ts-type-forge
    Preparing search index...

    Type Alias IsAny<T>

    IsAny: 0 extends 1 & T ? true : false

    Checks if a given type T is exactly the any type.

    It uses the 0 extends 1 & T trick: 1 & T collapses to a type that 0 extends only when T is any (for any other type, 1 & T is 1, a subtype of 1, or never). This avoids conditional type distribution and does not require writing any in the implementation.

    Type Parameters

    • T

      The type to check.

    true if T is any, false otherwise.

    type T1 = IsAny<any>; // true
    type T2 = IsAny<unknown>; // false
    type T3 = IsAny<never>; // false
    type T4 = IsAny<string>; // false
    type T5 = IsAny<string | any>; // true (`any` absorbs the union)