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
4.9.3 commonjs output regression: Dynamical path import()s inside sync for-of are all called with the same parameter #51554
Comments
Change-type: patch See: microsoft/TypeScript#51554
Change-type: patch See: microsoft/TypeScript#51554
Change-type: patch See: microsoft/TypeScript#51554
Change-type: patch See: microsoft/TypeScript#51554
This is caused by #49663 Maybe it's better to emit |
Problem is that that introduces an additional event loop tick vs. a native dynamic import, which might be observable at runtime and is probably a spec violation. Seems like the issue is that it's putting the temp variable in the outer scope for some reason. It would be better to emit a |
@fatcerberus We currently emit
(Next bullet talks about no double evaluation, not how My proposal is also exactly how |
Just ran into the same issue, this is a massive bummer for ts4.9! And quite hard to find. |
Bug Report
🔎 Search Terms
4.9, compiler regression, for-of, import(), commonJS
🕗 Version & Regression Information
Works fine in 4.8.4 & 4.9.1-beta.
First saw this in the 4.9.2-rc & 4.9.3 and still exists in the current nightly 5.0.0-dev.20221116.
Please keep and fill in the line that best applies:
-->
⏯ Playground Link
v4.9.3 commonjs output with the issue
Properly working v4.8.4 commonjs output
💻 Code
Compiling the following while targeting es2022 w/ commonjs output.
PS: The actual code I'm using is storing the resulting promises, but didn't include it in the minimum reproduction code since it didn't make any difference.
🙁 Actual behavior
It imports file
3.json
three times, b/c of a newvar a_
outside the for-of scope is created and re-used across iterations.🙂 Expected behavior
It should import files 1.json, 2.json & 3.json, just like up to 4.9.1-beta.
The text was updated successfully, but these errors were encountered: