TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Missing .data member on Node in lib.d.ts

Open pocesar opened this issue 11 years ago • 2 comments

HTML nodeType 8 (Comment) have a .data attribute that hold they content. It's missing from the Node declaration in lib.d.ts, currently there's no workaround if you have --noImplicitAny turned on, having to rely on var node:any; instead of var node:Node;. Using node['data'] gives the error TS7017:Index signature of object type implicitly has an 'any' type.

pocesar avatar Dec 06 '14 21:12 pocesar

The .data property is actually part of the CharacterData interface, not of Node. Declare the variable as Comment, or use the .nodeValue property instead.

jeffreymorlan avatar Dec 07 '14 17:12 jeffreymorlan

Confirmed @jeffreymorlan's comment - see https://dom.spec.whatwg.org/#interface-characterdata

RyanCavanaugh avatar Dec 17 '14 19:12 RyanCavanaugh