feat(core-extensions): Narrow type of array in mapKeys

This commit is contained in:
T. R. Bernstein
2025-07-04 00:23:42 +02:00
parent 1704dd4c07
commit dabf978096

View File

@@ -1,8 +1,7 @@
export type MappedKeys<T, R extends string> =
T extends Array<infer U>
? Array<MappedKeys<U, R>>
: T extends object
? {
[K in keyof T as R]: MappedKeys<T[K], R>
}
: T
export type MappedKeys<T, R extends string> = T extends any[]
? { [K in keyof T]: MappedKeys<T[K], R> }
: T extends object
? {
[K in keyof T as R]: MappedKeys<T[K], R>
}
: T