Title: Constrained types is not assignable to constrainer union types, and failed to narrow its type · Issue #8563 · microsoft/TypeScript · GitHub
Open Graph Title: Constrained types is not assignable to constrainer union types, and failed to narrow its type · Issue #8563 · microsoft/TypeScript
X Title: Constrained types is not assignable to constrainer union types, and failed to narrow its type · Issue #8563 · microsoft/TypeScript
Description: TypeScript Version: master Code function f
Open Graph Description: TypeScript Version: master Code function f
X Description: TypeScript Version: master Code function f<T extends string[] | {}>(a: T) { if (a instanceof Array) { a = a; } } Expected behavior: $ node built/local/tsc.js index.ts Actual behavior: $ node ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/8563
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Constrained types is not assignable to constrainer union types, and failed to narrow its type","articleBody":"**TypeScript Version:** \n\nmaster\n\n**Code**\n\n``` ts\nfunction f\u003cT extends string[] | {}>(a: T) {\n if (a instanceof Array) {\n a = a;\n }\n}\n```\n\n**Expected behavior:**\n\n```\n$ node built/local/tsc.js index.ts\n```\n\n**Actual behavior:** \n\n```\n$ node built/local/tsc.js index.ts\nindex.ts(3,5): error TS2322: Type 'any[]' is not assignable to type 'T'.\n```\n","author":{"url":"https://github.com/falsandtru","@type":"Person","name":"falsandtru"},"datePublished":"2016-05-11T21:58:44Z","url":"https://github.com/microsoft/TypeScript/issues/8563"}
| 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:0c175247-416f-468f-0ccc-7e3764c9f14c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A27A:EDA7A:2EB6646:3B58A18:6B01C0D4 |
| html-safe-nonce | 0e97b9dcf973cb920f190759574af5117a8e6d65f21118b46d3065dd360459e5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjdBOkVEQTdBOjJFQjY2NDY6M0I1OEExODo2QjAxQzBENCIsInZpc2l0b3JfaWQiOiI0MjU5MTg3OTkxMTMxNTcwMzg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f0458bdfed139a0aaba138e8d8258698048d0cd06cf4c0fad6aee863619c7be9 |
| hovercard-subject-tag | issue:154352605 |
| 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/8563/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d216a3c863c05766f0fe37cb6529646bd8552ce44282f62fe8f56768cfe5df68/microsoft/TypeScript/issues/8563 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d216a3c863c05766f0fe37cb6529646bd8552ce44282f62fe8f56768cfe5df68/microsoft/TypeScript/issues/8563 |
| og:image:alt | TypeScript Version: master Code function f |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | falsandtru |
| 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