Type alias OptionalKeys<T>

OptionalKeys<T>: {
    [K in keyof T]-?: {} extends {
            [P in K]: T[K]
        }
        ? K
        : never
}[keyof T]

找出optional属性

Type Parameters

  • T

Example

type T = OptionalKeys<{ a: string; b?: number; c: boolean }>; // 'b'