Type alias RequiredKeys<T>

RequiredKeys<T>: {
    [K in Keys<T>]-?: IfExtends<EmptyObject, Pick<T, K>, never, K>
}[Keys<T>]

Extracts keys from a type T that represent required properties. Properties that are not marked with ?.

Type Parameters

  • T

Example

type T = RequiredKeys<{ a: number; b?: string }> // Result:  'a'