webshrine / stdtyp/src / OptionalKeys
Type Alias: OptionalKeys<T>
OptionalKeys<
T
>:{ [K in keyof T]-?: {} extends Pick<T, K> ? K : never }
[keyofT
]
OptionalKeys
Type Parameters
• T
Desc
Get union type of keys that are optional in object type T
See
Example
ts
type Props = { req: number; reqUndef: number | undefined; opt?: string; optUndef?: number | undefined; };
// Expect: "opt" | "optUndef"
type Keys = OptionalKeys<Props>;
Defined in
node_modules/.pnpm/utility-types@3.11.0/node_modules/utility-types/dist/mapped-types.d.ts:144