Title: Generic types from JSDoc aren't really generic · Issue #26883 · microsoft/TypeScript · GitHub
Open Graph Title: Generic types from JSDoc aren't really generic · Issue #26883 · microsoft/TypeScript
X Title: Generic types from JSDoc aren't really generic · Issue #26883 · microsoft/TypeScript
Description: /** * @constructor * @template {string} K * @template V */ function Multimap() { /** @type {Object
Open Graph Description: /** * @constructor * @template {string} K * @template V */ function Multimap() { /** @type {Object
X Description: /** * @constructor * @template {string} K * @template V */ function Multimap() { /** @type {Object<string, V>} TODO: Remove the prototype from the fresh object */ this._map = {}; }; var Ns = ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/26883
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic types from JSDoc aren't really generic","articleBody":"```js\r\n/**\r\n * @constructor\r\n * @template {string} K\r\n * @template V\r\n */\r\nfunction Multimap() {\r\n /** @type {Object\u003cstring, V>} TODO: Remove the prototype from the fresh object */\r\n this._map = {};\r\n};\r\n\r\nvar Ns = {}\r\n/** @type {Multimap\u003c\"a\" | \"b\", number>} */\r\nconst map = new Multimap();\r\nconst n = map._map['hi']\r\n```\r\n\r\n**Expected behavior:**\r\n`n: number`\r\n\r\n**Actual behavior:**\r\n`n: any` in 3.0; `n: V` in 3.1-dev.\r\n\r\nTypes resolved from functions are never properly generic, even that function has `@template`-specified type parameters; they're only special-cased in a few places to produce a specific instantiation of a type. They should use the normal generic type machinery that Typescript does.","author":{"url":"https://github.com/sandersn","@type":"Person","name":"sandersn"},"datePublished":"2018-09-04T20:41:48Z","url":"https://github.com/microsoft/TypeScript/issues/26883"}
| 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:3d39c01d-b2cd-bbb6-ceac-dd6291606888 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A50:311640:2721F1D:31BB008:6B0199EC |
| html-safe-nonce | d94797bb4eeea17f3a3f0b9b2f7fea676ed266f43048714409b89036fd1844c2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTUwOjMxMTY0MDoyNzIxRjFEOjMxQkIwMDg6NkIwMTk5RUMiLCJ2aXNpdG9yX2lkIjoiNTI0OTgyNzQ3MjE3Mzc5OTkxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | aec1304d6b32bcbd32164fbfd2cea4910ee3165f6ac1b6b9b19d9bf17bb73107 |
| hovercard-subject-tag | issue:356968369 |
| 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/26883/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e150000b052fc2187a2f0a5df66f72a69dbc839a877c2436c8c2c73431e9a1f6/microsoft/TypeScript/issues/26883 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e150000b052fc2187a2f0a5df66f72a69dbc839a877c2436c8c2c73431e9a1f6/microsoft/TypeScript/issues/26883 |
| og:image:alt | /** * @constructor * @template {string} K * @template V */ function Multimap() { /** @type {Object |
| 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 | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width