title: TypeScript: Use types on call() from redux-saga
body: <p>How can I set the types of a function using <code>call()</code>?</p>
  <p>I have this function:</p>
  <pre><code>export function apiFetch&lt;T&gt;(url: string): Promise&lt;T&gt; {
      return fetch(url).then(response =&gt; 
          {
              if (!response.ok) throw new Error(response.statusText)
              return response.json().then(data =&gt; data as T);
          }
      )  
  }
  </code></pre>
  <p>This function can be used like:</p>
  <pre><code>let resp = await apiFetch&lt;ServerResponse&gt;(&quot;http://localhost:51317/Task&quot;);
  </code></pre>
  <p>By using the function as you can see in the above piece of code, <code>resp</code> is correctly string-typed. So intellisense offers me all the attributes of the <code>ServerResponse</code> interface.</p>
  <p>However, this function has to be call inside a worker from <code>redux-saga</code> which does not allow, async functions:</p>
  <pre><code>function* refreshTaskSaga():any {
      yield takeEvery(&quot;TASK_REFRESH&quot;, workerRefreshTaskSaga);
  }
  
  
  function* workerRefreshTaskSaga() {
    //I need to call the function here
  }
  </code></pre>
  <p>I try to call it using yield + call, as <code>redux-saga</code> documentation said:</p>
  <pre><code>a) let resp = yield call(apiFetch, &quot;http://localhost:51317/Task&quot;);
  b) let resp = yield call(apiFetch&lt;ServerResponse&gt;, &quot;http://localhost:51317/Task&quot;);
  </code></pre>
  <p>The first option, execute the function as expected, however <code>resp</code> has <code>any</code> type.
  The second options throws me an exception.</p>
  <pre><code>No overload matches this call.
    The last overload gave the following error.
      Argument of type 'boolean' is not assignable to parameter of type '{ context: unknown; fn: (this: unknown, ...args: any[]) =&gt; any; }'.ts(2769)
  effects.d.ts(499, 17): The last overload is declared here.
  </code></pre>
  <p>Any idea of the correct syntax to call it and don't lose types?</p>