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

Don't you need a strict type that only accepts valid factory keys? #98

Open
kis0421 opened this issue Sep 5, 2024 · 1 comment
Open

Comments

@kis0421
Copy link
Contributor

kis0421 commented Sep 5, 2024

Currently, queryOptions except 'queryKey' | 'queryFn' | 'contextQueries' are omitted.

    const store = createQueryKeyStore({
      users: {
        me: null,
        detail: (userId: string) => ({
          queryKey: [userId],
          refetchInterval: 5000,
          hihi: () => 'hi'
          queryFn: () => Promise.resolve({ id: userId }),
          contextQueries: {
            settings: null,
          },
        }),
      },
    });

In the example above, adding the refetchInterval hihi option does not cause a type warning.
Invalid queryOptions such as hihi are omitted and no error occurs at runtime, making it safe.

However, I think it can cause confusion because it does not work even though I entered a valid option in react-query. is there a reason not to perform strict type checking for queryOption, which is currently not supported, including the refetchInterval option?

Copy link

linear bot commented Sep 5, 2024

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

No branches or pull requests

1 participant