Skip to content

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

@julienw

Description

@julienw

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions