fix(es/transforms/base): Fix resolver (#1666)

swc_ecma_transforms_base:
 - `resolver`: Handle function declarations in arrow body.
This commit is contained in:
강동윤 2021-05-09 18:52:29 +09:00 committed by GitHub
parent aea08fb8c9
commit 9585500476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 5 deletions

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_base"
repository = "https://github.com/swc-project/swc.git"
version = "0.12.13"
version = "0.12.14"
[dependencies]
fxhash = "0.2.1"

View File

@ -419,7 +419,14 @@ impl<'a> VisitMut for Resolver<'a> {
folder.ident_type = old;
folder.hoist = old_hoist;
e.body.visit_mut_with(&mut folder);
{
folder.hoist = false;
match &mut e.body {
BlockStmtOrExpr::BlockStmt(s) => s.stmts.visit_mut_with(&mut folder),
BlockStmtOrExpr::Expr(e) => e.visit_mut_with(&mut folder),
}
}
e.return_type.visit_mut_with(&mut folder);
}

View File

@ -2796,3 +2796,44 @@ to_ts!(
}
"
);
to_ts!(
ts_type_parameter_used_as_type_parameter_contraint_01,
"
var f3 = <T, U extends T>(x: T, y: U) => {
function bar<V extends T, W extends U>() {
var g = <X extends W, Y extends V>(a: X, b: Y): T => {
x = y;
return y;
}
}
}
var f4 = <U extends T, T>(x: T, y: U) => {
function bar<V extends T, W extends U>() {
var g = <X extends W, Y extends V>(a: X, b: Y): T => {
x = y;
return y;
}
}
}
",
"
var f3 = <T__2, U__2 extends T__2>(x__2: T__2, y__2: U__2)=>{
function bar__2<V__3 extends T__2, W__3 extends U__2>() {
var g__3 = <X__4 extends W__3, Y__4 extends V__3>(a__4: X__4, b__4: Y__4)=>{
x__2 = y__2;
return y__2;
};
}
};
var f4 = <U__5 extends T__5, T__5>(x__5: T__5, y__5: U__5)=>{
function bar__5<V__6 extends T__5, W__6 extends U__5>() {
var g__6 = <X__7 extends W__6, Y__7 extends V__6>(a__7: X__7, b__7: Y__7)=>{
x__5 = y__5;
return y__5;
};
}
};
"
);

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_compat"
repository = "https://github.com/swc-project/swc.git"
version = "0.14.1"
version = "0.14.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -1,6 +1,6 @@
{
"name": "@swc/core",
"version": "1.2.55",
"version": "1.2.57",
"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.55"
version = "1.2.57"
[lib]
crate-type = ["cdylib"]