-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow NodeList in for-of loop ES5 mode #4947
Copy link
Copy link
Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
NodeListinterface is defined as iterable in DOM4, but by design it cannot be directly used in for-of loop because we cannot declare it as iterable in ES5.Suggestion
Introduce a ES5-compatible way to declare iterable interfaces (Similar to what discussed in #2862)
iterable<T>in ES6 mode will work as a shorthand of[Symbol.iterator](): IterableIterator<T>but in ES5 mode will just make an internal flag to be allowed in for-of loop.This will make it work both on ES5 and ES6 without changing emit.