title: React-query and Typescript - how to properly type a mutation result?
body: <p>I have a simple hook that wraps the axios call in React Query:</p>
  <pre><code>function useInviteTeamMember(
    onSuccess?: Handler,
    onError?: Handler,
  ): UseMutationResult&lt;User&gt; {
    const mutation = useMutation(
      (payload: InviteMutationVars) =&gt; {
        return postInviteTeamMember(payload);
      },
      {
        onSuccess: (data) =&gt; {
      ...
  </code></pre>
  <p>The issue I have is that from the above definition you would expect the result to be of type User.
  Even in that onSuccess handler (data) is according to intellisense of type User.
  But it's not.
  To get the actual User object I have to do data['data'].</p>
  <p>The actual post function is the root cause I think, since it types the Promise with :</p>
  <pre><code>export function postInviteTeamMember(payload: InviteMutationVars): Promise&lt;User&gt; {
    return client.post('/user/invite/team', payload);
  }
  </code></pre>
  <p>So how can I rewrite this code so that the type of 'data' is correct?</p>