-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't iterate over DOM elements even with dom.iterable #15236
Comments
PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes. |
Documentation for NodeList.forEach can be found at https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach |
@mhegazy Uhm, But I am not sure if there even is a problem. From what I understand the interfaces exists but maybe you have to import them somehow. I was just trying to figure out what I'm doing wrong. |
|
Fixed by #14641 |
@mhegazy Yeah I know it's been fixed and they exist, I write so in my previous comment. I am just wondering on how to use them? Since they don't actually work out of the box. What do I need to import? |
c:\test>type b.ts
const myNodeListOfBrs = document.querySelectorAll("br")
myNodeListOfBrs.forEach(element => {
console.log(element);
})
c:\test>tsc --v
Version 2.3.0-dev.20170419
c:\test>tsc --lib dom.iterable,es6 C:\test\b.ts |
@mhegazy Thanks, I'll give it a try. It should be available on 2.2.0 as well. |
that is a 2.3 change. |
@mhegazy I'm running tsc 2.3.2 and it fails on the exact example given above. |
make sure your "lib": [
"dom", "es6", "dom.iterable"
] |
If I recall correctly, not all browser put a |
I might have missed something here. Feel free to close this ticket if it's related to #4947
TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)
Code
tsconfig.json
Expected behavior:
It should compile
Actual behavior:
It does not compile with error:
property 'forEach' does not exist on type 'NodeListOf<HTMLBRElement>
The text was updated successfully, but these errors were encountered: