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

Missing export of type SWRInfiniteMutatorOptions starting from 2.2.5 #2951

Open
dzek69 opened this issue Apr 25, 2024 · 1 comment
Open

Missing export of type SWRInfiniteMutatorOptions starting from 2.2.5 #2951

dzek69 opened this issue Apr 25, 2024 · 1 comment

Comments

@dzek69
Copy link

dzek69 commented Apr 25, 2024

Bug report

Description / Observed Behavior

With 2.2.5 (it's not happening with 2.2.4) you can't have this code:

import type { SWRInfiniteResponse } from "swr/infinite";

export const useStuff = (): SWRInfiniteResponse<unknown> => {};

export const useGetAllAssets = () => {
  const { mutate } = useStuff();

  return { mutate };
};

Because TypeScript can't access the type of mutate to correctly set the return type of useGetAllAssets in the .d.ts file.

This error appears:

TS4023: Exported variable useGetAllAssets has or is using name SWRInfiniteMutatorOptions from external module
"/Projects/stuff/node_modules/.pnpm/swr@2.2.5_react@18.2.0/node_modules/swr/dist/infinite/index"
but cannot be named.

Expected Behavior

There should be no TS error, SWRInfiniteMutatorOptions should be available to import.

Repro Steps / Code Example

Code example is shared above.

Additional Context

SWR version: 2.2.5
There is no problem with 2.2.4, other versions are untested.

@ryohidaka
Copy link

Related: #2954

ryohidaka added a commit to ryohidaka/use-backlog that referenced this issue May 8, 2024
- Due to the following bugs
  - vercel/swr#2951
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

No branches or pull requests

2 participants