I wanted to use HTMLDialogElement in a typescript project in VS Code.
But when using this class, it first shows a deprecation "this is not available in most browsers". However when looking at MDN browser compatibility, it looks commonly spread, and I don't really care to make it work on IE.
But then when trying to use the common dialog functions (show()
, showModal()
, close()
), they are simply not available for autocomplete, and thus shows error. After looking at my lib.dom.d.ts, the HTMLDialogElement definition looks like this :
/** @deprecated this is not available in most browsers */
interface HTMLDialogElement extends HTMLElement {
addEventListener<K extends keyof HTMLElementEventMap>((...) => ...): void;
addEventListener(...): void;
removeEventListener<K extends keyof HTMLElementEventMap>(...): void;
removeEventListener(...): void;
}
So as expected, no definition for show()
, showModal()
and close()
.
However the last comment from this github issue shows that the methods I mentionned above are present in Typescript.
Is there a way to update the lib.dom.d.ts file used by VS Code, or the problem is elsewhere?