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' >>, ]