Title: TypeScript unable to infer types properly between interfaces and overloaded methods. · Issue #43643 · microsoft/TypeScript · GitHub
Open Graph Title: TypeScript unable to infer types properly between interfaces and overloaded methods. · Issue #43643 · microsoft/TypeScript
X Title: TypeScript unable to infer types properly between interfaces and overloaded methods. · Issue #43643 · microsoft/TypeScript
Description: Bug Report In all versions of TS I can find, there's no way to mark certain call patterns of a method as deprecated while maintaining inference with certain interfaces. If an interface is split out into different overloads so certain ove...
Open Graph Description: Bug Report In all versions of TS I can find, there's no way to mark certain call patterns of a method as deprecated while maintaining inference with certain interfaces. If an interface is split out...
X Description: Bug Report In all versions of TS I can find, there's no way to mark certain call patterns of a method as deprecated while maintaining inference with certain interfaces. If an interface is split...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/43643
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TypeScript unable to infer types properly between interfaces and overloaded methods.","articleBody":"# Bug Report\r\n\r\nIn all versions of TS I can find, there's no way to mark certain call patterns of a method as deprecated while maintaining inference with certain interfaces. If an interface is split out into different overloads so certain overloads can be deprecated, then it breaks inference in some cases.\r\n\r\n### 🔎 Search Terms\r\n\r\nI'm not sure what to search for here. Interfaces? \r\n\r\n### 🕗 Version & Regression Information\r\n\r\n\u003c!-- When did you start seeing this bug occur?\r\n\r\n\"Bugs\" that have existed in TS for a long time are very likely to be FAQs; refer to\r\n https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs\r\n\r\nIf possible, please try testing the nightly version of TS to see if it's 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\nNote: The TypeScript Playground can be used to try older versions of TypeScript.\r\n\r\nPlease keep and fill in the line that best applies:\r\n-->\r\n- All versions\r\n\r\n### ⏯ Playground Link\r\n\r\n\u003c!--\r\n A link to a TypeScript Playground \"Share\" link which shows this behavior\r\n\r\n The TypeScript Workbench can be used for more complex setups, try\r\n https://www.typescriptlang.org/dev/bug-workbench/\r\n\r\n As a last resort, you can link to a repo, but these will be slower for us to investigate.\r\n-->\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgPICMDO0Bu0A8AKgHzIDeAsAFDK3IgQAeYAFDnADYCuEAXMoQCU-HAHtgAEwDc1OsmhRRUFgqX84IAJ7DkYyTJp0EogLYAHDhEgsde6dQC+1aqEixEKAKohMXLAihgdDh0S3JZOi4fP0wAoIgbEXF7KicqF3BoeCRkAGUYuODQiCJSSkNaX39A9ATRLFxoAH5+AAU4KDBgTnwMbCg8KFLiHW8q2JqQywM06gQOOExMNAaBqZKSZGBzSxMIcGX86qD10vCK5AB6a5vbu-uHx7uI2mvkADVOSWQETg5kMxwMBuEAvK5PCGQiFg8aFOqrQaoKAAOSYYBayHanW6HF6CIIJFIAB9kCw2JwePwhMgALykOyCUbRY5FabOdIXKFc7k3MFvAAiEDMUAgv0gEh+fwBQJBmD5PIV0M5ACplWDkMrkAABCRCkViiASwgAC2Ay1+HH+gOB0BAW2WAHNxCAHcg4AB3OCadXKy4wgo1BIMZj8EBcS3IElRXUwUCGgA08igiigofD-yjIBjcYkieMOysfFJglp9OSTNhk2KBjkl1VPu1uuFoqBhoEpvNUutIPtyCdoFdHq9Pr9F0r8RYwbAaYjmezDFzSZT-BUybUbq0JbpumSedMFkLGJspZ3kgrAZO1b59YuGsbepb4vbZslEe7tt7-Zdbs93tvvv9FkgzRFd2G4ItqW3OxE1UVN6HTSNkGjCBYwXPcC0gFctzLM9+DGC9WQgGs6DrNV-3vZsDSNDtXytGUPxfL9B1-EdAImCcpyPMDKQEbDT0XWCj1g9RNxPaCfn3SxICPPiGTw5l2MIgx2VrRU1MeeVkAASR2eV1P03kxwIhIADozI6B1MBEzQAG0AF1zxZdZzjkOQRTALgoDtcpXN8pCFLhY8yDSPzkAcYjaDSWYORgKIEC6UQ7UwUwrFNF0TSBQg4AAawgTAjkU04SBYCz+AKwoipGKkXLodzPLtMNLQAQhmdkDIVag3lQTzkHgYBLAlJgzFFMAgWARLkGNaAIE6y5SWAMAAHJliibKQFEd0QEEWb2q5OZEswMBkBFXwOCOmlkGSvYwDSh0MrALLcvygj1knCB3RWfp2GKfAwxMWooGIGxBCkcFkAAEgAUUYYb4sITRhvg-7oCAA)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\ninterface Observer\u003cT> {\r\n next(value: T): void;\r\n error(error: any): void;\r\n complete(): void;\r\n}\r\n\r\ninterface Unsubscribable {\r\n unsubscribe(): void;\r\n}\r\n\r\ninterface Subscribable\u003cT> {\r\n subscribe(observer?: Partial\u003cObserver\u003cT>>): Unsubscribable;\r\n}\r\n\r\nclass Observable\u003cT> implements Subscribable\u003cT> {\r\n /////////////////////////////////////////\r\n // Valid call pattern\r\n /////////////////////////////////////////\r\n subscribe(observerOrNext?: Partial\u003cObserver\u003cT>> | ((value: T) => void)): Unsubscribable;\r\n\r\n\r\n //////////////////////////////////////////\r\n // Deprecated call patterns\r\n //////////////////////////////////////////\r\n /**\r\n * @deprecated This call pattern is going away\r\n */\r\n subscribe(next: null | undefined, error: null | undefined, complete: () => void): Unsubscribable;\r\n /**\r\n * @deprecated This call pattern is going away\r\n */\r\n subscribe(next: null | undefined, error: (error: any) => void, complete?: () => void): Unsubscribable;\r\n /**\r\n * @deprecated This call pattern is going away\r\n */\r\n subscribe(next: (value: T) => void, error: null | undefined, complete: () => void): Unsubscribable;\r\n /**\r\n * @deprecated This call pattern is going away\r\n */\r\n subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Unsubscribable;\r\n\r\n\r\n ////////////////////////////////////////////\r\n // Impl\r\n ////////////////////////////////////////////\r\n subscribe(...args: any[]): Unsubscribable {\r\n return {\r\n unsubscribe() {}\r\n };\r\n }\r\n}\r\n\r\n\r\nfunction somethingThatTakesSubscribable\u003cT>(arg: Subscribable\u003cT>): T {\r\n return null!;\r\n}\r\n\r\n/////////////////////////////////////\r\n// Our failed expectation here\r\n// (it's unknown)\r\n/////////////////////////////////////\r\nconst result = somethingThatTakesSubscribable(new Observable\u003cnumber>()); // $ExpectType number\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\n`result` is `unknown` above.\r\n\r\n### 🙂 Expected behavior\r\n\r\n`result` would be `number`.\r\n","author":{"url":"https://github.com/benlesh","@type":"Person","name":"benlesh"},"datePublished":"2021-04-12T15:25:15Z","url":"https://github.com/microsoft/TypeScript/issues/43643"}
| 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:83489fca-49a3-4979-8f98-36bd477c0bc0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C710:4BB79:17D91B2:1E6B211:6B0143B3 |
| html-safe-nonce | e33a0d1b60c60fe0c4f6deb81aa291bf7da3a4366d5accbffc6f8c2a108bc994 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzEwOjRCQjc5OjE3RDkxQjI6MUU2QjIxMTo2QjAxNDNCMyIsInZpc2l0b3JfaWQiOiIxMjA0NDU1OTY4NTgzMjcxMzQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 388b2a571f93a9bc5e93f853419d356fb96bf8e04b2e7f19a0926b907ad9a3f5 |
| hovercard-subject-tag | issue:856090249 |
| 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/43643/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7ac113641218086c8f5d6e08e290b007727f0ead3cb231a84afdd462cf1c6046/microsoft/TypeScript/issues/43643 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7ac113641218086c8f5d6e08e290b007727f0ead3cb231a84afdd462cf1c6046/microsoft/TypeScript/issues/43643 |
| og:image:alt | Bug Report In all versions of TS I can find, there's no way to mark certain call patterns of a method as deprecated while maintaining inference with certain interfaces. If an interface is split out... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | benlesh |
| 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