-
-
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 noop = (val) => val;
let hasX;
@noop
class Foo {
static {
hasX = o => #x in o;
}
#x;
}
console.log(hasX(new Foo));Configuration file name
No response
Configuration
{
"plugins": [["@babel/plugin-proposal-decorator", { "version": "2023-05" }]]
}Current and expected behavior
Actual: The output code throws syntax error: "Private field '#x' must be declared in an enclosing class".
Expected: It prints true.
Environment
REPL
Possible solution
This is an inherent limit of our current "class separation" approach, where we move non-static elements into a new class. It does ensure that class brand check is still working when defined in the static element, but the instance brand check is broken as the private element is defined in the inner class.
Since a class decorator can mutate the class this value, we might have to partially transform every features involved with class this: private accesses, private brand checks, and all this expresssions and class bindings.
Additional context
No response
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