Skip to content

OptionalKeys

Extracts the optional keys of an object type T.

Available since v3.0.0

import type { OptionalKeys } from '@helpers4/type';
type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>
type User = { id: number; name: string; email?: string };
type Opts = OptionalKeys<User>; // 'email'

View source on GitHub