Skip to content

isConstTypeVariable stack overflow #54610

Closed

Description

@arcanis

Bug Report

🔎 Search Terms

isConstTypeVariable

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions 5.0 and 5.1.3

I suspect it's related to the changes in #53341 (cc Anders Hejlsberg (@ahejlsberg))

⏯ Playground Link

I trimmed our product code to obtain a minimal repro. This code doesn't make sense and doesn't preserve the semantic of what the original code does (B was originally an helper retrieving an union of all possible paths for an object), but it's much shorter and still reproduces the stack overflow.

Playground link with relevant code

💻 Code

type A<T> = T;

type B<T> = T extends any[]
    ? never
    : A<T> extends infer key
    ? key extends keyof T
        ? B<T[key]>
        : never
    : never;

function foo<T>() {
    `${a}` as B<T>;
}

🙁 Actual behavior

Stack overflow

🙂 Expected behavior

Shouldn't stack overflow (various errors should be reported, but not a stack overflow).

Activity

  1. added
    Bug
    Crash
    Recent Regression
    on Jun 12, 2023
  2. added
    Fix Available
    on Jun 12, 2023
  3. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugCrashFix AvailableRecent Regression

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions