mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): resolve type error in options of useFetch
(#23693)
This commit is contained in:
parent
1487c5631a
commit
732507b41f
@ -13,7 +13,7 @@ type AvailableRouterMethod<R extends NitroFetchRequest> = _AvailableRouterMethod
|
||||
export type FetchResult<ReqT extends NitroFetchRequest, M extends AvailableRouterMethod<ReqT>> = TypedInternalResponse<ReqT, unknown, Lowercase<M>>
|
||||
|
||||
type ComputedOptions<T extends Record<string, any>> = {
|
||||
[K in keyof T]: T[K] extends Function ? T[K] : T[K] extends Record<string, any> ? ComputedOptions<T[K]> | Ref<T[K]> | T[K] : Ref<T[K]> | T[K]
|
||||
[K in keyof T]: T[K] extends Function ? T[K] : ComputedOptions<T[K]> | Ref<T[K]> | T[K]
|
||||
}
|
||||
|
||||
interface NitroFetchOptions<R extends NitroFetchRequest, M extends AvailableRouterMethod<R> = AvailableRouterMethod<R>> extends FetchOptions {
|
||||
|
11
test/fixtures/basic-types/types.ts
vendored
11
test/fixtures/basic-types/types.ts
vendored
@ -406,6 +406,17 @@ describe('composables', () => {
|
||||
expectTypeOf(test).toEqualTypeOf<string | undefined>()
|
||||
})
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user