Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isConstTypeVariable stack overflow #54610

Closed
arcanis opened this issue Jun 12, 2023 · 0 comments Β· Fixed by #54624
Closed

isConstTypeVariable stack overflow #54610

arcanis opened this issue Jun 12, 2023 · 0 comments Β· Fixed by #54624
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue Recent Regression This is a new regression just found in the last major/minor version of TypeScript.

Comments

@arcanis
Copy link

arcanis commented Jun 12, 2023

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

@ahejlsberg ahejlsberg self-assigned this Jun 12, 2023
@ahejlsberg ahejlsberg added Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Recent Regression This is a new regression just found in the last major/minor version of TypeScript. labels Jun 12, 2023
@ahejlsberg ahejlsberg added this to the TypeScript 5.1.4 milestone Jun 12, 2023
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue Recent Regression This is a new regression just found in the last major/minor version of TypeScript.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants