import { NonPlainObject } from "../_internal/NonPlainObject.mjs"; //#region src/types/ToConstantCaseKeys.d.ts type ConstantCase = S extends Lowercase ? Uppercase : S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize ? `${Uppercase}${ConstantCase}` : `${Uppercase}_${ConstantCase>}` : Uppercase; /** * Converts the keys of `T` to CONSTANT_CASE recursively. * * This is the return type of the `toConstantCaseKeys` 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 = ToConstantCaseKeys; * // => { USER_ID: number; FIRST_NAME: string } */ type ToConstantCaseKeys = T extends NonPlainObject ? T : T extends any[] ? Array> : T extends Record ? { [K in keyof T as ConstantCase]: ToConstantCaseKeys } : T; //#endregion export { ToConstantCaseKeys };