title: Typescript - Get typeof function arguments
body: <p>Is it possible to get the type of a function's arguments with TypeScript?</p>
  
  <p>I have a function that returns another function that returns a promise:</p>
  
  <pre><code>type login = (params: LoginParams) =&gt; dispatched
  type dispatched = (dispatch: Dispatch) =&gt; Promise&lt;any&gt;
  </code></pre>
  
  <p>I would like to create a generic type that takes function as a param and creates a new function type. For example:</p>
  
  <pre><code>GenericFunctionType&lt;login&gt;
  </code></pre>
  
  <p>Would create the following type:</p>
  
  <pre><code>(LoginParams) =&gt; Promise&lt;any&gt;
  </code></pre>
  
  <p>In short GenericFunctionType creates a function type with the arguments of the initial function (login) and return value of the returned function (dispatched).</p>
  
  <hr>
  
  <p>I want this because I am using Redux. Here is my use case:</p>
  
  <pre><code>//Action Creator
  export type login = (params: LoginParams) =&gt; ThunkAction&lt;Promise&lt;any&gt;&gt;;
  
  export const login: login = params =&gt; async dispatch =&gt; {
    dispatch({ type: LOGIN });
  
    const promise = httpClient.post('/auth/sign_in', params);
  
    ...stuff
  
    return promise;
  };
  </code></pre>
  
  <p>My Login component is connected like so:</p>
  
  <pre><code>interface LoginProps {
    login: ???
  }
  
  class Login extends React.component&lt;LoginProps, {}&gt; {...}
  
  connect(null, {login})(Login)
  </code></pre>
  
  <p>I'm trying to find a reusable way of typing action creators that have been wrapped in dispatch (which is what <code>connect</code> does).</p>