I am currently discovering TypeScript. I use the following code:
const someClass = document.querySelector(".that-class");
const someId = document.getElementById("elemId").value;
As many others before me and surely many more to come I am getting the following errors:
Property 'style' does not exist on type 'Element'.
Property 'value' does not exist on type 'HTMLElement'.
I fixed these errors in my .ts file by adding <HTMLElement>
or <HTMLInputElement>
when needed, works fine. But when I compile my .ts I get some TS warnings from VSCode in the .js file.
My question is simply: is there a way to avoid getting these errors in the JS file as well (i.e.: is there a "cleaner" way to write JavaScript code)? Or should I simply ignore these TS warnings?
Thanks very much for your help!