You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling test(undefined, "foo") executes without an error.
Actual behavior:
Runtime error ReferenceError: _b is not defined.
The helper variables _a and _b are declared inside the function body, but parameter initializers cannot reference declarations in the function body. I guess this could be fixed by wrapping the emit of the class expression in an IIFE.
The example is invalid in ES2015 and up as each parameter initializer essentially gets its own lexical scope and cannot reference other parameters or variables in the body. At some point we added an error to this effect:
TypeScript Version: 3.2.1
Search Terms:
Code
Expected behavior:
Calling
test(undefined, "foo")
executes without an error.Actual behavior:
Runtime error
ReferenceError: _b is not defined
.The helper variables
_a
and_b
are declared inside the function body, but parameter initializers cannot reference declarations in the function body. I guess this could be fixed by wrapping the emit of the class expression in an IIFE.Note: The same code downleveled to ES5 works as expected as the parameter initializer is emitted inside the function body.
Playground Link: https://agentcooper.github.io/typescript-play/?target=2#code/GYVwdgxgLglg9mABFApgZygCgFCL4gD0QF5EIAbAQzTUQG9d8mBtATwF0TEBGRvAXwA0fRKwBciAOTA4cScICU9ftiA
Related Issues:
The text was updated successfully, but these errors were encountered: