Skip to content

Commit

Permalink
Fix CamelCaseKeys type.
Browse files Browse the repository at this point in the history
  The T[P] in the type definition of CamelCaseKeys could be anything and did not always satisfy the constraint of the generics argument T.
  • Loading branch information
Masa-Shin committed Aug 29, 2022
1 parent 1082010 commit c1003eb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions index.d.ts
Expand Up @@ -45,16 +45,18 @@ export type CamelCaseKeys<
> = T extends readonly any[]
// Handle arrays or tuples.
? {
[P in keyof T]: T[P] extends Record<string, any> | readonly any[]
// eslint-disable-next-line @typescript-eslint/ban-types
[P in keyof T]: {} extends CamelCaseKeys<T[P]>
? T[P]
: CamelCaseKeys<
T[P],
Deep,
IsPascalCase,
Exclude,
StopPaths
>;
? {} extends CamelCaseKeys<T[P]>
? T[P]
: CamelCaseKeys<
T[P],
Deep,
IsPascalCase,
Exclude,
StopPaths
>
: T[P];
}
: T extends Record<string, any>
// Handle objects.
Expand Down

0 comments on commit c1003eb

Please sign in to comment.