I'm feeling a bit unsure about whether my query pertains to WebStorm, Angular2, or Typescript.
Currently, I have an Angular2 build set up and I am using WebStorm 2016.1.2 for editing purposes. In one of my components, I obtain a reference to a DOM element by simply using
document.getElementById('some-el');
and then pass this to a service method:
calc(el:HTMLElement){
this.height = el.offsetHeight;
this.width = el.offsetWidth;
let span:HTMLElement = el.querySelector("span");
this.pos = span.offsetTop - span.offsetHeight;
}
Everything seems to be working fine as no errors appear in the browser, but I do encounter an error in WebStorm related to el.querySelector("span");
The error message states: Initializer type Element is not assignable to variable type HTMLElement
I am unsure if this issue lies with WebStorm or if it stems from me inaccurately typing the elements. When I change the type of span
to Element
, the error disappears but then offsetTop
and offsetHeight
are highlighted as incorrect. Quite perplexing.
Although my actual project seems unaffected when I run it, I can't help but wonder if this is something within my code that needs correcting or just an editor-related hiccup that can be disregarded?
Thank you for your assistance!