I am dealing with an Angular2 application. Unfortunately, I have had to resort to using the following code within a component method (I know it's not ideal, but...):
let confirmWindowDOM = document.getElementsByClassName('modal')[0];
confirmWindowDOM.style['z-index'] = "2049";
This code triggers an error that shows up in the console:
(program):75 ./some/path/to/component.component.ts
(103,28): error TS2339: Property 'style' does not exist on type 'Element'.
Despite the error, the application still functions as expected.
Now, I have a couple of questions:
- Although this is valid JavaScript syntax, TypeScript, being a superset of JavaScript, should not have any issues with it. However, even after modifying the code slightly to
, the error persists and tests fail. Why is this happening?document.getElementsByClassName('modal')[0].style['z-index'] = "1051";
- Is there a way to suppress or fix this error in TypeScript?