Type alias Exclude<T, U, R>

Exclude<T, U, R>: T extends U
    ? R
    : T

🌪️ filter

Exclude from T those types that are assignable to U, and replace them with R.

This can be used as a drop-in replacement of the build-in Exclude.

Type Parameters

  • T

  • U

  • R = never

Example

type R = Exclude<undefined, undefined> // never
type R = Exclude<undefined | 1, undefined> // 1

type R = Exclude<undefined, undefined, 2> // 2
type R = Exclude<undefined | 1, undefined, 2> // 1 | 2

Generated using TypeDoc