import { NonPlainObject } from "../_internal/NonPlainObject.js"; //#region src/types/ToPascalCaseKeys.d.ts type SnakeToPascal = S extends `${infer H}_${infer T}` ? `${Capitalize>}${Capitalize>}` : Capitalize>; type CamelToPascal = S extends `${infer F}${infer R}` ? `${Uppercase}${R}` : S; /** If it's snake_case, apply the snake_case rule; for uppercase keys, lowercase and capitalize the entire string; otherwise, just uppercase the first letter (including camelCase → PascalCase). */ type AnyToPascal = S extends `${string}_${string}` ? SnakeToPascal : S extends Uppercase ? Capitalize> : CamelToPascal; /** * Converts the keys of `T` to PascalCase recursively. * * This is the return type of the `toPascalCaseKeys` function. Recurses into * plain objects and arrays; built-in objects like `Date`, `Map`, and functions * pass through unchanged. * * @template T - The type whose keys are converted. * * @example * type Response = { userId: number; firstName: string }; * type Converted = ToPascalCaseKeys; * // => { UserId: number; FirstName: string } */ type ToPascalCaseKeys = T extends NonPlainObject ? T : T extends any[] ? Array> : T extends Record ? { [K in keyof T as AnyToPascal>]: ToPascalCaseKeys } : T; //#endregion export { ToPascalCaseKeys };