-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
Spec: DecoratorsoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
{
const errs = [];
const fns = [];
const captureAndAssertUninitialized = function (fn) {
fns.push(fn);
try {
fn();
} catch (err) {
errs.push(err);
} finally {
return v => v;
}
}
@captureAndAssertUninitialized(() => C)
class C {
@captureAndAssertUninitialized(() => C) [captureAndAssertUninitialized(() => C)]
}
console.log(errs, fns.map(fn => fn()));
C = null;
console.log(fns.map(fn => fn()));
}Configuration file name
No response
Configuration
{
"plugins": [["proposal-decorators", { "version": "2023-11" }]]
}Current and expected behavior
Current:
The first console.log prints [ReferenceError], [C, C, C], the second console.log prints [null, null, null].
Expected:
The first console.log should print [ReferenceError, ReferenceError, ReferenceError], [C, C, C],
because decorators and computed keys are evaluated before the class binding is bound.
The second console.log should print [null, C, C], because C within the class decorators points to the mutable binding created in BindingClassDeclarationEvaluation, while C in the element decorators and computed keys point to the internal immutable class binding.
Environment
REPL
Possible solution
No response
Additional context
This is the point 6 of #16117.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Spec: DecoratorsoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue