Vue-apollo: Incomplete typings for `UseMutationReturn` on @vue/apollo-composable

Created on 6 Feb 2020  路  2Comments  路  Source: vuejs/vue-apollo

Versions
apollo-composable: 4.0.0-alpha.6

In useMutation.d.ts the return type of the function mutate is actually

Promise<FetchResult<any, Record<string, any>, Record<string, any>>>;

I should be fixed with TResult

Promise<FetchResult<TResult, Record<string, any>, Record<string, any>>>;
pending triage

Most helpful comment

I get (with "@vue/apollo-composable": "^4.0.0-alpha.8"):

 ERROR  ERROR in /@app/server/node_modules/@vue/apollo-composable/dist/useMutation.d.ts(45,340):
45:340 Type 'MutateWithRequiredVariables<TResult, TVariables>' does not satisfy the constraint 'MutateWithOptionalVariables<TResult, TVariables>'.
  Types of parameters 'variables' and 'variables' are incompatible.
    Type 'TVariables | undefined' is not assignable to type 'TVariables'.
      Type 'undefined' is not assignable to type 'TVariables'.
    43 |  * Use a mutation with variables, but without a default.
    44 |  */
  > 45 | export declare function useMutation<TResult = any, TVariables extends OperationVariables = OperationVariables>(document: DocumentNode | ReactiveFunction<DocumentNode>, options?: UseMutationOptionsNoVariables<TResult, undefined> | ReactiveFunction<UseMutationOptionsNoVariables<TResult, undefined>>): UseMutationReturn<TResult, TVariables, MutateWithRequiredVariables<TResult, TVariables>>;
       |                                                                                                                                                                                                                                                                                                                                                    ^
    46 | export {};
    47 |

All 2 comments

I get (with "@vue/apollo-composable": "^4.0.0-alpha.8"):

 ERROR  ERROR in /@app/server/node_modules/@vue/apollo-composable/dist/useMutation.d.ts(45,340):
45:340 Type 'MutateWithRequiredVariables<TResult, TVariables>' does not satisfy the constraint 'MutateWithOptionalVariables<TResult, TVariables>'.
  Types of parameters 'variables' and 'variables' are incompatible.
    Type 'TVariables | undefined' is not assignable to type 'TVariables'.
      Type 'undefined' is not assignable to type 'TVariables'.
    43 |  * Use a mutation with variables, but without a default.
    44 |  */
  > 45 | export declare function useMutation<TResult = any, TVariables extends OperationVariables = OperationVariables>(document: DocumentNode | ReactiveFunction<DocumentNode>, options?: UseMutationOptionsNoVariables<TResult, undefined> | ReactiveFunction<UseMutationOptionsNoVariables<TResult, undefined>>): UseMutationReturn<TResult, TVariables, MutateWithRequiredVariables<TResult, TVariables>>;
       |                                                                                                                                                                                                                                                                                                                                                    ^
    46 | export {};
    47 |

Same issue with a clean install of `"@vue/apollo-composable": "^4.0.0-alpha.8". I see there's already a PR. It would be great if this could be merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alsofronie picture alsofronie  路  3Comments

beeplin picture beeplin  路  4Comments

wangxiangyao picture wangxiangyao  路  4Comments

Akryum picture Akryum  路  3Comments

danthareja picture danthareja  路  4Comments