Composition / foldkit-composition/foldkit

TextKey

type · packages/composition/src/foldkit/index.ts:33

type TextKey<Props> = {
  readonly [K in keyof Props]-?: [Props[K]] extends [string]
    ? string extends Props[K]
      ? K
      : never
    : never
}[keyof Props] &
  string

The props of Props that are any text, which field draws: a prop that is exactly string. One of a few names ('plain' | 'accent'), a branded string or one that may be absent is no field: typing could not keep it valid.