Skip to content

Fix VariableFn<V> type returns Object instead of V #726

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

Merged
merged 1 commit into from
Sep 3, 2019
Merged

Fix VariableFn<V> type returns Object instead of V #726

merged 1 commit into from
Sep 3, 2019

Conversation

bbugh
Copy link
Contributor

@bbugh bbugh commented Aug 11, 2019

The VariableFn<V> type incorrectly returns any Object type, rather than the type specified by V. This is a small change but has a high impact on type correctness.

This resulted in an easily preventable typing bug in our app. Here is a simplified example:

apollo: {
  project (): VueApolloQueryOptions<ProjectQueryVariables, ProjectQuery> {
    return {
      variables: { projectId: 5 }, // ❌ should be just id, but the type isn't checked 😢
      query: PROJECT_QUERY,
      fetchPolicy: 'network-only'
    }
  }
}

This means that the variables key of a few important things don't actually check V variables type:

  • ApolloVueSubscribeToMoreOptions<V>
  • VueApolloQueryOptions<V, R>
  • VueApolloMutationOptions<V, R>
  • VueApolloSubscriptionOptions<V, R>

The `VariableFn<V>` type incorrectly returns any `Object` type, rather than the type specified by `V`.
@Akryum Akryum merged commit faba677 into vuejs:master Sep 3, 2019
@ciscorn
Copy link
Contributor

ciscorn commented Sep 5, 2019

V means a vue instance not variables.

This merge has broken many things as the CI results shows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants