I get an error from Typescript and I'm not sure how to fix it. The code works fine when "compiled", but I canโt fix the error. I extracted parts that are related to my code error. I suppose I need to predict src, but don't know how to do it.
Error msg in Editor and Gulp compile:
"Property 'src' does not exist in type 'HTMLElement'.at line 53 col 17"
... element:HTMLElement; /* Defining element */ ''' this.element = document.createElement('img'); /*creating a img*/ '''
This is the method that I run to visualize the element, position, top and left all work with an error.
display() { this.element.src = this.file; this.element.style.position = "absolute"; this.element.style.top = this.pointX.toString() + "px"; this.element.style.left = this.pointY.toString() + "px"; document.body.appendChild(this.element); };
javascript typescript
Bjรถrn hjorth
source share