diff --git a/packages/nuxt/src/app/composables/asyncData.ts b/packages/nuxt/src/app/composables/asyncData.ts index 3f0cc48ced..a809ff2f09 100644 --- a/packages/nuxt/src/app/composables/asyncData.ts +++ b/packages/nuxt/src/app/composables/asyncData.ts @@ -127,7 +127,7 @@ export type AsyncData = _AsyncData & Promise<_AsyncDat */ export function useAsyncData< ResT, - NuxtErrorDataT = unknown, + NuxtErrorDataT = Error, DataT = ResT, PickKeys extends KeysOf = KeysOf, DefaultT = undefined, @@ -143,7 +143,7 @@ export function useAsyncData< */ export function useAsyncData< ResT, - NuxtErrorDataT = unknown, + NuxtErrorDataT = Error, DataT = ResT, PickKeys extends KeysOf = KeysOf, DefaultT = DataT, @@ -160,7 +160,7 @@ export function useAsyncData< */ export function useAsyncData< ResT, - NuxtErrorDataT = unknown, + NuxtErrorDataT = Error, DataT = ResT, PickKeys extends KeysOf = KeysOf, DefaultT = undefined, @@ -178,7 +178,7 @@ export function useAsyncData< */ export function useAsyncData< ResT, - NuxtErrorDataT = unknown, + NuxtErrorDataT = Error, DataT = ResT, PickKeys extends KeysOf = KeysOf, DefaultT = DataT, @@ -189,7 +189,7 @@ export function useAsyncData< ): AsyncData | DefaultT, NuxtErrorDataT | undefined> export function useAsyncData< ResT, - NuxtErrorDataT = unknown, + NuxtErrorDataT = Error, DataT = ResT, PickKeys extends KeysOf = KeysOf, DefaultT = undefined, diff --git a/test/fixtures/basic-types/types.ts b/test/fixtures/basic-types/types.ts index f549c59175..3887cf5b45 100644 --- a/test/fixtures/basic-types/types.ts +++ b/test/fixtures/basic-types/types.ts @@ -43,7 +43,7 @@ describe('API routes', () => { expectTypeOf(useAsyncData('api-other', () => $fetch('/api/other')).data).toEqualTypeOf>() expectTypeOf(useAsyncData('api-generics', () => $fetch('/test')).data).toEqualTypeOf>() - expectTypeOf(useAsyncData('api-error-generics', () => $fetch('/error')).error).toEqualTypeOf>() + expectTypeOf(useAsyncData('api-error-generics', () => $fetch('/error')).error).toEqualTypeOf>() expectTypeOf(useAsyncData('api-error-generics', () => $fetch('/error')).error).toEqualTypeOf>() // backwards compatibility expectTypeOf(useAsyncData('api-error-generics', () => $fetch('/error')).error).toEqualTypeOf>()