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

Improved type support for suspense is not working well #2396

Closed
mehm8128 opened this issue Jan 29, 2023 · 0 comments · Fixed by #2452 or #2506
Closed

Improved type support for suspense is not working well #2396

mehm8128 opened this issue Jan 29, 2023 · 0 comments · Fixed by #2452 or #2506
Labels
area: typing wontfix This will not be worked on

Comments

@mehm8128
Copy link

mehm8128 commented Jan 29, 2023

Bug report

Description / Observed Behavior

In v2.0.1, #2301 improved type support for suspense, so when we make suspense true, data can't be undefined. But when we use generics for useSWR, this type support become not working.
The same is true of fallbackData.

I think it is because TypeScript hasn't support partial type inferring of generics.

image
image

Expected Behavior

Even if we use generics, data must not be undefined.

And in this way, it work as we expect.
image

Repro Steps / Code Example

I attached images above.

Additional Context

SWR version: v2.0.3

huozhi pushed a commit that referenced this issue Feb 24, 2023
* fix SWROptions type

* add undefined to config type

* fix typo

* add test case for suspense

* add test case for fallbackdata

* add test case for config is undefined

---------

Co-authored-by: taro <taro.onishi@shelfy.jp>
connorch added a commit to connorch/swr that referenced this issue Mar 14, 2023
@promer94 promer94 added the wontfix This will not be worked on label Mar 14, 2023
promer94 pushed a commit that referenced this issue Mar 14, 2023
… type (#2506)

* add test case

* Revert "Fix: type support for suspense and fallbackData(#2396) (#2452)"

This reverts commit 04df1bf.

* fix: better tests that now properly explain why partial type inferrence won't work in typescript

* add test for passing in a config of type SWRConfiguration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: typing wontfix This will not be worked on
Projects
None yet
3 participants