Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

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

Comments

@clockk
Copy link
Contributor

clockk 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

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

No branches or pull requests

1 participant