ts-type-forge
    Preparing search index...

    Type Alias StrictExtract<T, U>

    StrictExtract: T extends U ? T : never

    Extracts from union type T those types that are assignable to U. This is a stricter version of the built-in Extract that requires U to extend T.

    Type Parameters

    • T

      The union type to extract from.

    • U extends T

      The type to extract, must extend T.

    The intersection of T and U.

    type Union = 'a' | 'b' | 'c';
    type Extracted = StrictExtract<Union, 'a' | 'b'>; // 'a' | 'b'
    // type Invalid = StrictExtract<Union, 'a' | 'd'>; // Error: 'd' is not assignable to Union