Skip to content

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

Open
@Key5n

Description

@Key5n

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=%2Fsrc%2FApp.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions