Skip to content

Commit

Permalink
fix: change readonly any[] to ReadonlyArray<Record<string, unknown>>
Browse files Browse the repository at this point in the history
  • Loading branch information
yutak23 committed Jan 12, 2024
1 parent 3e241fc commit bcdab0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ type AppendPath<S extends string, Last extends string> = S extends ''
Convert keys of an object to camelcase strings.
*/
export type CamelCaseKeys<
T extends ObjectUnion | readonly any[],
T extends ObjectUnion | ReadonlyArray<Record<string, unknown>>,
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<Record<string, unknown>>
// Handle arrays or tuples.
? {
[P in keyof T]: T[P] extends Record<string, unknown> | readonly any[]
[P in keyof T]: T[P] extends Record<string, unknown> | ReadonlyArray<Record<string, unknown>>
? CamelCaseKeys<
T[P],
Deep,
Expand All @@ -72,7 +72,7 @@ export type CamelCaseKeys<
]
? T[P]
: [Deep] extends [true]
? T[P] extends ObjectUnion | readonly any[]
? T[P] extends ObjectUnion | ReadonlyArray<Record<string, unknown>>
? CamelCaseKeys<
T[P],
Deep,
Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -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};
Expand Down

0 comments on commit bcdab0c

Please sign in to comment.