There are two text inputs: (jade syntax)

input#x.game__input.game__input_text(type='text', value='X') input#y.game__input.game__input_text(type='text', value='Y') 

There are js receiving their value:

 let x = Math.floor(Math.abs(document.querySelector('#x').value)); let y = Math.floor(Math.abs(document.querySelector('#y').value)); 

Why the typescript interpreter complains about the value value:

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

Thank!

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

document.querySelector Typescript document.querySelector returns an object with an Element interface. In turn, this interface does not have such a property as value . To avoid this, you must first return the value to an HTMLInputElement , which has a value .