Title: callbacks should select the right overload · Issue #35501 · microsoft/TypeScript · GitHub
Open Graph Title: callbacks should select the right overload · Issue #35501 · microsoft/TypeScript
X Title: callbacks should select the right overload · Issue #35501 · microsoft/TypeScript
Description: TypeScript Version: 3.8.0-dev.20191121 Search Terms: callback overload mismatch Code declare function fn(x: string): string; declare function fn(x: string[]): string; declare function map(fn: (item: A) => R, list: A[]): R[]; const ...
Open Graph Description: TypeScript Version: 3.8.0-dev.20191121 Search Terms: callback overload mismatch Code declare function fn(x: string): string; declare function fn(x: string[]): string; declare function map(fn:...
X Description: TypeScript Version: 3.8.0-dev.20191121 Search Terms: callback overload mismatch Code declare function fn(x: string): string; declare function fn(x: string[]): string; declare function map<A, R&g...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/35501
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"callbacks should select the right overload","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\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.8.0-dev.20191121\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\ncallback overload mismatch\r\n\r\n**Code**\r\n\r\n```ts\r\ndeclare function fn(x: string): string;\r\ndeclare function fn(x: string[]): string;\r\n\r\ndeclare function map\u003cA, R>(fn: (item: A) => R, list: A[]): R[];\r\n\r\nconst mapped = map(fn, ['1']) // error\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nTypeScript does infer `A` as `string` and could choose the right overload `fn(x: string)`, decline the ones that don't fit.\r\n\r\n**Actual behavior:**\r\n\r\nChecks the last overload only, so it shows an error.\r\n\r\n**Playground Link:** http://www.typescriptlang.org/play/?ssl=7&ssc=1&pln=1&pc=1#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVNQAoAPALngGcMYtUBzASnKpvoG4AoUSWBFdbHgIlm1WnQDaAXSaUx7Dl3DQ4SNJlz4AtlAAOAHgCCAGngAlAHyFEqcoSwYQW8oYbwAvBfOmIWKi+lZM2lODjA8KngdXV0QYA8ovWtUUwkAcgBGNJkOIA\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/millsp","@type":"Person","name":"millsp"},"datePublished":"2019-12-04T18:21:03Z","url":"https://github.com/microsoft/TypeScript/issues/35501"}
| 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:370e0641-d382-6093-15ba-1a9597d3b456 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 995C:1D86C4:7383FF:9458B7:6B00E3EC |
| html-safe-nonce | 5fe6ef25327985a8195846a9edadd92e8c22fc23ed824e85d4df78de0b56cf16 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTVDOjFEODZDNDo3MzgzRkY6OTQ1OEI3OjZCMDBFM0VDIiwidmlzaXRvcl9pZCI6IjUxMjYwMTQzMjgyMTgxMTcxMDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5d9e79b564981f46dbd5be581d253c2f518c180735d952ccaf256b4df211d9b3 |
| hovercard-subject-tag | issue:532855233 |
| 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/35501/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7f73018a4906f8ea2b5e34d5cad0f16f023b9bb291ac5277df31ff682066373d/microsoft/TypeScript/issues/35501 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7f73018a4906f8ea2b5e34d5cad0f16f023b9bb291ac5277df31ff682066373d/microsoft/TypeScript/issues/35501 |
| og:image:alt | TypeScript Version: 3.8.0-dev.20191121 Search Terms: callback overload mismatch Code declare function fn(x: string): string; declare function fn(x: string[]): string; declare function map(fn:... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | millsp |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width