CamelCase
提出詳細
type CamelCase<S extends string> = Lowercase<S> extends `${infer L}_${infer R}` ? R extends `${infer RL}${infer RR}` ? `${L}${Uppercase<RL>}${CamelCase<RR>}` : L : Lowercase<S>
提出日時 | 2023-08-09 08:57:02 |
---|---|
問題 | 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<'😎'>, '😎'>>, ]