Skip to content

Crash on 5.4.0-dev.20231206 #56688

Closed

Description

🔎 Search Terms

🕗 Version & Regression Information

It's working on 5.3
Here is the stacktrace, I hope it helps, I don't really have time to disect which part my codebase triggers this. Feel free to close if this not enough to understand the regression

TypeError: Cannot read properties of undefined (reading '0')
   at removeConstrainedTypeVariables (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:57118:33)
   at getUnionTypeWorker (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:57215:9)
   at getUnionType (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:57194:12)
   at createJsxAttributesTypeFromAttributesProperty (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:69288:216)
   at checkJsxAttributes (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:69353:12)
   at checkExpressionWorker (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:75700:16)
   at checkExpression (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:75557:32)
   at checkExpressionWithContextualType (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:75203:18)
   at resolveJsxOpeningLikeElement (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:72230:51)
   at resolveSignature (/Users/arnaud/git/carbon-calculator/node_modules/typescript/lib/tsc.js:72303:16)

⏯ Playground Link

No response

💻 Code

No response

🙁 Actual behavior

Crash

🙂 Expected behavior

No crash

Additional information about the issue

No response

Activity

  1. Andarist commented on Dec 6, 2023

    @Andarist
    Contributor

    Does it crash on 5.4.0-dev.20231206 too?

  2. ArnaudBarre commented on Dec 6, 2023

    @ArnaudBarre
    Author

    It crashes on 20231206 and 20231205, not on 5.3.2. Didn't try other versions

  3. Andarist commented on Dec 6, 2023

    @Andarist
    Contributor

    removeConstrainedTypeVariables was introduced in #56515 . Could you confirm that 5.4.0-dev.20231130 works OK but 5.4.0-dev.20231201 is broken? Even with that confirmation - it might be hard to fix this without a repro case. If you'd be interested I could try to guide you on how to at least narrow it down to the file in which the problem occurs. With that information, you'd have an easier time dissecting this to a minimal repro case.

  4. ArnaudBarre commented on Dec 7, 2023

    @ArnaudBarre
    Author

    Ok so yes it crashes starting on 20231201.
    I ran the debugger and found the file, and after few try and errors I think this is this combination:

    // .d.ts
    declare global {
      interface String {
        upperFirst<T extends string>(this: T): Capitalize<T>;
      }
    }
    
    // display.ts
    const displayEnum = (value: string) => value.toLowerCase().upperFirst();
    
    // Component.tsx
    <>{displayEnum("VALUE")}</> 
    
  5. jakebailey commented on Dec 8, 2023

    @jakebailey
    Member

    It's in the template, but you can also use https://www.npmjs.com/package/every-ts to narrow it down further.

    I can't get your case to crash in the test suite, unfortunately.

  6. ArnaudBarre commented on Dec 8, 2023

    @ArnaudBarre
    Author

    Ok this is the missing piece, the span before is strangely required:
    Here is my mininal repro, I don't think my TS config should have an impact on the crash

    declare global {
      interface String {
        upperFirst<T extends string>(this: T): Capitalize<T>;
      }
    }
    
    const displayEnum = (value: string) => value.toLowerCase().upperFirst();
    
    console.log(
      <div>
        <span>Scope:</span> {displayEnum("VALUE")}
      </div>,
    );
    
    export {};
    
  7. 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

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions