Title: TS3.6/3.7 regression: template arguments used in unions no longer resolve/narrow · Issue #34754 · microsoft/TypeScript · GitHub
Open Graph Title: TS3.6/3.7 regression: template arguments used in unions no longer resolve/narrow · Issue #34754 · microsoft/TypeScript
X Title: TS3.6/3.7 regression: template arguments used in unions no longer resolve/narrow · Issue #34754 · microsoft/TypeScript
Description: TypeScript Version: 3.7.1-rc Search Terms: template argument union Code declare class Data { string
Open Graph Description: TypeScript Version: 3.7.1-rc Search Terms: template argument union Code declare class Data { string
X Description: TypeScript Version: 3.7.1-rc Search Terms: template argument union Code declare class Data { string<T>(defaultValue?: string|T): string|T; } declare const str: string|undefined; const x = new...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/34754
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS3.6/3.7 regression: template arguments used in unions no longer resolve/narrow","articleBody":"**TypeScript Version:** 3.7.1-rc\r\n\r\n**Search Terms:** template argument union\r\n\r\n**Code**\r\n\r\n```ts\r\ndeclare class Data {\r\n string\u003cT>(defaultValue?: string|T): string|T;\r\n}\r\n\r\ndeclare const str: string|undefined;\r\nconst x = new Data().string(str);\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nI'd argue `string`, at least that's what the user intended here.\r\n\r\n**Actual behavior:**\r\n\r\nIn TypeScript version:\r\n* 3.5, `typeof x === string`\r\n* 3.6, `typeof x === unknown`\r\n* 3.7, `typeof x === string|undefined`\r\n\r\n**Playground Link:** n/a\r\n","author":{"url":"https://github.com/mprobst","@type":"Person","name":"mprobst"},"datePublished":"2019-10-26T20:12:53Z","url":"https://github.com/microsoft/TypeScript/issues/34754"}
| 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:37a049a8-9973-5ee8-2a79-907e08db069e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B020:2D2F2F:20DEA4A:29FB71F:6B016295 |
| html-safe-nonce | 414cb955a4044e39a461c393fdf63f1d7ae7df1451a75ac74e04cb1711ee40f1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDIwOjJEMkYyRjoyMERFQTRBOjI5RkI3MUY6NkIwMTYyOTUiLCJ2aXNpdG9yX2lkIjoiNDgxNjgxNTg1MzAwNzg4OTA0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f533dc375c85a24da05b8c7196b7074582f9663dd8515e92e04cddfae0b601c7 |
| hovercard-subject-tag | issue:512880020 |
| 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/34754/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8a05089f2013b2061548ee490635f1e2393f3a9965f162b2c9afb8799bb4e504/microsoft/TypeScript/issues/34754 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8a05089f2013b2061548ee490635f1e2393f3a9965f162b2c9afb8799bb4e504/microsoft/TypeScript/issues/34754 |
| og:image:alt | TypeScript Version: 3.7.1-rc Search Terms: template argument union Code declare class Data { string |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mprobst |
| 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