TypeScript: Errors

By Xah Lee. Date: . Last updated: .

Error ts2339: property 'style' does not exist on type 'element'.

error TS2339: Property 'style' does not exist on type 'Element'.

const x = document.querySelector("span.x42663").style;

change the above to

const x = (document.querySelector("span.x42663") as HTMLElement).style;

// or

const x = (<HTMLElement> document.querySelector("span.x42663")).style;

Error ts2339: property 'value' does not exist on type 'htmlelement'

error TS2339: Property 'value' does not exist on type 'HTMLElement'.

solution.

change the line

document.getElementById("user_input_24066").value

to

(document.getElementById("user_input_24066") as HTMLInputElement).value

// or

(<HTMLInputElement> document.getElementById("user_input_24066")).value