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

[Compiler Bug]: TypeError: Cannot read properties of undefined (reading 'length') #31205

Open
1 of 4 tasks
kireerik opened this issue Oct 11, 2024 · 1 comment
Open
1 of 4 tasks
Labels
Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@kireerik
Copy link

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhHCA7MAXABAYQgFsAHTBDPAXlwApgSYISEZsBPAXwEpcqA+ADoZcuADwATAJYA3XI2asOVYLV4D5TFm3YA6ADYUA5tgAWnAPT8QnIA

Repro steps

  1. render the component

We do not call the property function named property, but the error occurs regardless (when the component is rendered).

other versions:
babel-plugin-react-compiler: experimental
react-compiler-runtime-polyfill: 0.x

How often does this bug happen?

Every time

What version of React are you using?

18.x

@kireerik kireerik added Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels Oct 11, 2024
@josephsavona
Copy link
Contributor

josephsavona commented Oct 11, 2024

@kireerik Thanks for filing this! The compiler currently assumes that the code is using a type system such as TypeScript or Flow, which both require checks to access possibly nullable data. For example, TypeScript and Flow would error on the example if property was nullable, and require using something like property?.length or using an if (property != null) { ... } guard.

But we know that not everyone is using a type system, so we're also looking at options for inferring more conservative dependencies if a type system isn't being used. We've implemented this behind a feature flag, but we don't want to have to make users mess with complex configurations, so we're iterating on how to choose the right default automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants