Replies: 1 comment
-
@samsch Same question! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
the function passed as
optimisticData
in mutate gets two parameters, wherecurrentData
can explicitly be undefined regardless ofData
(most recent updates from this PR: https://github.com/vercel/swr/pull/2708/files#diff-947adbc8aa4f84c3191ad83c84d1344a1fd311224f73a9f92e7b9eaa73860508R324). if you are using the function version ofoptimisticData
though, it's very possible you can't create the whole object expected, so can we explicitly allow the return value ofoptimisticData
to be undefined?Right now this gets a type error because
optimisticData
infers that the return value should beDataType
.It can be worked around by changing the first line to explicitly have the data type or undefined
The addition of an explicit type or undefined lets this work. but the value of swr.data is already allowed to be undefined.
Can we have optimisticData's inferred type also explicitly allow returning
undefined
?Beta Was this translation helpful? Give feedback.
All reactions