microsoft / microsoft/TypeScript

TS2589 regression in 6.0: implements without type parameters causes excessive type instantiation when property uses concrete generic type

Open
#63,376 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Fixed
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 Search Terms

Type instantiation is excessively deep and possibly infinite.

### 🕗 Version & Regression Information

- This changed between versions 5.9.3 and 6.0.2

### ⏯ Playground Link

https://www.typescriptlang.org/play/?target=7#code/JYWwDg9gTgLgBDAnmApnA3nAShArjFKAGQgGMBDGYCAOwBo4B1FAIwGEJxaUaYBJXoQBm5UmgC+cIVE5wARAAEAbuXIATYDQD0M-ITkBuAFBGkqbHgIBRAB7wAvBjgBnFKSq0A-AC4XMKJoA5nDixkZaWnAAKgDKAEwArAAcAJxwtAgAFmikADbkzs5wam75UJTUNHAsKLkQAO4AdOGRAGLANr5QKGD5YnAABszsnJA0PPyCUCJiA3D1wDCZg8McXOO8AgTToigAPDh6tjAAfAPNES1wAHIQBL5LaIQyUOk0uYgIAYGBhEU1FFwrkGdQoHhoc2ARTMKDU80Wy3IcFItFI3QICGQKCuYHI5RAKG2cAAFANDtsSGDKgdLChjmcAJSNOAAVWcQUG5MIlIqtDmCyWljgSJhOLx5AJRLUEBQRRody+wB+hDgi2aKBskFgyPyhTgAFlEFZcigCbw4BqCDQ1EUABJRfVEY2miaq8Ams0wIqrUbcTZTGZodBGOBwUG8mg+Cx6YhkCM0o52E7GcRGIA

### 💻 Code

```ts
import type { RouterLocation, WebComponentInterface } from "@vaadin/router";

type RouteExt = { section?: string };

// TS2589 on the class declaration below.
// Fix: replace `WebComponentInterface` with `WebComponentInterface`.
//
// Note: the error only triggers because `location` is typed with a concrete type
// parameter (`RouterLocation`). Using `RouterLocation` without a type
// parameter does not trigger it.
export class MyElement extends HTMLElement implements WebComponentInterface {
location?: RouterLocation;
}
```

### 🙁 Actual behavior

I get this error:
```
Type instantiation is excessively deep and possibly infinite.
```
But the information isn't very useful to know what to do exactly in this case.

### 🙂 Expected behavior

Ideally no error, otherwise some more pointers about how to fix this.

### Additional information about the issue

When running with `--extendedDiagnostics`:

typescript 5.9.3:
```
Files: 259
Types: 203241
Instantiations: 2593860
```

typescript 6.0.2:
```
Files: 259
Types: 217322
Instantiations: 5379836
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Playground and compare TypeScript 5.9.3 with 6.0.2 using --extendedDiagnostics, focusing on the implements declaration and concrete RouterLocation property. Trace the type-instantiation path responsible for TS2589 and validate the result against the provided reproduction; done means the example no longer reports the error or provides more actionable guidance.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.