Skip to content

isConstTypeVariable stack overflowΒ #54610

Closed
@arcanis

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 @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).

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issueRecent RegressionThis is a new regression just found in the last major/minor version of TypeScript.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions