devtypes - v1.1.0
    Preparing search index...

    Type Alias Narrow<T>

    Narrow: T extends string
        ? string extends T ? T : T
        : T extends number ? number extends T ? T : T : T

    Narrow a type without widening literals.

    Type Parameters

    • T

      Type to narrow

    Preserves literal types while leaving their corresponding base types unchanged. Primarily useful as a semantic marker in public APIs.

    type A = Narrow< 'hello' >; // 'hello'
    type B = Narrow< string >; // string