PokéRogue
    Preparing search index...

    Type Alias ExcludeExactly<Union, Delete>

    ExcludeExactly: IfNotAnyOrNever<
        Union,
        _ExcludeExactly<Union, Delete>,
        If<IsAny<Delete>, never, Union>,
        If<IsNever<Delete>, never, Union>,
    >

    A stricter version of Exclude<T, U> that excludes types only when they are exactly identical.

    Type Parameters

    • Union
    • Delete
    import type {ExcludeExactly} from 'type-fest';

    type TestExclude1 = Exclude<'a' | 'b' | 'c' | 1 | 2 | 3, string>;
    //=> 1 | 2 | 3

    type TestExcludeExactly1 = ExcludeExactly<'a' | 'b' | 'c' | 1 | 2 | 3, string>;
    //=> 'a' | 'b' | 'c' | 1 | 2 | 3

    type TestExclude2 = Exclude<'a' | 'b' | 'c' | 1 | 2 | 3, any>;
    //=> never

    type TestExcludeExactly2 = ExcludeExactly<'a' | 'b' | 'c' | 1 | 2 | 3, any>;
    //=> 'a' | 'b' | 'c' | 1 | 2 | 3

    type TestExclude3 = Exclude<{a: string} | {a: string; b: string}, {a: string}>;
    //=> never

    type TestExcludeExactly3 = ExcludeExactly<{a: string} | {a: string; b: string}, {a: string}>;
    //=> {a: string; b: string}