TypeScript Version: 2.4.1
Code
<body>
<dialog id="modal">
<p>Hello Modal!</p>
</dialog>
<script>
const modal = document.getElementById("modal") as HTMLDialogElement; // Error
modal.showModal();
</script>
</body>
Expected behavior:
Understand what a dialog element is
Actual behavior:
[ts] Cannot find name 'HTMLDialogElement'.
Generally TypeScript does not include the experimental technologies that aren't widely adopted tend not to be added to TypeScript. This helps developers to not accidentally create code that is broken on most browsers. Developers who _know_ they are only going to be running on Chrome, can of course add these types to their environment themselves.
Dialog is a Living Standard and the readme for TSJS-lib-generator says:
"WhatWG
A "Working Draft" should go on DefinitelyTyped. A "Living Standard" should be added here."
No. TypeScript does not cover everything in the standard until it is widely adopted.
Is that recorded somewhere? The only thing I've found is the readme saying "Living Standard" is the baseline.
Dialog is a Living Standard and the readme for TSJS-lib-generator says:
"WhatWG
A "Working Draft" should go on DefinitelyTyped. A "Living Standard" should be added here."
The process of including a definition on DT in the default library is painful. it involves errors to all users of the DT definition file, and a cascade of issues in depending packages.
we have been more open to accepting definitions into the standard library to avoid that pain in the future.
@mhegazy @kitsonk Is there a way to add support for properties like this using .tsconfig? I'm running into this exact same error, and can't figure anything out. I'm using the polyfill that Google has provided, so support isn't an issue for me.
@jhpratt I'm a beginner so I could be wrong but I think your two options are waiting for Typescript 2.6 or writing your own definition in the short term https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html
@terrylewis60 What's your problem? This is absolutely unacceptable behavior period, let alone in the open source community.
@arjunyel Thanks! I'll check that out.
I think someone doesn't understand being subscribed to a thread via e-mail in GitHub and thinks we are intentionally sending them e-mails. Someone needs to learn how to use a computer.
@jhpratt as mentioned, an interface file with something that introduced what you are looking for. The state of this issue though now indicates that the typings are now in master and will be available in TypeScript at the next release.
Most helpful comment
@terrylewis60 What's your problem? This is absolutely unacceptable behavior period, let alone in the open source community.
@arjunyel Thanks! I'll check that out.