Title: 5.6 regression: Array.prototype.reduce type inference regression · Issue #59763 · microsoft/TypeScript · GitHub
Open Graph Title: 5.6 regression: Array.prototype.reduce type inference regression · Issue #59763 · microsoft/TypeScript
X Title: 5.6 regression: Array.prototype.reduce type inference regression · Issue #59763 · microsoft/TypeScript
Description: 🔎 Search Terms Inference, Reduce 🕗 Version & Regression Information This changed between versions 5.5.4 and 5.6.0-beta (still happening in 5.6.1-rc) ⏯ Playground Link https://www.typescriptlang.org/play/?ts=5.6.1-rc#code/JYOwLgpgTgZghgYw...
Open Graph Description: 🔎 Search Terms Inference, Reduce 🕗 Version & Regression Information This changed between versions 5.5.4 and 5.6.0-beta (still happening in 5.6.1-rc) ⏯ Playground Link https://www.typescriptlang.org...
X Description: 🔎 Search Terms Inference, Reduce 🕗 Version & Regression Information This changed between versions 5.5.4 and 5.6.0-beta (still happening in 5.6.1-rc) ⏯ Playground Link https://www.typescriptlang...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/59763
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"5.6 regression: Array.prototype.reduce type inference regression","articleBody":"### 🔎 Search Terms\n\nInference, Reduce\n\n### 🕗 Version \u0026 Regression Information\n\n- This changed between versions 5.5.4 and 5.6.0-beta (still happening in 5.6.1-rc)\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?ts=5.6.1-rc#code/JYOwLgpgTgZghgYwgAgMoHsC2EAqBPABxQG8AoZC5CEAVwC40sIBRWzAblIF9TTqbMjbKwHIylZAEFkAXmQBGADTlKAIVnIATMokBhDQGYdlACIaALMp6kAJhAQAbOFBQJ0IAM5hkANzgOPBgxsfCIAbQBdTlI3T28PTH8HCC8RDT8AgDoXGxokAAoVCnzMUBFFX38ASlkAPmQAWTgwAAtM0pASstoKjMz+KuMKYJY2TJNlKs4EpJSwEU4AekXkAD0AfiA\n\n### 💻 Code\n\n```ts\r\ninterface SomeType {\r\n enu: SomeEnum;\r\n}\r\n\r\nenum SomeEnum {\r\n A = 1,\r\n B = 2,\r\n C = 3,\r\n D = 4,\r\n}\r\n\r\ndeclare const vals: SomeType[];\r\n\r\nconst smallestEnu = vals.reduce(\r\n (minEnu, val) =\u003e Math.min(minEnu, val.enu),\r\n SomeEnum.D,\r\n);\r\nsmallestEnu;\r\n// ^?\r\n```\r\n\n\n### 🙁 Actual behavior\n\n`smallestEnu` has type `number`\n\n### 🙂 Expected behavior\n\n`smallestEnu` has type `SomeEnum` as it did in previous releases\n\n### Additional information about the issue\n\nInterestingly, this does not repro if you remove the container type:\r\nhttps://www.typescriptlang.org/play/?ts=5.6.1-rc#code/KYOwrgtgBAyg9hYBRc0DeAoK2oEEoC8UAjADRY4BChUATOTlAMI0DMDOAIjQCzkC+GDABNgAYwA2AQwBOwKGLggAzgBcooSMoBcsBMlQBtALoBuIYpXrlEKRInA1KMDU0RlAOjnCwY4AAoKbH8IAEsQZ1INcABKQgA+KABZKVUACw8wkBDwyOiwGI5seERnCA9OchjzGzsHJ3BzAHomqAA9AH4MIA\r\n\r\n(Google note: relevant source location http://shortn/_JgMRGaMa4e)","author":{"url":"https://github.com/trevorade","@type":"Person","name":"trevorade"},"datePublished":"2024-08-26T19:41:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/59763/TypeScript/issues/59763"}
| 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:ca293805-147b-16b8-4168-179701827654 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A922:3F0017:11B7D0:17DF01:6A612F5B |
| html-safe-nonce | 2b9f9e1c867dd1a26e5ee03580cd8286259b481279c9a8fab9ffe1a4c344cb5c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTIyOjNGMDAxNzoxMUI3RDA6MTdERjAxOjZBNjEyRjVCIiwidmlzaXRvcl9pZCI6IjM0ODkzOTY3ODUwMDEwODI3MTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a349c7a785b118c51d6311616a01e4868079a96b5c61edd7a4e85762297fa7f8 |
| hovercard-subject-tag | issue:2487631207 |
| 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/59763/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ccc38fc80d35fd0617f516941d2854efb52466602dc54193ff328bbfbd4e7fcb/microsoft/TypeScript/issues/59763 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ccc38fc80d35fd0617f516941d2854efb52466602dc54193ff328bbfbd4e7fcb/microsoft/TypeScript/issues/59763 |
| og:image:alt | 🔎 Search Terms Inference, Reduce 🕗 Version & Regression Information This changed between versions 5.5.4 and 5.6.0-beta (still happening in 5.6.1-rc) ⏯ Playground Link https://www.typescriptlang.org... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trevorade |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6896275b704df9b9258326d49c8695aecd98d736cd9eeda7bcbb1790ac97d3ad |
| 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 | af89f6cd55841b57fa09b6b0ed9e3f8f2e94b05d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width