Repository: TypeScript
Issue: Debug Failure. No error for last overload signature
Labels: Bug

### 🔎 Search Terms

Debug Failure. No error for last overload signature

possibly related to
* https://github.com/microsoft/TypeScript/issues/60202
* https://github.com/microsoft/TypeScript/issues/55217

### 🕗 Version & Regression Information

- This is the behavior in every version I tried, from 4.5.5 on through 5.7.0-dev.20241014. In 4.4 there's a different error, `RangeError: Maximum call stack size exceeded`.


### ⏯ Playground Link

[Playground link](https://www.typescriptlang.org/play/?ts=5.7.0-beta#code/PTAEDEEsCcGcBdQGMD2AHAnqFAzUBDUAG0gCNp9oMAoeDNAU1AGEUBbNFAOwa-gBEGOSF0jxI3AKIAPTtHiwAPABUAfKAC81UKGWgG0+LwAmsFu048+g4aPHdFInA2igZcheoD8b2SnlmAFygPABuLgDc1NRIRPiwZgCSXAj4REQMxqwc3LzwijYiYhJc+oYmZtmWeYV2JYr4XBiq6gDe2qAA5gyIBh6wABQAlMFVudZCRfZc7v4KBZN13G0dOtA9AK7QpVwb6QRmjRhROgC+1Oe09ExjVgKLxQ4A+rMB6hqg7TobsAwLto9SgYjFxTOYcndaoCGk0WgNVqBjA9psEodMOiNQMlUulMrc8v8piVVFFTlFqDgNlwkNNEYsGPi+MNRhZxvcAdMYc1Ph11vAtjs9kQDgQmiLGeyiQ4jiSLtFUClEPhOp11p18EZNHTbAzWXdhuSQFi2MqRExGih4AALFzIdBYXCga1MEjkSg0K6McHVCYckqvBQAJhU7w6emBFW9bLRJWDTltAdg3l8-VAwTCkXlcQSWMVaQyWT1eWDMe4ZRBYIlpa4wZlKx03V6fgCzKjkOR-ubQcJSy49Z0oD5ApCQpFRxOoHOlzoXqrHe4wZeXaTWq+oB+f2r5cjc79C65cIRSL3XFR864GOC2Pg+bxRb4JfPsrJ0T6cyd11AAEE0Ghq4HVw6Dce0BbdQUqe9JV7WtYVUeEB21KVT1AatL1zHECwlR8T2fck33kUBKWpWljzNH80EDVtyP-Hk1k2bYR32eJRWOOUYm4BACF-LVSJ4cjKKGKJ8F-AA6DcBmVVUGHVIxBOoIA)

### 💻 Code

```ts
// First copy of a library
type ComponentDefinitionExports<T> =
  T extends ComponentDefinition<infer Exports> ? Exports : never;

class InstalledComponent<Definition extends ComponentDefinition<any>> {
  get exports(): ComponentDefinitionExports<Definition> {
    return null as any;
  }
}

type ComponentDefinition<_Exports> = {
  use<Definition extends ComponentDefinition<any>>(
    definition: Definition
  ): InstalledComponent<Definition>;
};

function defineComponent(): ComponentDefinition<any> {
  return null as any as ComponentDefinition<any>;
}

const aggregate = defineComponent();

// Imagine another copy of the library

type ComponentDefinitionExports2<T> =
  T extends ComponentDefinition2<infer Exports> ? Exports : never;

class InstalledComponent2<Definition extends ComponentDefinition2<any>> {
  get exports(): ComponentDefinitionExports2<Definition> {
    return null as any;
  }
}

type ComponentDefinition2<_Exports> = {
  use<Definition extends ComponentDefinition2<any>>(
    definition: Definition
  ): InstalledComponent2<Definition>;
};

export type AppDefinition2 = {
  use<Definition extends ComponentDefinition2<any>>(
    definition: Definition
  ): InstalledComponent2<Definition>;
};

export function defineApp2(): AppDefinition2 {
  return null as any;
}

const app = defineApp2();
app.use(aggregate);

```


### 🙁 Actual behavior

tsc exits with error code 1 and write to stderr `Debug Failure. No error for last overload signature`
```
/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:113984
      throw e;
      ^

Error: Debug Failure. No error for last overload signature
    at resolveCall (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:69834:19)
    at resolveCallExpression (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:70216:12)
    at resolveSignature (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:70599:16)
    at getResolvedSignature (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:70619:20)
    at checkCallExpression (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:70728:23)
    at checkExpressionWorker (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:73819:16)
    at checkExpression (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:73729:32)
    at checkExpressionStatement (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:76310:5)
    at checkSourceElementWorker (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:79237:16)
    at checkSourceElement (/Users/tomb/aggregate/node_modules/typescript/lib/tsc.js:79097:7)
```

In the playground,
```
Uncaught (in promise) Error: Debug Failure. No error for last overload signature
    at wR (tsWorker.js:341:318135)
    ...
```

### 🙂 Expected behavior

I'm not sure. I'd like this to pass typechecking.

### Additional information about the issue

I tried to minimize this but I imagine this is not the minimal repro. Please give this a better title :)