Created
November 28, 2021 02:04
-
-
Save eddiemoore/bd59502aaea8f59fe970e2845a55d129 to your computer and use it in GitHub Desktop.
TypeScript CamelCase type
This file contains hidden or 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 CamelCase<T> = T extends `-${infer A}-${infer B}` | |
? `${A}${Capitalize<CamelCase<B>>}` | |
: T extends `${infer A}-${infer B}` | |
? `${A}${Capitalize<CamelCase<B>>}` | |
: T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment