Type alias Extends<T, U>

Extends<T, U>: T extends never
    ? false
    : T extends U
        ? true
        : false

Evaluates whether one type T is assignable to another type U.

Type Parameters

  • T
  • U

Returns

true if T is assignable to U, false otherwise.

Example

type A = { x: number };
type B = { x: number; y: string };
type C = { x: number; y?: string };

type Check1 = Extends<A, B>; // false, A does not extend B
type Check2 = Extends<B, A>; // true, B extends A
type Check3 = Extends<C, B>; // true, C extends B