Skip to content

Commit

Permalink
support private name in decorator member expr
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jun 14, 2022
1 parent f8785e9 commit 743b3f0
Show file tree
Hide file tree
Showing 5 changed files with 600 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/babel-parser/src/parser/statement.js
Expand Up @@ -552,7 +552,15 @@ export default class StatementParser extends ExpressionParser {
while (this.eat(tt.dot)) {
const node = this.startNodeAt(startPos, startLoc);
node.object = expr;
node.property = this.parseIdentifier(true);
if (this.match(tt.privateName)) {
this.classScope.usePrivateName(
this.state.value,
this.state.startLoc,
);
node.property = this.parsePrivateName();
} else {
node.property = this.parseIdentifier(true);
}
node.computed = false;
expr = this.finishNode(node, "MemberExpression");
}
Expand Down
@@ -0,0 +1,11 @@
class C {
static decFactory = () => () => {}
static #decFactory = () => () => {}
static dec = C.decFactory();
static #dec = C.#decFactory();
static self = C;
static #self = C;
@C.#dec @C.self.#dec @C.#self.dec @C.#self.#dec
@C.#decFactory() @C.self.#decFactory() @C.#self.decFactory() @C.#self.#decFactory()
m() {}
}

0 comments on commit 743b3f0

Please sign in to comment.