Extract correct type when using key parser mapping #548
Unanswered
guanboo-yang
asked this question in
Q&A
Replies: 1 comment 1 reply
|
Just to rule this out, have you checked https://nuqs.47ng.com/docs/batching Otherwise, the root of the issue is a TypeScript one rather than related to function useKeyState<K extends keyof typeof keyMap>(key: K) {
return useQueryState(key, keyMap[key])
}This should help "specialise" the call by narrowing it to only the key passed in the argument. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
First of all, thank you for the amazing package! I have encountered a scenario for which I'm seeking some guidance. Here's what I'm working with:
The behavior shown above is what I expected. However, I tried to create a helper hook to automatically select the correct parser, as shown below:
Unfortunately, this resulted in the wrong type being returned. Is there a way to extract the correct type in this context? I would greatly appreciate any guidance or suggestions you might have.
All reactions