Skip to content

Conversation

@kachkaev
Copy link
Contributor

@kachkaev kachkaev commented Aug 21, 2020

This PR fixes a possible regression from #897. The typing matches the JSDoc again now.

@vercel
Copy link

vercel bot commented Aug 21, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tannerlinsley/react-query/hv0r4mej2
✅ Preview: https://react-query-git-fork-kachkaev-fix-fetchinterval-typing.tannerlinsley.vercel.app

@kachkaev
Copy link
Contributor Author

kachkaev commented Aug 21, 2020

Since we're touching this file, does enabled?: boolean | unknown make sense on line 74? Should not it be enabled?: boolean? Happy to update the PR if that makes sense.

@boschni
Copy link
Collaborator

boschni commented Aug 21, 2020

Thanks for the PR @kachkaev ! I do wonder if it makes much sense to accept false as refetch interval. Either you provide one or you don't? The idea behind the enabled property is that you can provide any truthy value, although personally I would also be in favour to be a little bit stricter here ;)

@kachkaev
Copy link
Contributor Author

kachkaev commented Aug 22, 2020

The docs above the type definition say:

  • If set to a number, the query will continuously refetch at this frequency in milliseconds.
  • Defaults to false.

I checked the logic of the method and can confirm that it works with false. Setting the value to false can be useful when overriding another non-default config value from, say, a context provider.

Since false works the same as 0 or Infinity, we can restrict the value to ?: number, but this would be a breaking change. Could this be postponed till v3?

Same for enabled: we can potentially keep boolean | unknown to avoid breaking changes in v2, but I guess it should become boolean in v3. If someone passes a non-boolean value, they would have to wrap it in !!value or Boolean(value)

@boschni
Copy link
Collaborator

boschni commented Aug 23, 2020

In case of the cache provider you can also override it with undefined, but I agree it would be better to postpone these changes until v3 as they are indeed breaking. Let's keep false as valid value for now.

@tannerlinsley tannerlinsley merged commit 3ebb454 into TanStack:master Aug 24, 2020
@tannerlinsley
Copy link
Member

🎉 This PR is included in version 2.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kachkaev kachkaev deleted the fix-fetchInterval-typing branch August 24, 2020 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants