Type Challenges Judge

CamelCase

提出詳細

type CamelCaseImpl<S extends string> = S extends `${infer S1}_${infer S2}` ? Capitalize<S2> extends S2 ? `${S1}_${CamelCaseImpl<S2>}` : `${S1}${CamelCaseImpl<Capitalize<S2>>}` : S type CamelCase<S extends string> = CamelCaseImpl<Lowercase<S>>
提出日時2023-09-20 02:45:51
問題CamelCase
ユーザーsankantsu
ステータス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<'😎'>, '😎'>>, ]