Title: Wrong type inference with tuples · Issue #22432 · microsoft/TypeScript · GitHub
Open Graph Title: Wrong type inference with tuples · Issue #22432 · microsoft/TypeScript
X Title: Wrong type inference with tuples · Issue #22432 · microsoft/TypeScript
Description: TypeScript Version: 2.7.0-dev.20180307 Search Terms: Code Expected behavior: type B
Open Graph Description: TypeScript Version: 2.7.0-dev.20180307 Search Terms: Code Expected behavior: type B
X Description: TypeScript Version: 2.7.0-dev.20180307 Search Terms: Code Expected behavior: type B<R, S> = [R] | [R, S]; declare function g<T, U>(f: B<T, U>): void; g([[]] as [never[]]); // T: n...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/22432
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrong type inference with tuples","articleBody":"**TypeScript Version:** 2.7.0-dev.20180307\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** \r\n\r\n**Code**\r\n\r\n**Expected behavior:**\r\n\r\n```ts\r\ntype B\u003cR, S> = [R] | [R, S];\r\ndeclare function g\u003cT, U>(f: B\u003cT, U>): void;\r\ng([[]] as [never[]]); // T: never[], U: {}\r\ng([[]] as [void[]]); // T: void[], U: {}\r\n\r\ntype C\u003cR, S> = [R[]] | [R[], S];\r\ndeclare function h\u003cT, U>(f: C\u003cT, U>): void;\r\nh([[]] as [never[]]); // T: never, U: {}\r\nh([[]] as [void[]]); // T: void, U: {}\r\n\r\ntype A\u003cR, S> = [R[], string] | [R[], string, S];\r\ndeclare function f\u003cT, U>(f: A\u003cT, U>): void;\r\nf([[], ''] as [never[], string]); // T: never, U: {}\r\nf([[], ''] as [void[], string]); // T: void, U: {}\r\n```\r\n\r\n**Actual behavior:**\r\n\r\n```ts\r\ntype B\u003cR, S> = [R] | [R, S];\r\ndeclare function g\u003cT, U>(f: B\u003cT, U>): void;\r\ng([[]] as [never[]]); // T: never[], U: {}\r\ng([[]] as [void[]]); // T: void[], U: {}\r\n\r\ntype C\u003cR, S> = [R[]] | [R[], S];\r\ndeclare function h\u003cT, U>(f: C\u003cT, U>): void;\r\nh([[]] as [never[]]); // T: never[], U: never[] | ConcatArray\u003cnever[]>\r\nh([[]] as [void[]]); // T: void, U: void[] | ConcatArray\u003cvoid[]>\r\n\r\ntype A\u003cR, S> = [R[], string] | [R[], string, S];\r\ndeclare function f\u003cT, U>(f: A\u003cT, U>): void;\r\nf([[], ''] as [never[], string]); // T: string | never[], U: never[] | ConcatArray\u003cstring | never[]>\r\nf([[], ''] as [void[], string]); // T: void, U: void[] | ConcatArray\u003cstring | void[]>\r\n```\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior --> \r\n\r\n**Related Issues:**\r\n","author":{"url":"https://github.com/falsandtru","@type":"Person","name":"falsandtru"},"datePublished":"2018-03-09T15:55:18Z","url":"https://github.com/microsoft/TypeScript/issues/22432"}
| 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:bf673a24-ba68-148b-989b-d11b812231cf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D056:363D8E:E9524F:12B4F0F:6B00F694 |
| html-safe-nonce | 043a0a1a3bbeb8c3549f659015338b41f32031b1933ae2cf19e3007d902e4f6c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDU2OjM2M0Q4RTpFOTUyNEY6MTJCNEYwRjo2QjAwRjY5NCIsInZpc2l0b3JfaWQiOiI5MDg3MTg1NjQzNjcwNDAyNzA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6f921004cf3ae808c62a97fa78fa233a384dd12fc1e9663277db73db9d5f9238 |
| hovercard-subject-tag | issue:303887707 |
| 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/22432/issue_layout |
| twitter:image | https://opengraph.githubassets.com/500c110255e07869da918b4aea07cb727c2f18ef5ce5ed21f9686990eeb005e4/microsoft/TypeScript/issues/22432 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/500c110255e07869da918b4aea07cb727c2f18ef5ce5ed21f9686990eeb005e4/microsoft/TypeScript/issues/22432 |
| og:image:alt | TypeScript Version: 2.7.0-dev.20180307 Search Terms: Code Expected behavior: type B |
| 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 | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width