diff --git a/index.d.ts b/index.d.ts index 5e3d8d9..375c1c1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -39,17 +39,17 @@ type AppendPath = S extends '' Convert keys of an object to camelcase strings. */ export type CamelCaseKeys< - T extends ObjectUnion | readonly any[], + T extends ObjectUnion | ReadonlyArray>, Deep extends boolean = false, IsPascalCase extends boolean = false, PreserveConsecutiveUppercase extends boolean = false, Exclude extends readonly unknown[] = EmptyTuple, StopPaths extends readonly string[] = EmptyTuple, Path extends string = '', -> = T extends readonly any[] +> = T extends ReadonlyArray> // Handle arrays or tuples. ? { - [P in keyof T]: T[P] extends Record | readonly any[] + [P in keyof T]: T[P] extends Record | ReadonlyArray> ? CamelCaseKeys< T[P], Deep, @@ -72,7 +72,7 @@ export type CamelCaseKeys< ] ? T[P] : [Deep] extends [true] - ? T[P] extends ObjectUnion | readonly any[] + ? T[P] extends ObjectUnion | ReadonlyArray> ? CamelCaseKeys< T[P], Deep, diff --git a/index.test-d.ts b/index.test-d.ts index e08f9ef..2690ba7 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/indent */ -import {expectType, expectAssignable, expectNotType} from 'tsd'; +import {expectType, expectAssignable, expectNotType, expectError} from 'tsd'; import camelcaseKeys, {type CamelCaseKeys} from './index.js'; const fooBarObject = {'foo-bar': true};