Type Challenges Judge

BEM style string

提出詳細

type NeverToEmpty<T> = [T] extends [never] ? "" : T type BEM<B extends string, E extends string[], M extends string[]> = `${B}${NeverToEmpty<`__${E[number]}`>}${NeverToEmpty<`--${M[number]}`>}`
提出日時2023-09-16 00:59:03
問題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' >>, ]