Typescript: DomTokenList has no method "forEach"

Created on 26 Jul 2018  路  2Comments  路  Source: microsoft/TypeScript

TypeScript Version: 3.1.0-dev.20180726
Search Terms: DomTokenList forEach classList

Code

const body:HTMLElement = document.body;

body.classList.forEach((attr)=>{
    /* Some code */
);

Expected behavior:
File just Compiles wwithout generating an error according to https://developer.mozilla.org/de/docs/Web/API/DOMTokenList/forEach
Actual behavior:

client/main.ts:24:20 - error TS2339: Property 'forEach' does not exist on type 'DOMTokenList'.

24                      body.classList.forEach((attr)=>{
                                       ~~~~~~~

Playground Link:
https://www.typescriptlang.org/play/#src=.....

The file from where VS Code loads the DOMTokenList is: /usr/share/code/resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts

Bug lib.d.ts Fixed

Most helpful comment

All 2 comments

Also it needs to be added: supports, entries, keys, values
https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OliverJAsh picture OliverJAsh  路  242Comments

nitzantomer picture nitzantomer  路  135Comments

disshishkov picture disshishkov  路  224Comments

quantuminformation picture quantuminformation  路  273Comments

xealot picture xealot  路  150Comments