Skip to content

QuizNot attempted

Template literal toast positions

Which values are assignable to ToastPosition?
type Horizontal = 'left' | 'right' | 'center';
type Vertical = 'top' | 'bottom' | 'center';
type ToastPosition = Exclude<`${Horizontal}-${Vertical}`, 'center-center'> | 'center';

Select all that apply.

1–4 to choose, Enter to submit
Show answer & explanation

Correct answers:

  • 'left-top'
  • 'center'
  • A template literal type over two unions produces the cross product (3 × 3 = 9 strings), Exclude drops 'center-center', and | 'center' adds the shorthand, so 'left-top' and 'center' are allowed.
  • Not 'top-left': the pattern is horizontal first, and template literal types are ordered.
  • Not 'center-center': Exclude removed it.