Title: In JS, `@template` types on constructor functions do not resolve in prototype methods · Issue #26826 · microsoft/TypeScript · GitHub
Open Graph Title: In JS, `@template` types on constructor functions do not resolve in prototype methods · Issue #26826 · microsoft/TypeScript
X Title: In JS, `@template` types on constructor functions do not resolve in prototype methods · Issue #26826 · microsoft/TypeScript
Description: var Multimap = function() { /** @type {!Map.
Open Graph Description: var Multimap = function() { /** @type {!Map.
X Description: var Multimap = function() { /** @type {!Map.<K, !Set.<!V>>} */ this._map = new Map(); }; /** * @param {K} key the key ok * @returns {Set<V>} the value ok */ Multimap.prototype.get...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/26826
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"In JS, `@template` types on constructor functions do not resolve in prototype methods","articleBody":"```js\r\nvar Multimap = function() {\r\n /** @type {!Map.\u003cK, !Set.\u003c!V>>} */\r\n this._map = new Map();\r\n};\r\n\r\n/**\r\n * @param {K} key the key ok\r\n * @returns {Set\u003cV>} the value ok\r\n */\r\nMultimap.prototype.get = function (key) {\r\n return this._map.get(key) || new Set();\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nNo errors, and `Multimap\u003cK,V>.get: (key: K) => Set\u003cV>`\r\n\r\n**Actual behavior:**\r\nK and V in `@param {K}` and `@returns {Set\u003cV>}` are not found and `get: (key: any) => any`.\r\n\r\nWorks fine if Multimap is declared as `function Multimap ...`.\r\n\r\nShould work with prototype assignments too, eg `Multimap.prototype = { get() { ... } }`. Discovered while fixing #24230","author":{"url":"https://github.com/sandersn","@type":"Person","name":"sandersn"},"datePublished":"2018-08-31T21:01:03Z","url":"https://github.com/microsoft/TypeScript/issues/26826"}
| 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:7a2a5de5-e3d7-5e2a-5b5b-008488c2f432 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB92:FD77C:26DFF4:33AA3D:6B04B5A0 |
| html-safe-nonce | ef0f8688b2e761fb6a6a521424e15448c692f9475b4467709d6672118b16091a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjkyOkZENzdDOjI2REZGNDozM0FBM0Q6NkIwNEI1QTAiLCJ2aXNpdG9yX2lkIjoiNjkzNzU4NjgwMTU4Njc3OTU1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b805fc3020e4c3b2cc7fa2aafeb327b79946bfa1c03c0b930f36bf1d4fcfc6bf |
| hovercard-subject-tag | issue:356122490 |
| 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/26826/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1a460f64a96fee2b81f388141e63c82081f8211367ce5314c94c1d5324af2d4/microsoft/TypeScript/issues/26826 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1a460f64a96fee2b81f388141e63c82081f8211367ce5314c94c1d5324af2d4/microsoft/TypeScript/issues/26826 |
| og:image:alt | 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 | 378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7 |
| 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 | b032e77f1ea437ede6c115446a0a467709b468e7 |
| 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