Title: JSDoc `@template` type parameters aren't resolved on prototype assignments · Issue #24230 · microsoft/TypeScript · GitHub
Open Graph Title: JSDoc `@template` type parameters aren't resolved on prototype assignments · Issue #24230 · microsoft/TypeScript
X Title: JSDoc `@template` type parameters aren't resolved on prototype assignments · Issue #24230 · microsoft/TypeScript
Description: /** * @constructor * @template K, V */ var Multimap = function() { /** @type {!Map.
Open Graph Description: /** * @constructor * @template K, V */ var Multimap = function() { /** @type {!Map.
X Description: /** * @constructor * @template K, V */ var Multimap = function() { /** @type {!Map.<K, !Set.<!V>>} */ this._map = new Map(); }; Multimap.prototype = { /** * @param {K} key // <------...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/24230
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JSDoc `@template` type parameters aren't resolved on prototype assignments","articleBody":"```js\r\n/**\r\n * @constructor\r\n * @template K, V\r\n */\r\nvar Multimap = function() {\r\n /** @type {!Map.\u003cK, !Set.\u003c!V>>} */\r\n this._map = new Map();\r\n};\r\n\r\nMultimap.prototype = {\r\n /**\r\n * @param {K} key // \u003c------ error here, 'K' not found\r\n * @param {V} value // \u003c---- and here\r\n */\r\n set: function(key, value) {\r\n var set = this._map.get(key);\r\n if (!set) {\r\n set = new Set();\r\n this._map.set(key, set);\r\n }\r\n set.add(value);\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n`K` and `V` are resolved to the declaration on `var Multimap = function ...`.\r\n\r\n**Actual behavior:**\r\nCannot find name 'K'. and Cannot find name 'V'.\r\n\r\nThe js-specific code in resolveEntityName needs to understand prototype assignment the same way that it does prototype *property* assignment. This works fine:\r\n\r\n```js\r\n/**\r\n * @param {K} key // \u003c------ error here, 'K' not found\r\n * @param {V} value // \u003c---- and here\r\n */\r\nMultimap.prototype.set = function {\r\n}\r\n```","author":{"url":"https://github.com/sandersn","@type":"Person","name":"sandersn"},"datePublished":"2018-05-17T22:40:31Z","url":"https://github.com/microsoft/TypeScript/issues/24230"}
| 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:f711e9a0-1e3a-849d-ef4b-b8e6f0a5f3ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D678:29272F:352200:490BBE:6B046BA8 |
| html-safe-nonce | e6d13f771b28f49a705484b6af3d9d2a6d2df00263d5c661da7924a8ac51c426 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjc4OjI5MjcyRjozNTIyMDA6NDkwQkJFOjZCMDQ2QkE4IiwidmlzaXRvcl9pZCI6IjQ3MzMzMDA1MTg4ODAwNDU5OTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 73e983674699df7e0774dd3039e99d9001b3e53d544f0da652d2e659ca4de29b |
| hovercard-subject-tag | issue:324210556 |
| 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/24230/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4779a9979479453c780adb65212921da85221555576aaf19bccbc728a3bf069b/microsoft/TypeScript/issues/24230 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4779a9979479453c780adb65212921da85221555576aaf19bccbc728a3bf069b/microsoft/TypeScript/issues/24230 |
| og:image:alt | /** * @constructor * @template K, V */ var Multimap = function() { /** @type {!Map. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sandersn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| 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 | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width