-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
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 before v5.0.4.)
🕗 Version & Regression Information
- This is a crash
- This changed between versions 4.9.5 and 5.0.4, and still occurs up to typescript@next.
⏯ Playground Link
Bug-workbench link with relevant code
💻 Code
// @filename: types.ts
export type ProductName = 'a' | 'b'
export type SubproductNameForProductName<P extends ProductName> = P extends unknown
? keyof EntitiesByProductName[P]
: never
type EntitiesByProductName = {
a: { a1: { value: 'a-a1' } }
b: { b1: { value: 'b-b1' } }
}
export type DiscriminatedUnion<
P extends ProductName = ProductName,
E extends SubproductNameForProductName<P> = SubproductNameForProductName<P>,
> = P extends ProductName
? E extends SubproductNameForProductName<P>
// ? E extends unknown // With unknown, the exception doesn't happen.
? EntitiesByProductName[P][E]
: never
: never
// @filename: app.ts
import { SubproductNameForProductName, DiscriminatedUnion, ProductName } from './types'
export const bug = <P extends ProductName>() => {
const subproducts: DiscriminatedUnion<P, SubproductNameForProductName<P>>[] = []
subproducts.map((_: DiscriminatedUnion) => null)
}
🙁 Actual behavior
The compiler throws an exception:
/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:114747
throw e;
^
Error: Debug Failure. No error for last overload signature
at resolveCall (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:70223:19)
at resolveCallExpression (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:70605:12)
at resolveSignature (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:70988:16)
at getResolvedSignature (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:71008:18)
at checkCallExpression (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:71120:23)
at checkExpressionWorker (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:74278:16)
at checkExpression (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:74189:32)
at maybeCheckExpression (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:73280:28)
at BinaryExpressionStateMachine.onLeft (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:73216:16)
at Array.left (/Users/martijn/git/Insify/insify-core/node_modules/typescript/lib/tsc.js:25140:30)
🙂 Expected behavior
No compiler exception.
RyanCavanaugh and atnnn-pylon
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone