Why do setters use Args extends unknown[]
and ...args: Args
for their types when you only pass one value?
#2523
Unanswered
AriaFallah
asked this question in
Q&A
Replies: 1 comment 8 replies
-
Because we support multiple arguments. This is a huge improvement in Jotai v2. For primitive atoms we set the type like this: Lines 59 to 65 in 7a68a12 |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm really confused because the types are currently written as
jotai/src/vanilla/atom.ts
Lines 3 to 10 in 7a68a12
But why is the value after atom
...args: Args
? I cannot find a single example ofset
called with more than one argument. Why is it not instead something likenewValue: Value | ((oldValue: Value) => Value)
?Beta Was this translation helpful? Give feedback.
All reactions