title: Conditional types and infer in typescript to reduce redux boilerplate
body: <p>Sorry if this question is ill-posed, but i'm stuck trying to figure out how to do this. As described in the titel, I'm trying to reduce boilerplate in redux. Here's the issue:</p>
  
  <p>I have <code>ApiUtils.ts</code>, and my actions <code>ApiActions</code> (and later, <code>ApiReducer</code>, but that's a separate issue).</p>
  
  <p>My <code>ApiUtils</code> largely have functions that look like this:</p>
  
  <pre><code>export function updateUserAPI(id: string, data: Partial&lt;User&gt;) {
    return axios.put&lt;User&gt;(`${usersUrl}/${id}`, data)
  }
  </code></pre>
  
  <p>My question is that given that i am using <code>creatAction</code> from <a href="https://github.com/piotrwitek/typesafe-actions#createaction" rel="nofollow noreferrer">https://github.com/piotrwitek/typesafe-actions#createaction</a>, I'd like to automate some of this and provide type safety.</p>
  
  <p>Right now, setting up actions looks something like this: </p>
  
  <pre><code>export const updateUser = createAction('UPDATE_USER', resolve =&gt; (user: Partial&lt;User&gt;) =&gt; resolve({ user }))
  </code></pre>
  
  <p>ie, i would like to have something of the form: <code>function createApiAction&lt;fn&gt; { ... }</code> where I can provide the ApiUtils.updateUserAPI and it would then it would infer the signature for <code>resolve =&gt; (user: Partial&lt;User&gt;) =&gt; resolve({ user})</code> parameter.</p>
  
  <p>I'm not really sure how to go about this. I've been playing with the tuple args from typescript 3.0+ and <code>infer</code>, but that's not sure how to tie them together to get what I want</p>