Title: Allow NodeList in for-of loop ES5 mode · Issue #4947 · microsoft/TypeScript · GitHub
Open Graph Title: Allow NodeList in for-of loop ES5 mode · Issue #4947 · microsoft/TypeScript
X Title: Allow NodeList in for-of loop ES5 mode · Issue #4947 · microsoft/TypeScript
Description: NodeList interface 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...
Open Graph Description: NodeList interface 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...
X Description: NodeList interface 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...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/4947
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow NodeList in for-of loop ES5 mode","articleBody":"`NodeList` interface 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.\n### Suggestion\n\nIntroduce a ES5-compatible way to declare iterable interfaces (Similar to what discussed in #2862)\n\n``` typescript\n// WebIDL-like way\ninterface NodeList {\n iterable\u003cNode>\n}\n\n// extends-like way\ninterface NodeList iterable\u003cNode> {}\n```\n\n`iterable\u003cT>` in ES6 mode will work as a shorthand of `[Symbol.iterator](): IterableIterator\u003cT>` but in ES5 mode will just make an internal flag to be allowed in for-of loop.\n\n``` typescript\n// NodeList is marked as iterable,\n// it has .length property and index signature for ES5 emit, so all good\nfor (let node of document.querySelectorAll(\"...\")) {\n}\n```\n\nThis will make it work both on ES5 and ES6 without changing emit.\n","author":{"url":"https://github.com/saschanaz","@type":"Person","name":"saschanaz"},"datePublished":"2015-09-24T06:04:19Z","url":"https://github.com/microsoft/TypeScript/issues/4947"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4ef0c5b7-be26-4c01-74ca-fad625d21d3b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A8B4:2F4BD9:84D02C:B1FBBB:6B00DD46 |
| html-safe-nonce | 281ed2404ba3f996ce4b0cf875663e604c14e964655f7b542efbdc0b99c68049 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEI0OjJGNEJEOTo4NEQwMkM6QjFGQkJCOjZCMDBERDQ2IiwidmlzaXRvcl9pZCI6IjU5NTM5NTgzNjA3MzM3NjkwMzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e1e215ea0f024c367f23d40ec63a7b5e325f02317590830c3f388846e2ebdfcb |
| hovercard-subject-tag | issue:108064144 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/4947/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5fc9d73374c7e7e74ebae951faaa84e508d23aff043c7ecce9da7ec5485175a0/microsoft/TypeScript/issues/4947 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5fc9d73374c7e7e74ebae951faaa84e508d23aff043c7ecce9da7ec5485175a0/microsoft/TypeScript/issues/4947 |
| og:image:alt | NodeList interface 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | saschanaz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width