Skip to content
New issue

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

Key type inference doesn't work if the data generic is provided #1518

Closed
shuding opened this issue Oct 1, 2021 · 2 comments
Closed

Key type inference doesn't work if the data generic is provided #1518

shuding opened this issue Oct 1, 2021 · 2 comments

Comments

@shuding
Copy link
Member

shuding commented Oct 1, 2021

Bug report

Description / Observed Behavior

useSWR<Data>('/api', (endpoint) => sendRequestFor(endpoint))
                      ﹌﹌﹌﹌﹌ "Parameter 'endpoint' implicitly has an 'any' type.ts(7006)"

Expected Behavior

It would be great if we can workaround this.

Repro Steps / Code Example

N/A

Additional Context

SWR 1.1.0-beta.3.

@shuding
Copy link
Member Author

shuding commented Oct 5, 2021

Update: we need partial inference for this, AFAIK it's still not supported by TS yet (microsoft/TypeScript#26242).

@promer94 promer94 mentioned this issue Nov 19, 2021
@shuding
Copy link
Member Author

shuding commented Nov 26, 2021

Closed by #1640.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant