Created
July 31, 2022 23:04
-
-
Save Luisgustavom1/251365d5c9cf54da097c8db33e85d0e2 to your computer and use it in GitHub Desktop.
Type-challenges - 612 Medium kebabcase
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
// 00612 - Medium kebabcase | |
type KebabCase<T extends string> = | |
T extends `${infer F}${infer R}` | |
? R extends Uncapitalize<R> | |
? `${Uncapitalize<F>}${KebabCase<R>}` | |
: `${Uncapitalize<F>}-${KebabCase<R>}` | |
: T | |
export type KebabCaseResult = KebabCase<'FooBarBaz'> //foo-bar-baz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment