devtypes - v2.0.0
    Preparing search index...

    Type Alias OptionalKeys<T>

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

    Extract the keys of optional properties.

    Type Parameters

    • T

      Object type to analyze

    Identifies properties that are optional in the object type, including properties whose value type explicitly allows undefined.

    type Obj = { a: number; b?: string; c: number | undefined; d: boolean };
    type OptKeys = OptionalKeys< Obj >; // 'b' | 'c'