microsoft / microsoft/TypeScript

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

Ouverte
#63,376 5 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Fixed
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
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
import type { RouterLocation, WebComponentInterface } from "@vaadin/router";

type RouteExt = { section?: string };

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par le Playground lié et comparez TypeScript 5.9.3 à 6.0.2 avec --extendedDiagnostics, en vous concentrant sur la déclaration implements et la propriété concrète RouterLocation. Suivez le chemin d’instanciation des types responsable de TS2589 et validez le résultat par rapport à la reproduction fournie ; le travail est terminé lorsque l’exemple ne signale plus l’erreur ou fournit des indications plus exploitables.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
compilers
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.