Title: Narrowing does not work for variables typed with type parameters · Issue #6445 · microsoft/TypeScript · GitHub
Open Graph Title: Narrowing does not work for variables typed with type parameters · Issue #6445 · microsoft/TypeScript
X Title: Narrowing does not work for variables typed with type parameters · Issue #6445 · microsoft/TypeScript
Description: interface Base { b } interface Derived extends Base { d } declare function isDerived(x: Base): x is Derived; function f
Open Graph Description: interface Base { b } interface Derived extends Base { d } declare function isDerived(x: Base): x is Derived; function f
X Description: interface Base { b } interface Derived extends Base { d } declare function isDerived(x: Base): x is Derived; function f<T extends Base>(x: T, y: T) { if (isDerived(x) && isDerived(y))...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/6445
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Narrowing does not work for variables typed with type parameters","articleBody":"``` ts\ninterface Base { b }\ninterface Derived extends Base { d }\n\ndeclare function isDerived(x: Base): x is Derived;\n\nfunction f\u003cT extends Base>(x: T, y: T) {\n if (isDerived(x) && isDerived(y)) {\n return x.d === y.d;\n }\n\n return false;\n}\n```\n\nCurrently, this errors because both `x` and `y` still have type `T`, so they are missing the `d` property.\n","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2016-01-12T00:13:59Z","url":"https://github.com/microsoft/TypeScript/issues/6445"}
| 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:6f1406aa-2309-0eaa-f258-196db1544836 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD68:187C1E:CDF1D3:1109B34:6B01C9B1 |
| html-safe-nonce | c975e210a329b683d7c58ccf6c57b1aaf56fd54da7e12caa5ed05664867149f0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDY4OjE4N0MxRTpDREYxRDM6MTEwOUIzNDo2QjAxQzlCMSIsInZpc2l0b3JfaWQiOiIzNzEyMTY1NTQxNjc1Mzg3MzEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 28beb72603eae39ffd541b68a884521dfc459fd390156b9aecf05cc21ca1e99e |
| hovercard-subject-tag | issue:126068183 |
| 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/6445/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d69d9f59f9d58a2409e2e37c3793c95ead91215c56e811182248a1c72bcc2ca7/microsoft/TypeScript/issues/6445 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d69d9f59f9d58a2409e2e37c3793c95ead91215c56e811182248a1c72bcc2ca7/microsoft/TypeScript/issues/6445 |
| og:image:alt | interface Base { b } interface Derived extends Base { d } declare function isDerived(x: Base): x is Derived; function f |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| 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