Title: Improve error when function overload set incorrectly authored · Issue #4797 · microsoft/TypeScript · GitHub
Open Graph Title: Improve error when function overload set incorrectly authored · Issue #4797 · microsoft/TypeScript
X Title: Improve error when function overload set incorrectly authored · Issue #4797 · microsoft/TypeScript
Description: Users do not realize that implementation signatures of overload sets do not count as an actual signature at call sites. Attempting to call their overloaded function then results in a surprising error and off they go to StackOverflow to a...
Open Graph Description: Users do not realize that implementation signatures of overload sets do not count as an actual signature at call sites. Attempting to call their overloaded function then results in a surprising err...
X Description: Users do not realize that implementation signatures of overload sets do not count as an actual signature at call sites. Attempting to call their overloaded function then results in a surprising err...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/4797
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve error when function overload set incorrectly authored","articleBody":"Users do not realize that implementation signatures of overload sets do not count as an actual signature at call sites. Attempting to call their overloaded function then results in a surprising error and off they go to StackOverflow to ask a question or here to file a bug. This comes up fairly often (most recently with https://github.com/Microsoft/TypeScript/issues/4786).\n\nCan we improve the error by checking the type at the callsite against the implementation signature if no other signatures are applicable? Ex:\n\n``` ts\nclass EventAggregator\n{\n publish(event: string, data?: any): void;\n publish\u003cT>(event: T): void {}\n}\n\nvar ea: EventAggregator;\nea.publish([1,2,3]); \n```\n\nToday the last line is an error: \"number[] is not assignable to string.\" To many this just looks like the compiler for some reason chose the wrong overload, now what?\n\nIn this case after seeing array is not assignable to any overload signatures we could check whether it is assignable to the implementation signature. If it is, we could issue a potentially more helpful error mentioning this rule (implementation signatures are not considered overload signatures) and a potential fix.\n","author":{"url":"https://github.com/danquirk","@type":"Person","name":"danquirk"},"datePublished":"2015-09-15T01:56:58Z","url":"https://github.com/microsoft/TypeScript/issues/4797"}
| 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:dd3daf42-5d72-5853-972d-897cc3ff1c25 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D526:3DD488:200744A:28A2F9F:6B017055 |
| html-safe-nonce | f78dcdc7ca9d133181b138d7ce253fb8c2d46b5989963b942970d7fbfa646cd9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTI2OjNERDQ4ODoyMDA3NDRBOjI4QTJGOUY6NkIwMTcwNTUiLCJ2aXNpdG9yX2lkIjoiMTQ3ODg3MjI1MjQ0MjMwODY5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | af287102b464d39979d986d396b9ea38a1c3eab8534e7f8db2765ec2064ad2f1 |
| hovercard-subject-tag | issue:106461061 |
| 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/4797/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7d0c8d797de80fb9f26e8202f490380ae15aa22ade3699ae307817044ff18649/microsoft/TypeScript/issues/4797 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7d0c8d797de80fb9f26e8202f490380ae15aa22ade3699ae307817044ff18649/microsoft/TypeScript/issues/4797 |
| og:image:alt | Users do not realize that implementation signatures of overload sets do not count as an actual signature at call sites. Attempting to call their overloaded function then results in a surprising err... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danquirk |
| 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