Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript HTMLElement disabled 1.4 to 1.6 what happened (TS2339)?

I have been working on a TypeScript project using Visual Studio 2013 and the 1.4 version of the TS language. Just now I've upgraded the Visual Studio 2015, which uses TS 1.6.

I have code that uses the "disabled" property of an HTMLElement: var e: HTMLElement = ... e.disabled = true;

VS 2015/TS 1.6 now gives me error Code TS2339: "Property 'disabled' does not exist on type 'HTMLElement'.

Whoa! 'disabled' is a DOM property, and it used to do something in my code, and now it's no longer defined? Where did it go, and how do I deal?

I've carefully read the 'What's New' notes on the TS release from 1.4 to 1.6 but it has nothing to say on this matter.

like image 958
mszinger Avatar asked Sep 22 '15 12:09

mszinger


2 Answers

The HTMLElement interface does not contain the disabled property, as it is not a property which has a meaning for all HTML elements. However, it's children HTMLInputElement, HTMLButtonElement etc. does, because the disabled property makes sense with them.

With this in mind, you should be able to correct your code with little trouble.

like image 60
meskobalazs Avatar answered Nov 24 '22 00:11

meskobalazs


Corresponding to MDN topics, class HTMLElement does not have property such as disabled. That is why Typescript developers team correct this Web API object

like image 43
Oleh Dokuka Avatar answered Nov 23 '22 22:11

Oleh Dokuka