Type alias RemoveNeverKeys<T>

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

this utility type removes all property keys that are of the never type.

Type Parameters

  • T

Example

type MyType = { a: number, b: never, c: never, d: { e: never, f: string } }
type MyType_Cleansed = RemoveNeverKeys<MyType>
// type MyType_Cleansed === { a: number, d: { e: never, f: string } }

Generated using TypeDoc