Title: Narrowing breaking changes · Issue #7662 · microsoft/TypeScript · GitHub
Open Graph Title: Narrowing breaking changes · Issue #7662 · microsoft/TypeScript
X Title: Narrowing breaking changes · Issue #7662 · microsoft/TypeScript
Description: This is a place holder for changes to the type narrowing behavior in TypeScript 2.0: Generic type parameters are now narrowed function g
Open Graph Description: This is a place holder for changes to the type narrowing behavior in TypeScript 2.0: Generic type parameters are now narrowed function g
X Description: This is a place holder for changes to the type narrowing behavior in TypeScript 2.0: Generic type parameters are now narrowed function g<T>(obj: T) { var t: T; if (obj instanceof RegExp) { t ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/7662
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Narrowing breaking changes","articleBody":"This is a place holder for changes to the type narrowing behavior in TypeScript 2.0:\n- Generic type parameters are now narrowed\n\n``` ts\nfunction g\u003cT>(obj: T) {\n var t: T;\n if (obj instanceof RegExp) {\n t = obj; // RegExp is not assignable to T\n }\n}\n```\n\nSee the explanation by @Arnavion in https://github.com/Microsoft/TypeScript/issues/7719#issuecomment-202684512\n- Type narrowing does not work for catprued variables in functions and class expressions\n\n``` ts\nexport class Class {\n constructor(public p) { }\n}\n\nvar c: Class | string;\nvar x: Class;\n\nif (c instanceof Class) {\n function inner() {\n x = c; // Error, type of c is not narrowed, c is Class | string\n }\n x = c; // OK, c is Class\n}\n```\n","author":{"url":"https://github.com/mhegazy","@type":"Person","name":"mhegazy"},"datePublished":"2016-03-23T21:56:56Z","url":"https://github.com/microsoft/TypeScript/issues/7662"}
| 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:2bae2a3b-2755-c385-d289-ee0f62388e57 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E21A:2C69FC:A4736B:DB9BE4:6B01BCC4 |
| html-safe-nonce | 31f0350cb22f62bb14dba99e16cb326a6243e7df2f34d477e255b7888bfeb591 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjFBOjJDNjlGQzpBNDczNkI6REI5QkU0OjZCMDFCQ0M0IiwidmlzaXRvcl9pZCI6IjcyMzE2NTIyMjU4MTczNjE2MDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6344a8771b80a246470e3940b4e07a0c794f17f53d00041ff965c7df8280e578 |
| hovercard-subject-tag | issue:143090551 |
| 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/7662/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e6effa50b15e079c7f93adfd02d27031728e415268e3b13d97baa919ebace22a/microsoft/TypeScript/issues/7662 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e6effa50b15e079c7f93adfd02d27031728e415268e3b13d97baa919ebace22a/microsoft/TypeScript/issues/7662 |
| og:image:alt | This is a place holder for changes to the type narrowing behavior in TypeScript 2.0: Generic type parameters are now narrowed function g |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mhegazy |
| 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