Skip to content

fix: Improve useSubscription typing #2525

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

Closed
wants to merge 2 commits into from

Conversation

oosawy
Copy link
Contributor

@oosawy oosawy commented Mar 23, 2023

Fixes useSubscription typing that is not accept generics and do not inter key type.

For the generics problem, I believe that is caused by the TypeScript behind the difference between type and interface, anyway using interface instead of type solves the ploblem.

Also, I checked other hooks (useSWR, useSWRInfinite, useSWRMutation, useSWRImmutable) and they used interface for typing and works fine.

reproduction:
https://stackblitz.com/edit/react-ts-ur5fbw?file=App.tsx

@oosawy oosawy requested review from shuding and huozhi as code owners March 23, 2023 15:43
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 45269fd:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

@oosawy oosawy changed the title Improve useSubscription typing fix: Improve useSubscription typing Mar 24, 2023
@promer94
Copy link
Collaborator

Thanks for your contribution!

but i need to address this issue and #2522 with a more complex implementation. Therefore, I have opened another pull request in #2535

So i will close this pr now, let me know if you have any further questions.

@promer94 promer94 closed this Mar 31, 2023
@oosawy oosawy deleted the fix/subscription-type branch April 14, 2023 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants