The issue is in the composables/test.ts file, and appears as an error on the default property.
Describe the bug
When creating a custom wrapper for useFetch as described in the documentation, the default option of UseFetchOptions is always () => Ref<null, null> | null, no matter what the type passed to UseFetchOptions is.
Additional context
As far as I can tell from looking through the type definitions, only the main ResT type is passed to the UseFetchOptions type:
The type used for the default option function comes from DefaultT on UseFetchOptions:
When using useFetch normally, DefaultT is set to the same type as ResT, but when using the custom wapper, DefaultT instead uses its default type of DefaultAsyncDataValue, which is null.
This is solvable by copying the types defined by useFetch and passed to UseFetchOptions, but this is not a realistic option because it requires a significant amount of boilerplate typing for the wrapper function.
Environment
Working directory: /home/projects/nuxt-starter-r4dshc Nuxt project info:
Build Modules: -
Reproduction
https://stackblitz.com/edit/nuxt-starter-r4dshc?file=composables%2Ftest.ts&view=editor
The issue is in the
composables/test.ts
file, and appears as an error on thedefault
property.Describe the bug
When creating a custom wrapper for
useFetch
as described in the documentation, thedefault
option ofUseFetchOptions
is always() => Ref<null, null> | null
, no matter what the type passed toUseFetchOptions
is.Additional context
As far as I can tell from looking through the type definitions, only the main
ResT
type is passed to theUseFetchOptions
type:The type used for the
default
option function comes fromDefaultT
onUseFetchOptions
:When using
useFetch
normally,DefaultT
is set to the same type asResT
, but when using the custom wapper,DefaultT
instead uses its default type ofDefaultAsyncDataValue
, which isnull
.This is solvable by copying the types defined by
useFetch
and passed toUseFetchOptions
, but this is not a realistic option because it requires a significant amount of boilerplate typing for the wrapper function.Logs