Skip to content
webtype.orgwebtype.org

    ↑↓ move · ⏎ open · esc close

    Unions

    Exclude

    Removes from a union every member assignable to U.

    What it is

    A distributive conditional type, and the clearest example of what distribution is for. T is a bare type parameter on the left of extends, so the conditional runs once per union member and the results are unioned back — members that match become never and vanish, because never in a union is nothing at all.

    Examples

    • Exclude<'a' | 'b' | 'c', 'b'>
      →"a" | "c"
    • Exclude<string | number | null, null>
      →string | number
    • Exclude<'a' | 'b', 'a' | 'b'>
      →never

      Excluding everything leaves never, which is the correct name for the empty union.

    Each resolved type above was printed by TypeScript 6.0.3, not written by hand.

    What it does not do

    • It does not remove properties from an object. Exclude works on unions; the object equivalent is Omit.
    • It does not require an exact match. Any member *assignable* to U goes, so Exclude<string | "a", string> removes both.

    Takeaway

    If Exclude seems to do nothing, the left side is probably not a union — distribution needs members to distribute over.