Created
April 14, 2023 10:16
-
-
Save vannio/73eb287729d27d2176bcbf9e69831030 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CamelizeString<T extends PropertyKey> = T extends string | |
? string extends T | |
? string | |
: T extends `${infer F}_${infer R}` | |
? `${F}${Capitalize<CamelizeString<R>>}` | |
: string extends T | |
? string | |
: T extends `${infer F}-${infer R}` | |
? `${F}${Capitalize<CamelizeString<R>>}` | |
: T | |
: T; | |
type Camelize<T> = { [K in keyof T as CamelizeString<K>]: T[K] }; | |
type Camelized = Camelize<{'kebab-case': string, 'snake_case': string} |
Author
vannio
commented
Apr 14, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment