-
-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix TypeScript error when multiple clients are used #193
Conversation
types/vue-apollo.d.ts
Outdated
@@ -21,7 +21,7 @@ type VueApolloOptions = { | |||
export class VueApollo implements PluginObject<{}> { | |||
[key: string]: any; | |||
install: PluginFunction<{}>; | |||
constructor (options: { defaultClient: ApolloClient<{}>, defaultOptions?: VueApolloOptions }); | |||
constructor (options: { defaultClient: ApolloClient<{}>, defaultOptions?: VueApolloOptions, clients: { [key: string]:any } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@azulite
thanks! this is my mistake 🙇
Client property is optional value, so could you change it to type of optional value?
https://www.typescriptlang.org/docs/handbook/functions.html#optional-and-default-parameters
And I'm glad to run yarn run test:types
on your local machine.(Your changes cause to fail tests...)
types/vue-apollo.d.ts
Outdated
@@ -21,7 +21,7 @@ type VueApolloOptions = { | |||
export class VueApollo implements PluginObject<{}> { | |||
[key: string]: any; | |||
install: PluginFunction<{}>; | |||
constructor (options: { defaultClient: ApolloClient<{}>, defaultOptions?: VueApolloOptions }); | |||
constructor (options: { defaultClient: ApolloClient<{}>, defaultOptions?: VueApolloOptions, clients: { [key: string]:any } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to use ApolloClient<{}>[]
instead of any.
types/vue-apollo.d.ts
Outdated
@@ -21,7 +21,7 @@ type VueApolloOptions = { | |||
export class VueApollo implements PluginObject<{}> { | |||
[key: string]: any; | |||
install: PluginFunction<{}>; | |||
constructor (options: { defaultClient: ApolloClient<{}>, defaultOptions?: VueApolloOptions }); | |||
constructor (options: { defaultClient: ApolloClient<{}>, defaultOptions?: VueApolloOptions, clients: { [key: string]:any } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh yes I should run test and thank you for your suggestions! I am getting myself familiar with TypeScript still, your TS file saved my day 👏
Hello,
I am working on a project with Vue and Typescript. When I try to define multiple endpoints with below code:
There has TypeScript error that is described at below: