Type alias NeverKeys<T>

NeverKeys<T>: {
    [K in keyof T]: T[K] extends never
        ? K
        : never
}[keyof T]

this utility type returns a union of all the keys that have been assigned as never.

Type Parameters

  • T

Example

type MyType = { a: number, b: never, c: never, d: { e: never, f: string } }
type AllofMyNeverKeys = NeverKeys<MyType>
// type AllofMyNeverKeys === ("b" | "c")

Generated using TypeDoc