Title: extends clause leaks temporary type · Issue #31099 · microsoft/TypeScript · GitHub
Open Graph Title: extends clause leaks temporary type · Issue #31099 · microsoft/TypeScript
X Title: extends clause leaks temporary type · Issue #31099 · microsoft/TypeScript
Description: TypeScript Version: 3.5.0-dev.20190420 Code // type Weird = U type Weird = any extends infer U ? U : never; // Type 'null' is not assignable to type 'U'. const a: Weird = null; // Type 'U' is not assignable to type 'string'. const b: str...
Open Graph Description: TypeScript Version: 3.5.0-dev.20190420 Code // type Weird = U type Weird = any extends infer U ? U : never; // Type 'null' is not assignable to type 'U'. const a: Weird = null; // Type 'U' is not a...
X Description: TypeScript Version: 3.5.0-dev.20190420 Code // type Weird = U type Weird = any extends infer U ? U : never; // Type 'null' is not assignable to type 'U'. const a: Weird = null; // T...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/31099
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"extends clause leaks temporary type","articleBody":"**TypeScript Version:** 3.5.0-dev.20190420\r\n\r\n**Code**\r\n\r\n```ts\r\n// type Weird = U\r\ntype Weird = any extends infer U ? U : never;\r\n\r\n// Type 'null' is not assignable to type 'U'.\r\nconst a: Weird = null;\r\n\r\n// Type 'U' is not assignable to type 'string'.\r\nconst b: string = a;\r\n\r\n// type AlsoWeird = U\r\ntype AlsoWeird = unknown extends infer U ? U : never;\r\n```\r\n\r\n**Expected behavior:** Infer some type\r\n\r\n**Actual behavior:** The extends clause leaks a temporary type U. Happens for `any` and `unknown`\r\n\r\n**Playground Link:** [Playground](https://www.typescriptlang.org/play/#src=%2F%2F%20type%20Weird%20%3D%20U%0D%0Atype%20Weird%20%3D%20any%20extends%20infer%20U%20%3F%20U%20%3A%20never%3B%0D%0A%0D%0A%2F%2F%20Type%20'null'%20is%20not%20assignable%20to%20type%20'U'.%0D%0Aconst%20a%3A%20Weird%20%3D%20null%3B%0D%0A%0D%0A%2F%2F%20Type%20'U'%20is%20not%20assignable%20to%20type%20'string'.%0D%0Aconst%20b%3A%20string%20%3D%20a%3B%0D%0A%0D%0A%2F%2F%20type%20AlsoWeird%20%3D%20U%0D%0Atype%20AlsoWeird%20%3D%20unknown%20extends%20infer%20U%20%3F%20U%20%3A%20never%3B)\r\n","author":{"url":"https://github.com/SimonMeskens","@type":"Person","name":"SimonMeskens"},"datePublished":"2019-04-24T22:42:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/31099/TypeScript/issues/31099"}
| 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:84e107d8-1674-fda7-dfeb-7fc2e86c9117 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E122:356904:AD54AF:E63EEF:6A62B4A9 |
| html-safe-nonce | 41cdf7bb9d8edc578910a8abed2071aee55a0ab494acb8dc1450c5002e8951ab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTIyOjM1NjkwNDpBRDU0QUY6RTYzRUVGOjZBNjJCNEE5IiwidmlzaXRvcl9pZCI6IjUzOTc4NzUyODI2MTkzMTUzNjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9453e1adbdf6179852de9fab7beb1e8cf1981843a1fd5edc0a12bda515a079c1 |
| hovercard-subject-tag | issue:436937850 |
| 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/31099/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bbcdb21a85497e70193f9dee9c86d2659fd3fae3cb7f74d5e91e9c7e659807f6/microsoft/TypeScript/issues/31099 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bbcdb21a85497e70193f9dee9c86d2659fd3fae3cb7f74d5e91e9c7e659807f6/microsoft/TypeScript/issues/31099 |
| og:image:alt | TypeScript Version: 3.5.0-dev.20190420 Code // type Weird = U type Weird = any extends infer U ? U : never; // Type 'null' is not assignable to type 'U'. const a: Weird = null; // Type 'U' is not a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SimonMeskens |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2738d7125e864b55224a8bc40c72c220ca7d2c73f91a7bb8d69dffe9d35e997d |
| 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 | bf54af498459157b66a67136f992a68752cdbb54 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width