Consider the following interface in TypeScript's lib.d.ts
:
interface HTMLElement extends Element {
accessKey: string;
readonly children: HTMLCollection;
contentEditable: string;
readonly dataset: DOMStringMap;
dir: string;
draggable: boolean;
// ... many more
}
How would I pick only the properties out of this interface that are not readonly
, without having to manually identify and input them all (as illustrated below)?
type WriteableHTMLElProps = Pick<HTMLElement, "accessKey"|"contentEditable" /* ... */>
Note: a proper solution should also handle the non-readonly
properties of the interfaces that this one extends.