Answers for "Property 'state' does not exist on type 'HTMLScriptElement'."

2

Property 'state' does not exist on type

Can be multiple reasons. Main ones are missing @types/react in Dependencies

try typing this in the terminal (make sure it's the terminal of the right 
folder):

npm install --save-dev @types/react @types/react-dom

--------------------------------------------------------------------------------
Posted by: Guest on June-13-2020
2

Property 'on' does not exist on type 'HTMLElement'.

To prevent this error you can write:

var plotDiv: any = document.getElementById('myDiv');
plotDiv.on('plotly_relayout', ...
document.getElementById('myDiv') return HTMLElement. This type doesn't contain method
on because this method is added within plotly-latest.min.js. So in order to silence
the typescript warning you can explicity say compile not to check types for plotDiv

Another way is create type definition like:

interface PlotHTMLElement extends HTMLElement  {
  on(eventName: string, handler: Function): void;
}

var plotDiv  = <PlotHTMLElement>document.getElementById('myDiv')
plotDiv.on('plotly_relayout', function() {

});
Posted by: Guest on January-21-2021

Code answers related to "Property 'state' does not exist on type 'HTMLScriptElement'."

Code answers related to "TypeScript"

Browse Popular Code Answers by Language