Type Challenges Judge

BEM style string

提出詳細

type BEM<B extends string, E extends string[], M extends string[]> = `${B}${E["length"] extends 0 ? "" : `__${E[number]}`}${M["length"] extends 0 ? "" : `--${M[number]}`}`
提出日時2023-09-02 15:55:37
問題BEM style string
ユーザーookkoouu
ステータス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' >>, ]