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

FetcherResponse not exported #3038

Open
MonstraG opened this issue Nov 13, 2024 · 0 comments
Open

FetcherResponse not exported #3038

MonstraG opened this issue Nov 13, 2024 · 0 comments

Comments

@MonstraG
Copy link

MonstraG commented Nov 13, 2024

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)

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

1 participant