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

useSWRMutation - Type error: Expected 2-3 arguments, but got 1. #2921

Open
mindsworth opened this issue Mar 22, 2024 · 1 comment
Open

useSWRMutation - Type error: Expected 2-3 arguments, but got 1. #2921

mindsworth opened this issue Mar 22, 2024 · 1 comment

Comments

@mindsworth
Copy link

info: v2.2.5

Bug report

I am not really sure if it's bug but I believe it to be a type bug.

Description / Observed Behavior

In my current project Nextjs 14.1.4, Typescript 5. I have successfully setup swr with global swrConfig where I have added the fetcher and all is perfectly working as expected, except the type error Type error: Expected 2-3 arguments, but got 1. that I'm getting since I am not passing the fetcher option.

Screenshot 2024-03-22 at 11 34 40

Is there how I can extend the type declaration to make fetcher optional?

Thanks for the good work, SWR is a great tool.

Note: The code is working as expected, just the type.

@mindsworth
Copy link
Author

After spending some time on this I was able to extend the type by adding the following line to this file swr.d.ts;

Screenshot 2024-03-22 at 14 57 34

But it will be cool if this can be made optional here

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