-
Notifications
You must be signed in to change notification settings - Fork 620
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
Optimization error with TypeScript const Array #1375
Comments
Interestingly, the Jest test snapshots the view from App.tsx and when it calls it the log shows correctly when you run npm test. ` [TEST_ARRAY_VALUES] js array 1: 1,2,3,4,5,6,7
console.log
console.log
` |
Also note, if you just use tsc to transpile to JS it doesn't have this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you want to request a feature or report a bug?
BUG
What is the current behavior?
When generating a bundle, with or without minification, there is an error in the optimized code generated for the bundle after modifying the elements within the array and logging them.
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can
yarn install
andyarn test
.To reproduce:
Use the default TypeScript app created with:
npx @react-native-community/cli@latest init MyApp
Modify MyApp/App.tsx to insert this code just prior to the return statement:
Build a bundle for Android with:
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output index.android.bundle
In the index.android.bundle file search for TEST_ARRAY_VALUES to find the generated code.
I am seeing:
This is incorrect because the actual contents of the array changed in the for loop.
What is the expected behavior?
After increasing the value of each element in the array by 6000, the current values should be used.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
metro.config.js
Metro is bundled with "react-native": "0.75.4".
"metro-runtime": "^0.80.3",
"metro-source-map": "^0.80.3",
node --version
v18.20.3
npm --version
10.7.0
Mac OS 14.6.1
The text was updated successfully, but these errors were encountered: