Skip to content
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

refactor(query-core): change QueryMeta and MutationMeta to an interface #4253

Merged
merged 3 commits into from
Oct 7, 2022

Conversation

DaleWebb
Copy link
Contributor

@DaleWebb DaleWebb commented Oct 1, 2022

Changes the QueryMeta and MutationMeta types to interfaces, so that they can have their shapes overridden in the implementing codebase for safer typing and autocompletion.

interface Meta {
  persist?: boolean;
}

declare module '@tanstack/react-query' {
  interface QueryMeta extends Meta {}
}

useQuery(queryKey, {
  meta: {
    persist: false,
  },
});

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 1, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 06af0a2:

Sandbox Source
@tanstack/query-example-react-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-vue-basic Configuration

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript refers to these as index types in the docs:

https://www.typescriptlang.org/docs/handbook/2/objects.html#index-signatures

this is just a stylistic change though

packages/query-core/src/types.ts Outdated Show resolved Hide resolved
packages/query-core/src/types.ts Outdated Show resolved Hide resolved
@TkDodo TkDodo merged commit 9d364e7 into TanStack:main Oct 7, 2022
@umangjun92
Copy link

Can this be merged to version v3 as well

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