We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
any
What kind of issues did you encounter with SWR?
How did you expect SWR to behave here?
Code exp:
import useSWR from 'swr'; type Data = { id: string }; type Endpoint = '/my-endpoint'; // want type safe endpoints ! const fetcher = (url: Endpoint): Promise<Data> => fetch(url).then((res) => res.json()); export const useTest = () => { const { data } = useSWR<Data>('/any-thing', (url) => fetcher(url)); };
as shown below the url is inferred as any and this way we could introduce incorrect urls without having compile error.
SWR version: 2.2.5. Add any other context about the problem here.
I want to be able to have something like this :
It could be possible and i was missing something, so it'll be helpful to verify with me. Thanks :)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug report
The key type is not type safe as it is evaluated to
any
What kind of issues did you encounter with SWR?
I expect the Key to be inferred as the provided value
How did you expect SWR to behave here?
Repro Steps / Code Example
Code exp:
as shown below the url is inferred as any and this way we could introduce incorrect urls without having compile error.
Additional Context
SWR version: 2.2.5.
Add any other context about the problem here.
I want to be able to have something like this :
It could be possible and i was missing something, so it'll be helpful to verify with me.
Thanks :)
The text was updated successfully, but these errors were encountered: