import type {CamelCase} from '../camel-case.d.ts'; import type {DelimiterCase} from '../delimiter-case.d.ts'; import type {PascalCase} from '../pascal-case.d.ts'; import type {ScreamingSnakeCase} from '../screaming-snake-case.d.ts'; import type {UnknownArray} from '../unknown-array.d.ts'; import type {WordsOptions} from '../words.d.ts'; import type {IsArrayOfUnknownLength} from './array.d.ts'; import type {NonRecursiveType} from './type.d.ts'; /** The casing that {@link CasedPropertiesDeep} converts every key to: camel case, pascal case, screaming snake case, or a delimiter case such as `{delimiter: '-'}`. */ export type PropertyCasing = 'camel' | 'pascal' | 'screamingSnake' | {delimiter: string}; /** Converts one key to the given casing. */ type CaseKey = Casing extends 'camel' ? CamelCase : Casing extends 'pascal' ? PascalCase : Casing extends 'screamingSnake' ? ScreamingSnakeCase : Casing extends {delimiter: infer Delimiter extends string} ? DelimiterCase : never; /** The shared walker behind `CamelCasedPropertiesDeep`, `PascalCasedPropertiesDeep`, `ScreamingSnakeCasedPropertiesDeep` and `DelimiterCasedPropertiesDeep`. Converts the keys of every object it finds, and rebuilds arrays, tuples, maps and sets around their converted contents. Options are forwarded to the scalar casing types, which resolve their own defaults. */ export type CasedPropertiesDeep = Value extends NonRecursiveType ? Value : Value extends UnknownArray ? IsArrayOfUnknownLength extends false // A homomorphic mapped type keeps the length, the optional elements, the rest element and `readonly`, without a recursion step per element. ? {[Key in keyof Value]: CasedPropertiesDeep} // An array of unknown length is rebuilt directly, because mapping it makes a recursive element type, such as `JsonValue`, infinitely deep. : Value extends unknown[] ? Array> : ReadonlyArray> : Value extends Map ? Map, CasedPropertiesDeep> : Value extends ReadonlyMap ? ReadonlyMap, CasedPropertiesDeep> : Value extends WeakMap ? WeakMap, CasedPropertiesDeep> : Value extends Set ? Set> : Value extends ReadonlySet ? ReadonlySet> : Value extends WeakSet ? WeakSet> : Value extends object ? {[Key in keyof Value as CaseKey]: CasedPropertiesDeep} : Value; export {};