Title: Conditional type triggers "No error for last overload signature" exception · Issue #55217 · microsoft/TypeScript · GitHub
Open Graph Title: Conditional type triggers "No error for last overload signature" exception · Issue #55217 · microsoft/TypeScript
X Title: Conditional type triggers "No error for last overload signature" exception · Issue #55217 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms "No error for last overload signature" yields stale issue 35186, and a couple of more recent issues that got resolved: 48636, 37974. (The stale 35186 appears to be a different issue as it also occurs in versions...
Open Graph Description: Bug Report 🔎 Search Terms "No error for last overload signature" yields stale issue 35186, and a couple of more recent issues that got resolved: 48636, 37974. (The stale 35186 appears to be a diffe...
X Description: Bug Report 🔎 Search Terms "No error for last overload signature" yields stale issue 35186, and a couple of more recent issues that got resolved: 48636, 37974. (The stale 35186 appears to ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/55217
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Conditional type triggers \"No error for last overload signature\" exception","articleBody":"# Bug Report\r\n\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n--\u003e\r\n\r\n### 🔎 Search Terms\r\n\r\n**\"No error for last overload signature\"** yields [stale issue 35186](https://github.com/microsoft/TypeScript/issues/35186), and a couple of more recent issues that got resolved: [48636](https://github.com/microsoft/TypeScript/issues/48636), [37974](https://github.com/microsoft/TypeScript/issues/37974). (The stale 35186 appears to be a different issue as it also occurs in versions before v5.0.4.)\r\n\u003c!--\r\n What search terms did you use when trying to find an existing bug report?\r\n List them here so people in the future can find this one more easily.\r\n--\u003e\r\n\r\n### 🕗 Version \u0026 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--\u003e\r\n- This is a crash\r\n- This changed between versions 4.9.5 and 5.0.4, and still occurs up to typescript@next.\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 This should have the same code as the code snippet below, and use whichever settings are relevant to your report.\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--\u003e\r\n[Bug-workbench link with relevant code](https://www.typescriptlang.org/dev/bug-workbench/?ts=5.2.0-beta#code/PTAEAEDMEsBsFMB2BDAtvAXKALgTwA7wDOAdNkQFDwAe+A9gE7Y4HygAKDdAJgK4DG2AHJo2AXlAByZJNAAfKQCNJFKrUbM8hUAGVei-Fz6CR6AGKNOPAcNEAedqBrYk3IhyM3T8AHygJjs6u7ryIANaIdADuiBSgoAD8oGHwuHSQoACiiNjQucQAQrhWxrboANrsALpxoFiI8ABu8AyqWmzZuflERSVeov6gAN61yFhDoMgAjOOgjciwvJhSyAC007IAvqCbtYqzijPDcwtLWJKKq4dbOxS7avRMLNoAItBE-AzQqNAoLtwAVUQ0DoiDstUC1BciDcHmsJgGAU8CPQABpapknFDgrp9IZ4WV4BYGH0UfAHH4JHoDMjCcTSYSKejKRwsdDYQzvLV4klMUEYe5qfjSt56bTvBTuaAQIksmycaEItFENKwAB1PIAC1AisiMVROE1bBo-Hg+FyoNA3DoxEQkmYmuQ+EIiBIoClPKyOTy0EKxXFokqVXKmRq8XDdVADWarQj9SaLVUMqgcCQoiwTvwZEo30ezAmQoD5ksRfgBreHy+Pz+8EBwNBBs5A22kC4qCkJGA7SIKgeGlA-FBRGYil4AHNBg55QK4SLRD4ABQASn8fhG8UHiGHoCIeNpRCwFc+31+yH+QJBYPYBsLBNFJbv9nYPh85SqgzftV3NIJpFQToXBcAH1D3eY9qzPWsL1BFcxD8RBeFgWAlzuCggA)\r\n\r\n### 💻 Code\r\n\r\n```ts\r\n// @filename: types.ts\r\nexport type ProductName = 'a' | 'b'\r\n\r\nexport type SubproductNameForProductName\u003cP extends ProductName\u003e = P extends unknown\r\n ? keyof EntitiesByProductName[P]\r\n : never\r\n\r\ntype EntitiesByProductName = {\r\n a: { a1: { value: 'a-a1' } }\r\n b: { b1: { value: 'b-b1' } }\r\n}\r\n\r\nexport type DiscriminatedUnion\u003c\r\n P extends ProductName = ProductName,\r\n E extends SubproductNameForProductName\u003cP\u003e = SubproductNameForProductName\u003cP\u003e,\r\n\u003e = P extends ProductName\r\n ? E extends SubproductNameForProductName\u003cP\u003e\r\n // ? E extends unknown // With unknown, the exception doesn't happen. \r\n ? EntitiesByProductName[P][E]\r\n : never\r\n : never\r\n\r\n// @filename: app.ts\r\nimport { SubproductNameForProductName, DiscriminatedUnion, ProductName } from './types'\r\n\r\nexport const bug = \u003cP extends ProductName\u003e() =\u003e {\r\n const subproducts: DiscriminatedUnion\u003cP, SubproductNameForProductName\u003cP\u003e\u003e[] = []\r\n subproducts.map((_: DiscriminatedUnion) =\u003e null)\r\n}\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nThe compiler throws an exception:\r\n```\r\n/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:114747\r\n throw e;\r\n ^\r\n\r\nError: Debug Failure. No error for last overload signature\r\n at resolveCall (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:70223:19)\r\n at resolveCallExpression (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:70605:12)\r\n at resolveSignature (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:70988:16)\r\n at getResolvedSignature (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:71008:18)\r\n at checkCallExpression (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:71120:23)\r\n at checkExpressionWorker (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:74278:16)\r\n at checkExpression (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:74189:32)\r\n at maybeCheckExpression (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:73280:28)\r\n at BinaryExpressionStateMachine.onLeft (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:73216:16)\r\n at Array.left (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:25140:30)\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\nNo compiler exception.\r\n","author":{"url":"https://github.com/Oblosys","@type":"Person","name":"Oblosys"},"datePublished":"2023-07-31T16:50:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/55217/TypeScript/issues/55217"}
| 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:89bd0a95-0d9f-41d7-5251-ca010d3d381a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA7E:90030:4CCB5C:6FD5F7:6A61EB71 |
| html-safe-nonce | fa59d422c04b62cb3070bf017d4e425252bc8e774ba7346e36a101d171af57b2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTdFOjkwMDMwOjRDQ0I1Qzo2RkQ1Rjc6NkE2MUVCNzEiLCJ2aXNpdG9yX2lkIjoiMzU4MjE4MTcxOTQxMDg2Mjk2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 96ef24542c1dfa8c2fdd30a06abc7fb1960b70a98f0a252ca1033371960c1ecb |
| hovercard-subject-tag | issue:1829651562 |
| 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/55217/issue_layout |
| twitter:image | https://opengraph.githubassets.com/45205611f0c9250429c62deecca111dc83d2f4a9f5adb9454d7f1e4905e2afb5/microsoft/TypeScript/issues/55217 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/45205611f0c9250429c62deecca111dc83d2f4a9f5adb9454d7f1e4905e2afb5/microsoft/TypeScript/issues/55217 |
| og:image:alt | Bug Report 🔎 Search Terms "No error for last overload signature" yields stale issue 35186, and a couple of more recent issues that got resolved: 48636, 37974. (The stale 35186 appears to be a diffe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Oblosys |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5dd1217fff37e297563b9d318ee02bf6378c8957c6195b77786bb8896fc9c95d |
| 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 | 554667f6dda2a53c83687de64fabc457970f0f04 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width