Skip to content

Commit

Permalink
Merge branch 'fix-jest-e2e' into evaluate-computed-properties
Browse files Browse the repository at this point in the history
  • Loading branch information
JBYoshi committed Jan 2, 2023
2 parents c6b2232 + fd2ff47 commit 3d17772
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/babel-core/package.json
Expand Up @@ -59,7 +59,7 @@
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.2",
"json5": "^2.2.1",
"json5": "^2.2.2",
"semver": "condition:BABEL_8_BREAKING ? ^7.3.4 : ^6.3.0"
},
"devDependencies": {
Expand Down
Expand Up @@ -24,6 +24,7 @@
"@babel/helper-member-expression-to-functions": "workspace:^",
"@babel/helper-optimise-call-expression": "workspace:^",
"@babel/helper-replace-supers": "workspace:^",
"@babel/helper-skip-transparent-expression-wrappers": "workspace:^",
"@babel/helper-split-export-declaration": "workspace:^"
},
"peerDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions packages/babel-helper-create-class-features-plugin/src/fields.ts
Expand Up @@ -10,6 +10,7 @@ import type {
} from "@babel/helper-member-expression-to-functions";
import optimiseCall from "@babel/helper-optimise-call-expression";
import annotateAsPure from "@babel/helper-annotate-as-pure";
import { isTransparentExprWrapper } from "@babel/helper-skip-transparent-expression-wrappers";

import * as ts from "./typescript";

Expand Down Expand Up @@ -890,6 +891,15 @@ type ReplaceThisState = {
const thisContextVisitor = traverse.visitors.merge<ReplaceThisState>([
{
ThisExpression(path, state) {
// Replace `delete this` with `true`
const parent = path.findParent(
path => !isTransparentExprWrapper(path.node),
);
if (t.isUnaryExpression(parent.node, { operator: "delete" })) {
path.parentPath.replaceWith(t.booleanLiteral(true));
return;
}

state.needsClassRef = true;
path.replaceWith(t.cloneNode(state.classRef));
},
Expand Down
@@ -0,0 +1,7 @@
class Foo {
x = delete this;
static x = delete this;
}

expect(new Foo().x).toBe(true);
expect(Foo.x).toBe(true);
@@ -0,0 +1,4 @@
class Foo {
x = delete this;
static x = delete this;
}
@@ -0,0 +1,7 @@
var Foo = /*#__PURE__*/babelHelpers.createClass(function Foo() {
"use strict";

babelHelpers.classCallCheck(this, Foo);
babelHelpers.defineProperty(this, "x", delete this);
});
babelHelpers.defineProperty(Foo, "x", true);
1 change: 0 additions & 1 deletion scripts/integration-tests/e2e-jest.sh
Expand Up @@ -48,7 +48,6 @@ if [ "$BABEL_8_BREAKING" = true ] ; then

# Jest depends on @types/babel__traverse for Babel 7, and they contain the removed Noop node
sed -i 's/t.Noop/any/g' node_modules/@types/babel__traverse/index.d.ts
sed -i 's/t.Noop/any/g' node_modules/@types/babel__traverse/ts4.1/index.d.ts

node -e "
var pkg = require('./package.json');
Expand Down
11 changes: 6 additions & 5 deletions yarn.lock
Expand Up @@ -366,7 +366,7 @@ __metadata:
convert-source-map: ^1.7.0
debug: ^4.1.0
gensync: ^1.0.0-beta.2
json5: ^2.2.1
json5: ^2.2.2
rimraf: ^3.0.0
semver: "condition:BABEL_8_BREAKING ? ^7.3.4 : ^6.3.0"
languageName: unknown
Expand Down Expand Up @@ -591,6 +591,7 @@ __metadata:
"@babel/helper-optimise-call-expression": "workspace:^"
"@babel/helper-plugin-test-runner": "workspace:^"
"@babel/helper-replace-supers": "workspace:^"
"@babel/helper-skip-transparent-expression-wrappers": "workspace:^"
"@babel/helper-split-export-declaration": "workspace:^"
"@babel/plugin-syntax-class-static-block": ^7.14.5
"@babel/preset-env": "workspace:^"
Expand Down Expand Up @@ -10784,12 +10785,12 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"json5@npm:^2.1.2, json5@npm:^2.2.1":
version: 2.2.1
resolution: "json5@npm:2.2.1"
"json5@npm:^2.1.2, json5@npm:^2.2.1, json5@npm:^2.2.2":
version: 2.2.2
resolution: "json5@npm:2.2.2"
bin:
json5: lib/cli.js
checksum: 74b8a23b102a6f2bf2d224797ae553a75488b5adbaee9c9b6e5ab8b510a2fc6e38f876d4c77dea672d4014a44b2399e15f2051ac2b37b87f74c0c7602003543b
checksum: 9a878d66b72157b073cf0017f3e5d93ec209fa5943abcb38d37a54b208917c166bd473c26a24695e67a016ce65759aeb89946592991f8f9174fb96c8e2492683
languageName: node
linkType: hard

Expand Down

0 comments on commit 3d17772

Please sign in to comment.