kysely
    Preparing search index...

    Type Alias DrainOuterGeneric<T>

    DrainOuterGeneric: [T] extends [unknown] ? T : never

    Utility to reduce depth of TypeScript's internal type instantiation stack.

    Example:

    type A<T> = { item: T }

    type Test<T> = A<
    A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<T>>>>>>>>>>>>>>>>>>>>>>>>
    >

    // type Error = Test<number> // Type instantiation is excessively deep and possibly infinite.ts (2589)

    To fix this, we can use DrainOuterGeneric:

    type A<T> = DrainOuterGeneric<{ item: T }>

    type Test<T> = A<
    A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<T>>>>>>>>>>>>>>>>>>>>>>>>
    >

    type Ok = Test<number> // Ok

    Type Parameters

    • T