CamelCase
提出詳細
type CamelCase<S extends string, Res extends string = ""> = S extends `_${infer L}${infer R}` ? CamelCase<R, `${Res}${Uppercase<L>}`> : S extends `${infer L}${infer R}` ? L extends string ? CamelCase<R, `${Res}${Lowercase<L>}`> : Res : Res
提出日時 | 2023-08-08 18:21:30 |
---|---|
問題 | CamelCase |
ユーザー | ookkoouu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<CamelCase<'foobar'>, 'foobar'>>, Expect<Equal<CamelCase<'FOOBAR'>, 'foobar'>>, Expect<Equal<CamelCase<'foo_bar'>, 'fooBar'>>, Expect<Equal<CamelCase<'foo_bar_hello_world'>, 'fooBarHelloWorld'>>, Expect<Equal<CamelCase<'HELLO_WORLD_WITH_TYPES'>, 'helloWorldWithTypes'>>, Expect<Equal<CamelCase<'-'>, '-'>>, Expect<Equal<CamelCase<''>, ''>>, Expect<Equal<CamelCase<'😎'>, '😎'>>, ]