Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Apr 14, 2024
1 parent 3fc78e5 commit 30c8a25
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ function handleClassTDZ(
const classFieldDefinitionEvaluationTDZVisitor: Visitor<HandleClassTDZState> = {
ReferencedIdentifier: handleClassTDZ,
Function(path) {
path.skip();
const { parentPath } = path;
if (
!(parentPath.isCallExpression() && parentPath.node.callee === path.node)
) {
path.skip();
}
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
expect(() => {
class A {
static x = 42;
static [(() => A.x)()];
}
}).toThrow(ReferenceError);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
expect(() => {
class A {
static x = 42;
static [(() => A.x)()];
}
}).toThrow(ReferenceError);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["transform-class-properties", "transform-classes"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
expect(() => {
let _ref;
_ref = (() => (babelHelpers.classNameTDZError("A"), A).x)();
let A = /*#__PURE__*/babelHelpers.createClass(function A() {
"use strict";

babelHelpers.classCallCheck(this, A);
});
babelHelpers.defineProperty(A, "x", 42);
babelHelpers.defineProperty(A, _ref, void 0);
}).toThrow(ReferenceError);

0 comments on commit 30c8a25

Please sign in to comment.