type IsStringLiteral = Type extends string ? (string extends Type ? false : true) : false; type WordInCamelCase = Type extends `${Word}${infer NextCharacter}${infer _}` ? NextCharacter extends Capitalize ? Word : WordInCamelCase : Word; type Separator = "_" | "-"; type IncludesSeparator = Type extends `${string}${Separator}${string}` ? true : false; type IsOneWord = Type extends Lowercase ? true : Type extends Uppercase ? true : false; type IsCamelCase = Type extends Uncapitalize ? true : false; type IsPascalCase = Type extends Capitalize ? true : false; /** snake_case, CONSTANT_CASE, kebab-case or COBOL-CASE */ type SeparatorCaseParser = Type extends `${infer Word}${Separator}${infer Tail}` ? SeparatorCaseParser]> : Type extends `${infer Word}` ? [...Tuple, Lowercase] : Tuple; type CamelCaseParser = Type extends "" ? Tuple : Type extends `${WordInCamelCase}${infer Tail}` ? Type extends `${infer Word}${Tail}` ? CamelCaseParser, [...Tuple, Lowercase]> : never : never; type PascalCaseParser = Type extends string ? CamelCaseParser> : never; type SplitAnyCase = IncludesSeparator extends true ? SeparatorCaseParser : IsOneWord extends true ? [Lowercase] : IsCamelCase extends true ? CamelCaseParser : IsPascalCase extends true ? PascalCaseParser : []; type PascalCapitalizer = Type extends [infer Head, ...infer Tail] ? Head extends string ? PascalCapitalizer]> : PascalCapitalizer : Tuple; type CamelCapitalizer = Type extends [infer First, ...infer Tail] ? PascalCapitalizer : []; type Join = Type extends [infer Head, ...infer Tail] ? Head extends string ? Join : Join : JoinedString; export type CamelCase = IsStringLiteral extends true ? Join>> : Type; export {};