Type alias Equals<X, Y>

Equals<X, Y>: (<T>() => T extends X
        ? true
        : false) extends (<T>() => T extends Y
        ? true
        : false)
    ? true
    : false

Conditional type that checks if two types X and Y are exactly equal. If X is equal to Y, the type resolves to true; otherwise false.

Type Parameters

  • X
  • Y

Example

type Result1 = Equals<string, string>; // is true
type Result2 = Equals<number, string>; // is false
type Result3 = Equals<boolean | string, string | boolean>; // is true