diff --git a/packages/nuxt/src/app/composables/fetch.ts b/packages/nuxt/src/app/composables/fetch.ts index c4c1d2b083..a3cb38fc51 100644 --- a/packages/nuxt/src/app/composables/fetch.ts +++ b/packages/nuxt/src/app/composables/fetch.ts @@ -13,7 +13,7 @@ type AvailableRouterMethod = _AvailableRouterMethod export type FetchResult> = TypedInternalResponse> type ComputedOptions> = { - [K in keyof T]: T[K] extends Function ? T[K] : T[K] extends Record ? ComputedOptions | Ref | T[K] : Ref | T[K] + [K in keyof T]: T[K] extends Function ? T[K] : ComputedOptions | Ref | T[K] } interface NitroFetchOptions = AvailableRouterMethod> extends FetchOptions { diff --git a/test/fixtures/basic-types/types.ts b/test/fixtures/basic-types/types.ts index 11baf9366f..3f692400c1 100644 --- a/test/fixtures/basic-types/types.ts +++ b/test/fixtures/basic-types/types.ts @@ -406,6 +406,17 @@ describe('composables', () => { expectTypeOf(test).toEqualTypeOf() }) + it('allows passing reactive values in useFetch', () => { + useFetch('/api/hey', { + headers: { + key: ref('test') + }, + query: { + param: computed(() => 'thing') + } + }) + }) + it('correctly types returns with key signatures', () => { interface TestType { id: string