#2951·swr

Missing export of type `SWRInfiniteMutatorOptions` starting from 2.2.5

Author: dzek69Created Apr 25, 2024Updated Sep 1, 2026

Bug report

Description / Observed Behavior

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

typescript
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/[email protected][email protected]/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.