Type Challenges Judge

BEM style string

提出詳細

type Impl<B extends string, E extends string[], Delim extends string> = E extends [infer E1 extends string, ...infer E2 extends string[]] ? `${B}${Delim}${E1}` | Impl<B,E2,Delim> : never type BE<B extends string, E extends string[]> = E extends [] ? B : Impl<B,E,"__"> type BM<B extends string, M extends string[]> = M extends [] ? B : Impl<B,M,"--"> type BEM<B extends string, E extends string[], M extends string[]> = BM<BE<B,E>,M>
提出日時2023-09-16 00:47:49
問題BEM style string
ユーザーsankantsu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<BEM<'btn', ['price'], []>, 'btn__price'>>, Expect<Equal<BEM<'btn', ['price'], ['warning', 'success']>, 'btn__price--warning' | 'btn__price--success' >>, Expect<Equal<BEM<'btn', [], ['small', 'medium', 'large']>, 'btn--small' | 'btn--medium' | 'btn--large' >>, ]