-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Description
Due to the downleveling of const/let to var, the behavior of the variable declarations change because of Hoisting. This can clash with the generated name of an import:
I have attached a reproduction. Sorry if it feels a bit contrived, but we have ran into this error a few times in our large codebase.
Steps to Reproduce
- Download reproduction
- Run
mvn test - See error thrown during test execution
Preconditions:
- There should be an import that generates a
VROES.importLazy(...) - Define 2 variable names that match the name of an imported file (e.g. import a "Logger" and define 2 variables named "logger" in
ifstatements. - The variables should be inside their own scope (e.g. an action importing an exported function)
Expected behavior: To correctly transpile, without scoping issues
Actual behavior: An error is thrown during execution of the code: TypeError: Cannot read properties of undefined (reading '_')
Reproduces how often: 100%
Component/s: typescript/vrotsc or ecmascript(?)
Affects Build/s: 4.15.0 and below (haven't tested all versions)
Environment
Client
- Build Tools for VMware Aria Version: 4.15.0
Dependencies
✔ Node.js version 22.21.1 is within the required range (22 - 22).
✔ Maven version 3.9.11 meets the minimum requirement (>= 3.9).
✔ Java version 21.0.9 is within the required range (17 - 21).
Failure Logs
[INFO] Installing node modules for the tests completed.
[INFO] Starting unit tests.
[ERROR] Error occurred in unit tests execution: successful run
[ERROR] TypeError: Cannot read properties of undefined (reading '_')
[ERROR] at Object.subAction (C:\Users\johnd\repo\example_codebase\transpilerBugReproduction\target\vro-tests\src\com\example\service\transpilerBugReproduction\mySubAction.js:7:111)
[ERROR] at module.exports (C:\Users\johnd\repo\example_codebase\transpilerBugReproduction\target\vro-tests\src\com\example\service\transpilerBugReproduction\myLargerAction.js:5:594)
[ERROR] at s.<computed> (C:\Users\johnd\repo\example_codebase\transpilerBugReproduction\target\vro-tests\helpers\vro-runtime.js:1:34354)
[ERROR] at UserContext.<anonymous> (C:\Users\johnd\repo\example_codebase\transpilerBugReproduction\target\vro-tests\test\com\example\service\transpilerBugReproduction\tests\myLargerAction.test.js:4:22)
[ERROR] at <Jasmine>
Additional Context
We can prevent (most of) this issue ourselves by enabling the no-shadow rule in typescript-eslint. But other users might still run into this issue without a clear reason why.