Typescript compile error: Property 'classList' does not exist on type 'Node'

Windows 7 x64

Compiling using gulp-typescript 2.7.7 using typescript 1.5 beta

Getting error: Property 'classList' does not exist on type 'Node' because of statement document.getElementsByClassName('left-aside-wrapper')[0].classList.toggle('isOpen');

I see that classList is defined in the lib.d.ts file as interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode { classList: DOMTokenList;

Not all that familiar with how d.ts files work so is this my error or is it a bug in the d.ts file that need to be reported?

Answers


This is becuase getElementsByClassName is defined to return Node array and not an Element array.

Not all that familiar with how d.ts files work so is this my error or is it a bug in the d.ts file that need to be reported

Based on https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName I would report it as an error.


Need Your Help

does flex use frames?

frames apache-flex

I'm looking into developing a game using the flex SDK instead of flash. I'm kind of not sure how to start.

Using PHP for a class to make files and directories

php filenames explode xls

I have built a class for use with creating files;