Skip to content

FetcherResponse not exported  #3038

Open
@MonstraG

Description

@MonstraG

Bug report

FetcherResponse type, which I believe is retuend by preload is not exported.

Description / Observed Behavior

In the following code:

import useSWR, { preload, type SWRResponse } from "swr";

export interface MyData {}

const myDataSwrKey = "/api/myData";

export const useMyData = (): SWRResponse<MyData> => {
	return useSWR<MyData>(myDataSwrKey, {
		fetcher: fetch,
		onError: (err) => {
			console.error(err);
		}
	});
};

export const preloadMyData = () => preload<MyData>(myDataSwrKey, fetch);

I have a generic usage of useSWR. I like to type exported values explicitly, so I add SWRResponse<MyData> to useMyData.

I would also like to annotate preloadMyData but FetcherResponse it returns is not exported from "swr", so I my IDE imports

import { FetcherResponse } from "swr/_internal";

Which is _internal so I probably should not use it.

Please, export FetcherResponse.

SWR version: 2.2.5

(the bug template kinda doesn't work, sorry)

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