@mocanvas/editor · type
type OptionalKeys<T> = {
[K in keyof T]-?: object extends Pick<T, K> ? K : never;
}[keyof T]The keys of T that may be omitted.
The two halves of an options bag, at the type level: pair this with RequiredKeys to split one interface into "what a caller must supply" and "what has a default", which is how an options type and its defaults object are kept in step without restating either.
Mentioned here
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.