Title: Inference of constrained generic causes open generic to "escape" · Issue #31402 · microsoft/TypeScript · GitHub
Open Graph Title: Inference of constrained generic causes open generic to "escape" · Issue #31402 · microsoft/TypeScript
X Title: Inference of constrained generic causes open generic to "escape" · Issue #31402 · microsoft/TypeScript
Description: TypeScript Version: 3.5.0-dev.20190514 Search Terms: constrained generic inference infer keyword infer open generic infer constrained generic Code interface Synthetic {} type SyntheticDestination
Open Graph Description: TypeScript Version: 3.5.0-dev.20190514 Search Terms: constrained generic inference infer keyword infer open generic infer constrained generic Code interface Synthetic {} type Synthe...
X Description: TypeScript Version: 3.5.0-dev.20190514 Search Terms: constrained generic inference infer keyword infer open generic infer constrained generic Code interface Synthetic<A, B extends A> {} type ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/31402
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inference of constrained generic causes open generic to \"escape\"","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n--\u003e\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. --\u003e\r\n**TypeScript Version:** 3.5.0-dev.20190514\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) --\u003e\r\n**Search Terms:**\r\nconstrained generic inference infer keyword\r\ninfer open generic\r\ninfer constrained generic\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface Synthetic\u003cA, B extends A\u003e {}\r\ntype SyntheticDestination\u003cT, U\u003e = U extends Synthetic\u003cT, infer V\u003e ? V : never;\r\ntype TestSynthetic = // Resolved to T\r\n SyntheticDestination\u003cnumber, Synthetic\u003cnumber, number\u003e\u003e;\r\n\r\nconst w: TestSynthetic = undefined // ✓\r\nconst x: TestSynthetic = null; // ✓\r\n\r\nconst y: TestSynthetic = 3; // Type '3' is not assignable to type 'T'.\r\nconst z: TestSynthetic = '3'; // Type '\"3\"\"' is not assignable to type 'T'.\r\n```\r\n\r\n**Expected behavior:**\r\n- TestSynthetic resolved as number\r\n- w, x, and z invalid with strict\r\n- y valid\r\n\r\n**Actual behavior:**\r\n- TestSynthetic resolved as T -- an open generic from the underlying conditional type\r\n- w and x valid, even with strict\r\n- y and z error with commented errors\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior --\u003e\r\nhttps://bit.ly/30lTSqk\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? --\u003e\r\nhttps://github.com/microsoft/TypeScript/issues/31326\r\n\r\n**Notes:**\r\n\r\n- Removing the `extends A` constraint causes expected behavior, so that's likely involved somehow.\r\n- Turning on all strict options in typescript playground causes all four example cases to be errors -- unclear why this is stricter than `strict: true` in my local tsconfig with @next.\r\n- I'm not 100% sure if a conditional type that resolves to an open generic is allowed -- I was certainly surprised to see it. If it is, this still seems to be a bug in conditional type resolution.","author":{"url":"https://github.com/ddurschlag6river","@type":"Person","name":"ddurschlag6river"},"datePublished":"2019-05-14T21:54:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/31402/TypeScript/issues/31402"}
| 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:6321e29c-4136-d27b-9c91-232cac601a44 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7BE:32025:E27E52:138C015:6A61A9A4 |
| html-safe-nonce | d077a8794f3726c1aaef6d5583328a02740115228b0135b4f570374957ffdce0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0JFOjMyMDI1OkUyN0U1MjoxMzhDMDE1OjZBNjFBOUE0IiwidmlzaXRvcl9pZCI6IjU2NTU5NzQzODg3MjAzMTQ3ODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bee29da98b12d8170370ba91f3103402653b653b3b0f0411b916c6381e76f4bc |
| hovercard-subject-tag | issue:444142533 |
| 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/31402/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5afc1d7f38db6c98387d928197413cc9363777cc9e2c437607641e45a09d44f4/microsoft/TypeScript/issues/31402 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5afc1d7f38db6c98387d928197413cc9363777cc9e2c437607641e45a09d44f4/microsoft/TypeScript/issues/31402 |
| og:image:alt | TypeScript Version: 3.5.0-dev.20190514 Search Terms: constrained generic inference infer keyword infer open generic infer constrained generic Code interface Synthetic {} type Synthe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ddurschlag6river |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6f4633bcf01c1ad14b73fd07dd39ac31d61f3d3c2578ee08ec1792b7b351eeb9 |
| 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 | ac296ae7f21856f1f92adbad22f870b6fbb4b907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width