From c1003ebc393fd0864627d1937739fe2c25698628 Mon Sep 17 00:00:00 2001 From: Masahiko Shin Date: Mon, 29 Aug 2022 12:21:59 +0900 Subject: [PATCH] Fix CamelCaseKeys type. The T[P] in the type definition of CamelCaseKeys could be anything and did not always satisfy the constraint of the generics argument T. --- index.d.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index f4ee3c3..53a393c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -45,16 +45,18 @@ export type CamelCaseKeys< > = T extends readonly any[] // Handle arrays or tuples. ? { + [P in keyof T]: T[P] extends Record | readonly any[] // eslint-disable-next-line @typescript-eslint/ban-types - [P in keyof T]: {} extends CamelCaseKeys - ? T[P] - : CamelCaseKeys< - T[P], - Deep, - IsPascalCase, - Exclude, - StopPaths - >; + ? {} extends CamelCaseKeys + ? T[P] + : CamelCaseKeys< + T[P], + Deep, + IsPascalCase, + Exclude, + StopPaths + > + : T[P]; } : T extends Record // Handle objects.