Title: Generic literal marker not obeyed for unknown and {} · Issue #32169 · microsoft/TypeScript · GitHub
Open Graph Title: Generic literal marker not obeyed for unknown and {} · Issue #32169 · microsoft/TypeScript
X Title: Generic literal marker not obeyed for unknown and {} · Issue #32169 · microsoft/TypeScript
Description: TypeScript Version: 3.4 up to 3.6-dev20190628 Search Terms: generic literal unknown Code This is expected: function f
Open Graph Description: TypeScript Version: 3.4 up to 3.6-dev20190628 Search Terms: generic literal unknown Code This is expected: function f
X Description: TypeScript Version: 3.4 up to 3.6-dev20190628 Search Terms: generic literal unknown Code This is expected: function f<T>(x: T): T { return x; } enum E { A, B } let x = f(E.A); // x has type E...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/32169
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic literal marker not obeyed for unknown and {}","articleBody":"**TypeScript Version:** 3.4 up to 3.6-dev20190628\r\n\r\n**Search Terms:**\r\ngeneric literal unknown\r\n\r\n**Code**\r\n\r\nThis is expected:\r\n\r\n```ts\r\nfunction f\u003cT>(x: T): T { return x; }\r\nenum E { A, B }\r\nlet x = f(E.A); // x has type E, not E.A\r\n```\r\n\r\nAccording to https://github.com/Microsoft/TypeScript/issues/24919#issuecomment-397009888 , you can get this to produce an E.A if you add an extends marker:\r\n\r\n```ts\r\nfunction f\u003cT extends {}|null|undefined>(x: T): T { return x; }\r\nenum E { A, B }\r\nlet x = f(E.A); // x now has type E.A\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nI'd expect the same literal inference if you write these forms too:\r\n\r\n```ts\r\nfunction f\u003cT extends unknown>(x: T): T { return x; }\r\nfunction f\u003cT extends {}>(x: T): T { return x; }\r\n```\r\n\r\n**Actual behavior:**\r\n\r\nIt has the other behavior, as if you have no `extends` clause\r\n\r\n\r\n**Playground Link:** \r\n\r\nhttp://www.typescriptlang.org/play/#code/FAUwdgrgtgBAojA3jAggGhgIRgX2MAMwjAGMAXASwHswYCBGAHgBUA+ACgA8AuGZgSl7MkMAE4gyEUbU4BuXMAA2EmJ3owAvHXrs4AOhT95MAPQnVMABYBDAM4wyATwAOIePiKlKNOgCYWMCCcZOAAJvaIOAA+kIqKUcShIAQUYCChHDx8gnwi4pLSqvJ4ymSqvpp+ugZGMKbmnFZ2Di5u+igexOTUtAQAzAFBIWDhMMQA1mBUAO5gmUI5wsj5UjLFSiqcfZX91YbGZhY29k6u8DAA-BcAhEA\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/evmar","@type":"Person","name":"evmar"},"datePublished":"2019-06-28T19:19:25Z","url":"https://github.com/microsoft/TypeScript/issues/32169"}
| 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:a52415ba-1691-7fe5-23b8-29351e6f3254 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D708:ADA9D:986B25:C73EB9:6B00E152 |
| html-safe-nonce | 8a2f022e9ebfad6c9f73e9dda6118a272ecb2966b479d02dcc8655516ed1240e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzA4OkFEQTlEOjk4NkIyNTpDNzNFQjk6NkIwMEUxNTIiLCJ2aXNpdG9yX2lkIjoiNjEwNDY5NDIzMjMwNjQ3NTM0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bcab0c22e0e873376a4e06d19c531fb040bbaa035becb7bb4e577db222db06e9 |
| hovercard-subject-tag | issue:462174458 |
| 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/32169/issue_layout |
| twitter:image | https://opengraph.githubassets.com/04106753269cd38c712c357cb61e28d3fe29ee15024a5678a5b1e7f877bb1876/microsoft/TypeScript/issues/32169 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/04106753269cd38c712c357cb61e28d3fe29ee15024a5678a5b1e7f877bb1876/microsoft/TypeScript/issues/32169 |
| og:image:alt | TypeScript Version: 3.4 up to 3.6-dev20190628 Search Terms: generic literal unknown Code This is expected: function f |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | evmar |
| 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