devtypes - v1.1.0
    Preparing search index...

    Type Alias IsLiteral<T>

    IsLiteral: IsAny<T> extends true
        ? false
        : string extends T
            ? false
            : number extends T ? false : boolean extends T ? false : true

    Test whether a type is a literal type.

    Type Parameters

    • T

      Type to test

    Distinguishes string, number, and boolean literals from their corresponding primitive base types. The any type always resolves to false to avoid false positives.

    type A = IsLiteral< 'hello' >;  // true
    type B = IsLiteral< 42 >; // true
    type C = IsLiteral< true >; // true
    type D = IsLiteral< string >; // false