Skip to content

Commit c12959f

Browse files
committed
fix: missing autocomplete for query params when all query params are optional
1 parent eb304c2 commit c12959f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/runtime/fetchTypes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ type GetPathParams<Operation> = Operation extends {
125125

126126
type GetQueryParams<Operation> = Operation extends {
127127
parameters: {
128-
query: {};
128+
query?: {} | undefined | null;
129129
};
130130
}
131131
? HasRequiredProperties<Operation['parameters']['query']> extends true
@@ -140,7 +140,7 @@ type GetQueryParams<Operation> = Operation extends {
140140

141141
type GetHeaders<Operation> = Operation extends {
142142
parameters: {
143-
header: {};
143+
header?: {} | undefined | null;
144144
};
145145
}
146146
? HasRequiredProperties<Operation['parameters']['header']> extends true
@@ -255,7 +255,7 @@ export type NitroFetch<Paths extends Record<string, any>> = <
255255
]
256256
) => Promise<Response>;
257257

258-
export type SimplifiedUseFetchOptions = UseFetchOptions<void> & {
258+
export type SimplifiedUseFetchOptions = UseFetchOptions<any> & {
259259
pathParams?: MaybeRef<ComputedOptions<Record<string, string | number>>>;
260260
};
261261

src/runtime/typeUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import type { Ref } from 'vue';
55

66
export type OmitStrict<Object, Key extends keyof Object> = Omit<Object, Key>;
77

8-
export type HasRequiredProperties<Object> = {} extends Object ? false : true;
8+
export type HasRequiredProperties<Object> = Object extends {} | null | undefined
9+
? false
10+
: true;
911

1012
/** @see {@link https://github.com/nuxt/nuxt/blob/42114f44a60ae326b58c05afe92ad535227d8f37/packages/nuxt/src/app/composables/fetch.ts#L20} */
1113
export type ComputedOptions<T extends Record<string, any>> = {

0 commit comments

Comments
 (0)