-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
🐛 Bug: Typing mismatch in useHttp
wrapper with useFetch
Description
When using the provided useHttp
wrapper that integrates $http
into Nuxt’s useFetch
, TypeScript raises an error in IDEs (e.g., PhpStorm):
Vue: No overload matches this call.
Overload 1 of 2, ‘(request: string | Ref<string, string> | (() => string), opts?: UseFetchOptions<…>): AsyncData<…>’, gave the following error.
Overload 2 of 2, ‘(request: string | Ref<string, string> | (() => string), opts?: UseFetchOptions<…>): AsyncData<…>’, gave the following error.
The error points to the following call in useHttp.ts
and useLazyHttp.ts
:
return useFetch(url, {
...options,
$fetch: $http as $Fetch
});
Expected Behavior
- useHttp should compile cleanly with proper type inference.
- $http should be compatible with useFetch’s $fetch option.
Actual Behavior
- TypeScript reports overload resolution errors.
- Casting (as $Fetch) is required to silence the error, but this is not ideal.
Environment
- Laravel: v12 (latest)
- Nuxt: v4 (latest)
- TypeScript: enabled
- IDE: PhpStorm
The repo defines $http on NuxtApp as a custom (request, opts) => Promise instead of aligning with ofetch’s $Fetch type, which useFetch expects. This mismatch leads to typing incompatibilities.
Metadata
Metadata
Assignees
Labels
No labels