You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we look at the definition of useAsyncFn or useAsync we can see that args is defined as Args | [] which means that the function passed must have only optional arguments
To correct, we would remove | [] from args for all these functions, which will allow typescript to work out what Args should be, either an empty array or the parameters given.
You can see the two different generic arguments here...
Hi all! @react-hookz/web, the new library by one of react-use's former maintainers (background here and here) has implemented a useAsync hook that is much more ergonomic and typescript friendly. You might want to check it out!
If we look at the definition of
useAsyncFn
oruseAsync
we can see thatargs
is defined asArgs | []
which means that the function passed must have only optional argumentsTo correct, we would remove
| []
fromargs
for all these functions, which will allow typescript to work out whatArgs
should be, either an empty array or the parameters given.You can see the two different generic arguments here...
http://www.typescriptlang.org/play/#code/GYVwdgxgLglg9mABBEAnVBTMUA8AlDAZxABspEBeRAQzAE8AaRAQVQHNDEMAPKLAE0606AbQC6lGvXEA+ABTAwALkRyAdBurtCK1h0QAfROICUlGYgLEyZgN4AoRE8SYoaJIoDc9gL6J79qCQsAhc3AAOGNAY-PhEpORUwkx6nDx8YIJSohJJ0mLyiirqmtq62mYUFlYJdo7Oru6IXr7+9ijoWFByctQqhFCoMGBslRbUJnIARFMm3h2Y2D3UAPz9g8Oj5jSTM3PtaIvdvWuIA0MjYzty+wtdPVd7N972PJHR-MvrF1tV13veN5RPifE7fTZXCbTWaAiLAmLLU7nCHbKH7IEfB7bJ77exAA
This issue makes all functions that use
Args | []
unusable for me when using typescript.Here is an example of what I'm running into...
The text was updated successfully, but these errors were encountered: