type RequiredKeys<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K }[keyof T]; type OptionalKeys<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? K : never }[keyof T]; type PickRequired<T> = Pick<T, RequiredKeys<T>>; type PickOptional<T> = Pick<T, OptionalKeys<T>>; type Nullable<T> = { [P in keyof T]: T[P] | null }; type NullableOptional<T> = PickRequired<T> & Nullable<PickOptional<T>>;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter