Skip to content

TypeScript for atom with setter whose update type is different than the value type #1024

Closed Answered by dai-shi
elliotwaite asked this question in Q&A
Discussion options

You must be logged in to vote

This is sort of typescript limitation, and that's why we don't provide such examples in our docs.
In JS, it's valid. And, in TS, your solution is fine too.
Our current recommendation is to use two atoms, or use atomWithReducer (implemented with any).

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@elliotwaite
Comment options

@elliotwaite
Comment options

Answer selected by elliotwaite
Comment options

You must be logged in to vote
1 reply
@elliotwaite
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants