Title: Type inference with reduce functions · Issue #36225 · microsoft/TypeScript · GitHub
Open Graph Title: Type inference with reduce functions · Issue #36225 · microsoft/TypeScript
X Title: Type inference with reduce functions · Issue #36225 · microsoft/TypeScript
Description: Type of array elements shouldn't affect type inference in this case. TypeScript Version: 3.7.x-dev.20200115 Search Terms: Code ([] as any[]).reduce(() => 0, 0); // any ([] as unknown[]).reduce(() => 0, 0); // unknown ([] as never[]).redu...
Open Graph Description: Type of array elements shouldn't affect type inference in this case. TypeScript Version: 3.7.x-dev.20200115 Search Terms: Code ([] as any[]).reduce(() => 0, 0); // any ([] as unknown[]).reduce(() =...
X Description: Type of array elements shouldn't affect type inference in this case. TypeScript Version: 3.7.x-dev.20200115 Search Terms: Code ([] as any[]).reduce(() => 0, 0); // any ([] as unknown[]).redu...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/36225
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type inference with reduce functions","articleBody":"Type of array elements shouldn't affect type inference in this case.\r\n\r\n\u003c!--\r\nPlease try to reproduce the issue with the latest published version. It may have already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n-->\r\n**TypeScript Version:** 3.7.x-dev.20200115\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```ts\r\n([] as any[]).reduce(() => 0, 0); // any\r\n([] as unknown[]).reduce(() => 0, 0); // unknown\r\n([] as never[]).reduce(() => 0, 0); // number\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n```ts\r\n([] as any[]).reduce(() => 0, 0); // number\r\n([] as unknown[]).reduce(() => 0, 0); // number\r\n([] as never[]).reduce(() => 0, 0); // never or number\r\n```\r\n\r\n**Actual behavior:**\r\n\r\n```ts\r\n([] as any[]).reduce(() => 0, 0); // any\r\n([] as unknown[]).reduce(() => 0, 0); // unknown\r\n([] as never[]).reduce(() => 0, 0); // number\r\n```\r\n\r\n**Playground Link:** https://www.typescriptlang.org/play/?target=99&ts=3.8.0-dev.20200115&ssl=1&ssc=1&pln=3&pc=46#code/BQbQugBAhgztB2BPcBKAdAJwKYBMCuAxlsMChALwB8EADADS0oDcEA9KwogFCiSwR54Aa3gB7AO7xUmXIWKkK1eoxbsBwsZJ7hoceFgBuWDNOz4iJMlVoMazNh3h4AtgCNjQA\r\n\r\n**Related Issues:** #25454\r\n","author":{"url":"https://github.com/falsandtru","@type":"Person","name":"falsandtru"},"datePublished":"2020-01-16T13:45:10Z","url":"https://github.com/microsoft/TypeScript/issues/36225"}
| 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:a86e7689-a27a-33e8-df9c-d6b5cd46a20c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B56:37820D:DF9975:12AB8DC:6B00F58D |
| html-safe-nonce | 0ff5585b9ca53129fc8ef791aea7ddb6237463962049e26d634591dc9688c18f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjU2OjM3ODIwRDpERjk5NzU6MTJBQjhEQzo2QjAwRjU4RCIsInZpc2l0b3JfaWQiOiI2NDAwMzE2NDU3NjI4MDA1NzczIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e3011055e74a432c665d45e3c231cca7d1b7f3a6596a0b39cf7d4339291fb723 |
| hovercard-subject-tag | issue:550816866 |
| 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/36225/issue_layout |
| twitter:image | https://opengraph.githubassets.com/58100d9660308c5a81410021a7ecf704d5c0d1f1366f8fe241ef2ebb7089fd0b/microsoft/TypeScript/issues/36225 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/58100d9660308c5a81410021a7ecf704d5c0d1f1366f8fe241ef2ebb7089fd0b/microsoft/TypeScript/issues/36225 |
| og:image:alt | Type of array elements shouldn't affect type inference in this case. TypeScript Version: 3.7.x-dev.20200115 Search Terms: Code ([] as any[]).reduce(() => 0, 0); // any ([] as unknown[]).reduce(() =... |
| 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