Fix jest extension (#1106)

This commit is contained in:
강동윤 2020-09-24 19:49:12 +09:00 committed by GitHub
parent ab8df21797
commit 1f00d9ba26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 3 deletions

View File

@ -46,7 +46,7 @@ impl Jest {
computed: false, ..
},
) => match &callee.obj {
ExprOrSuper::Super(_) => {}
ExprOrSuper::Super(_) => new.push(T::from_stmt(stmt)),
ExprOrSuper::Expr(callee_obj) => match &**callee_obj {
Expr::Ident(i) if i.sym == *"jest" => match &*callee.prop {
Expr::Ident(prop) if HOIST_METHODS.contains(&*prop.sym) => {

View File

@ -18,3 +18,30 @@ it("should hoist methods", () => {
console.log(\"Hello\");
console.log(\"World\");`);
});
it("should preserve calls", () => {
const src = `class Foo {
method() {
super.foo()
}
}`;
expect(
swc.transformSync(src, {
jsc: {
transform: {
hidden: {
jest: true
}
},
target: 'es2019'
}
})
.code.trim()
).toBe(`class Foo {
method() {
super.foo();
}
}`);
});

View File

@ -1,6 +1,6 @@
{
"name": "@swc/core",
"version": "1.2.33",
"version": "1.2.34",
"description": "Super-fast alternative for babel",
"homepage": "https://swc.rs",
"main": "./index.js",

View File

@ -5,7 +5,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "wasm"
repository = "https://github.com/swc-project/swc.git"
version = "1.2.32"
version = "1.2.34"
[lib]
crate-type = ["cdylib"]