Title: JSDoc @type does not attach to for loop variable declarations · Issue #43756 · microsoft/TypeScript · GitHub
Open Graph Title: JSDoc @type does not attach to for loop variable declarations · Issue #43756 · microsoft/TypeScript
X Title: JSDoc @type does not attach to for loop variable declarations · Issue #43756 · microsoft/TypeScript
Description: Bug Report From what I could tell, this is a common pattern with JSDoc used to properly document the type of a loop variable. It does not seem to work in VSCode. 🔎 Search Terms jsdoc for loop type 🕗 Version & Regression Information This ...
Open Graph Description: Bug Report From what I could tell, this is a common pattern with JSDoc used to properly document the type of a loop variable. It does not seem to work in VSCode. 🔎 Search Terms jsdoc for loop type ...
X Description: Bug Report From what I could tell, this is a common pattern with JSDoc used to properly document the type of a loop variable. It does not seem to work in VSCode. 🔎 Search Terms jsdoc for loop type ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/43756
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JSDoc @type does not attach to for loop variable declarations","articleBody":"# Bug Report\r\n\r\nFrom what I could tell, this is a common pattern with JSDoc used to properly document the type of a loop variable. It does not seem to work in VSCode.\r\n\r\n### 🔎 Search Terms\r\n\r\njsdoc for loop type\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSDoc.\r\n\r\n### ⏯ Playground Link\r\n\r\nhttps://www.typescriptlang.org/play?#code/GYewTgBAFA9AVHCABALgTwA4FMIG8ASAKgLIAyAogDZYC2WAdigL4RwwQDGI9AzihDhDAIAExAcArnUYA6AEYgRaGQEcJWMGgDKWahxTgAgpUpQA5DJRY+ZgJS28AKAguBMvmmoyRASx4ZKAEM0CABeCDN6biwzAG5HJiA\r\n\r\n### 💻 Code\r\n\r\n```js\r\nfor (/** @type {HTMLElement} */ const e of document.body.querySelectorAll('.test')) {\r\n e.style.display = 'none';\r\n}\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\n`e` is typed as Element\r\n\r\n### 🙂 Expected behavior\r\n\r\n`e` should be typed as HTMLElement, as I have overridden it via @type.\r\n\r\nAs an example, if I were to change the code to this:\r\n\r\n```js\r\n/** @type {HTMLElement} */ const e = document.body.querySelectorAll('.test');\r\n```\r\n\r\nVSCode correctly picks up that I'm wishing to override `e` as an HTMLElement (and complains about missing interface implementations, but, that's not the issue here - in fact that's expected!)\r\n","author":{"url":"https://github.com/Paril","@type":"Person","name":"Paril"},"datePublished":"2021-04-21T01:27:06Z","url":"https://github.com/microsoft/TypeScript/issues/43756"}
| 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:1dcc2844-6df9-e0d9-097d-64efa6f8931e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C0E:296654:9BB4D0:D257FF:6B00EA9F |
| html-safe-nonce | 5f68c6e8e3dd58927a3bb6d7811559fc96f5c22bbf87ec535559ecca991bb2eb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzBFOjI5NjY1NDo5QkI0RDA6RDI1N0ZGOjZCMDBFQTlGIiwidmlzaXRvcl9pZCI6IjIxNzkxNzg0NDY4NTU0MDAwOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fd3b7b931924aaad4d651a336c29b3f48562ca05c22eee5515dc5d690373efdd |
| hovercard-subject-tag | issue:863366877 |
| 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/43756/issue_layout |
| twitter:image | https://opengraph.githubassets.com/930e300c5c628ba54c5661aec8e9e5ed54f903c4943ed74401e2a01ad99c1136/microsoft/TypeScript/issues/43756 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/930e300c5c628ba54c5661aec8e9e5ed54f903c4943ed74401e2a01ad99c1136/microsoft/TypeScript/issues/43756 |
| og:image:alt | Bug Report From what I could tell, this is a common pattern with JSDoc used to properly document the type of a loop variable. It does not seem to work in VSCode. 🔎 Search Terms jsdoc for loop type ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Paril |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width