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

bug: type error on updating cache with bound mutate #2975

Open
Key5n opened this issue Jun 1, 2024 · 1 comment · May be fixed by #2933
Open

bug: type error on updating cache with bound mutate #2975

Key5n opened this issue Jun 1, 2024 · 1 comment · May be fixed by #2933

Comments

@Key5n
Copy link

Key5n commented Jun 1, 2024

Bug report

Description / Observed Behavior

According to the document, populateCache is used to transform the updated data from server into a desired form.
So mutate's data argument must accept any type, but currently the argument only accepts the same type as the type of returned value of fetcher.

The error occurs just in bound mutate.
Global mutate has no problems with populateCache.

Expected Behavior

bound mutate accepts any type

Repro Steps / Code Example

I created code sandbox.
https://codesandbox.io/p/sandbox/swr-mutate-with-populatecache-type-error-9h9ynk?file=/src/App.tsx

I could see there is a red line which tells type error in the code sandbox below.

image

Additional Context

In the code sandbox, the version of code sandbox is v2.2.5, but I confirmed the error also occurs in the latest commit.

@Key5n
Copy link
Author

Key5n commented Jun 1, 2024

I fixed the problem.
Please see this PR.

I'm waiting for any comments and requests!

Key5n added a commit to Key5n/swr that referenced this issue Jun 17, 2024
…ue of different value is assigned to mutate

issue: vercel#2975
Key5n added a commit to Key5n/swr that referenced this issue Jun 17, 2024
…ue of different value is assigned to mutate

issue: vercel#2975
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 a pull request may close this issue.

1 participant