types-kit.if.md

September 4, 2023 ยท View on GitHub

Home > types-kit > If

If type

If for types.

Signature:

export type If<Condition, Case1, Case2> = IfExtends<
  [IsTruthy<Condition>, true],
  Case1,
  Case2
>

References: IfExtends, IsTruthy

Example

 // Expect: 1
 type Foo = If<true, 1, 2>

Contents

  1. 1If type
  2. 2Example