Skip to content

Commit

Permalink
Require fields transform for class with private fields (#16135)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Nov 28, 2023
1 parent c100223 commit a31c4b9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default function transformClass(
for (const path of classBodyPaths) {
const node = path.node;

if (path.isClassProperty()) {
if (path.isClassProperty() || path.isClassPrivateProperty()) {
throw path.buildCodeFrameError("Missing class properties transform.");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Test {
#key = '';

method() {
return this.#key;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["transform-classes"],
"throws": "Missing class properties transform."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Test {
key = '';

method() {
return this.key;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["transform-classes"],
"throws": "Missing class properties transform."
}

0 comments on commit a31c4b9

Please sign in to comment.