Skip to content

Commit 94659ee

Browse files
committed
fix(helpers): handle any type in RequiredKeysOf
When RequiredKeysOfHelper<T> evaluates to 'any' (e.g., when T is 'any'), RequiredKeysOf should return 'never' to indicate no required keys. This fixes the issue where using createClient<any>() with placeholder OpenAPI types would incorrectly require the second parameter in API calls like client.GET('/path'). The fix adds an additional conditional check: RequiredKeysOfHelper<T> extends any ? never This ensures that when paths type is 'any' (common when using placeholder types or fallback schemas), the second parameter becomes optional, allowing builds to succeed without type errors.
1 parent 12f9c29 commit 94659ee

File tree

1 file changed

+1
-1
lines changed
  • packages/openapi-typescript-helpers/src

1 file changed

+1
-1
lines changed

packages/openapi-typescript-helpers/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@ type RequiredKeysOfHelper<T> = {
198198
[K in keyof T]: {} extends Pick<T, K> ? never : K;
199199
}[keyof T];
200200
/** Get the required keys of an object, or `never` if no keys are required */
201-
export type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T>;
201+
export type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T> extends any ? never : RequiredKeysOfHelper<T>;

0 commit comments

Comments
 (0)