Title: Overload on constants: type checking additional parameters · Issue #191 · microsoft/TypeScript · GitHub
Open Graph Title: Overload on constants: type checking additional parameters · Issue #191 · microsoft/TypeScript
X Title: Overload on constants: type checking additional parameters · Issue #191 · microsoft/TypeScript
Description: Hi, consider this bit of code: class Bar { public bar: string; } interface IFoo { doFoo(type: any, bar: any): void; doFoo(type: "Quux", bar: Bar): string; } We use it like this: var foo: IFoo; var result:string = foo.doFoo("Quux", new Ba...
Open Graph Description: Hi, consider this bit of code: class Bar { public bar: string; } interface IFoo { doFoo(type: any, bar: any): void; doFoo(type: "Quux", bar: Bar): string; } We use it like this: var foo: IFoo; var ...
X Description: Hi, consider this bit of code: class Bar { public bar: string; } interface IFoo { doFoo(type: any, bar: any): void; doFoo(type: "Quux", bar: Bar): string; } We use it like this: var foo: ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/191
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Overload on constants: type checking additional parameters","articleBody":"Hi, consider this bit of code:\n\n``` typescript\nclass Bar {\n public bar: string;\n}\ninterface IFoo {\n doFoo(type: any, bar: any): void;\n doFoo(type: \"Quux\", bar: Bar): string;\n}\n```\n\nWe use it like this:\n\n``` typescript\nvar foo: IFoo;\nvar result:string = foo.doFoo(\"Quux\", new Bar()); // fine\n```\n\nHowever, while still specifying \"Quux\", if we pass any type other than new Bar() for the second argument, the compiler falls back to the non-overloaded method:\n\n``` typescript\n// Error TS2011: Cannot convert 'void' to 'string'.\nvar result2: string = foo.doFoo(\"Quux\", \"bar\");\n```\n\nI think this is a bit unfortunate. We are missing an opportunity to verify that the additional arguments also match the overloaded signature.\n\nIdeally the following\n\n``` typescript\nfoo.doFoo(\"Quux\", \"bar\");\n```\n\nshould generate error TS2082: Supplied parameters do not match any signature of call target\n\nSee further discussion on the old [codeplex site](https://typescript.codeplex.com/workitem/993).\n","author":{"url":"https://github.com/NoelAbrahams","@type":"Person","name":"NoelAbrahams"},"datePublished":"2014-07-22T10:08:03Z","url":"https://github.com/microsoft/TypeScript/issues/191"}
| 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:dd22be72-32d1-a026-b083-1b2e81a4206b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D0F0:F85D1:33344:4579E:6AFBF490 |
| html-safe-nonce | a615d096ab93cbd99a44733e7910c1099481e3ab1b5aa8615c32da1b15ff328d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEYwOkY4NUQxOjMzMzQ0OjQ1NzlFOjZBRkJGNDkwIiwidmlzaXRvcl9pZCI6IjEwOTM2MjEwNTYxNTQ2MjkyNjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | eeab9d8e7a139a2bd7fe2e374438103798f1253c66be80cf6806e9ee3048bda3 |
| hovercard-subject-tag | issue:38385870 |
| 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/191/issue_layout |
| twitter:image | https://opengraph.githubassets.com/267306ab69656f133b7325d68a4d232dd51687fecbc2eb48bcbfda80b543bc56/microsoft/TypeScript/issues/191 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/267306ab69656f133b7325d68a4d232dd51687fecbc2eb48bcbfda80b543bc56/microsoft/TypeScript/issues/191 |
| og:image:alt | Hi, consider this bit of code: class Bar { public bar: string; } interface IFoo { doFoo(type: any, bar: any): void; doFoo(type: "Quux", bar: Bar): string; } We use it like this: var foo: IFoo; var ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NoelAbrahams |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| 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 | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width