Typescript unresolved variable classList

Windows 7 x64
Phpstorm 9 EAP build 141.1619 x64

I am getting unresolved variable error in the editor for classList in a typescript file
Code the causes error:

 
myfunc() {
    document.getElementsByClassName('left-aside-wrapper')[0].classList.toggle('isOpen');
}


1) Is there a place in the settings where we can override this errror for typescript or add it to an excluded list?
2)What does the editor validate against for typescript errors? For example javascript uses jslint or jshint for editor errors, correct?

From looking at the typescript folder lib.d.ts classList is defined but I am also getting a similar error when I compile. So maybe it is a problem with the lib.d.ts file.  

error TS2339: Property 'classList' does not exist on type 'Node'.

0
4 comments

In TypeScript 1.5

getElementsByClassName
is defined to return
Node
array, and Node indeed doesn't have 'classList'   - thus the error. See https://github.com/Microsoft/TypeScript/issues/3613.

What does the editor validate against for typescript errors?



It uses its own TypeScript parser. But if either TypeScript compiler or TypeScript file watcher is set up, PHPStorm own error highlighting is suppressed and errors coming from TypeScript compiler are shown instead

For example javascript uses jslint or jshint for editor errors, correct?


No, not correct. JSLint/JSHint/other standard linters are used in addition to PHPStorm own inspections (based on proprietary JavaScript parser) if linters are configured in Settings/Languages & Frameworks/JavaScript/Code Quality Tools

0

Ok, thank you for the info very helpful.

So since it looks like it is defined incorrectly in Typescript(as the code is valid and should not be thowing an error without having to cast it to another type, which is not pratical), is there a way for now to override this error and add it to exception list. Example in Editor/Inspections/Css/Invalid Elements there is an unkown element option that you can manually add unkown elements to in order to fix false validation errors, is there something like this for Typescript?

0

Errors that come from TypeScript compiler can't be suppressed. I can only suggest turning the compiler off to avoid seeing them

0

Ok, thanks again, you have been very helpful.  Hope you have a nice day!

0

Please sign in to leave a comment.