mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 13:51:19 +03:00
Remove empty expression in expression statement with top level await (#630)
Eats the semi-colon. This doesn't compile (edit: doesn't compile the code in the tests) though because the target of that folder is ES2015. Also, this is kind of strange for me to put the tests in the "typescript" folder. Should we create something more general? You can take over this PR if you'd like!
This commit is contained in:
parent
26eb4e3206
commit
55c0258017
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "swc_ecma_parser"
|
name = "swc_ecma_parser"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||||
license = "Apache-2.0/MIT"
|
license = "Apache-2.0/MIT"
|
||||||
repository = "https://github.com/swc-project/swc.git"
|
repository = "https://github.com/swc-project/swc.git"
|
||||||
|
@ -100,6 +100,7 @@ impl<'a, I: Tokens> Parser<'a, I> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let expr = self.parse_await_expr()?;
|
let expr = self.parse_await_expr()?;
|
||||||
|
eat!(';');
|
||||||
|
|
||||||
let span = span!(start);
|
let span = span!(start);
|
||||||
return Ok(Stmt::Expr(ExprStmt { span, expr }));
|
return Ok(Stmt::Expr(ExprStmt { span, expr }));
|
||||||
|
@ -352,3 +352,12 @@ fn issue_605() {
|
|||||||
|
|
||||||
assert!(f.contains("Object.keys(_c)"));
|
assert!(f.contains("Object.keys(_c)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn await_expr() {
|
||||||
|
let f = file("tests/projects/await-expression/input.js").unwrap();
|
||||||
|
println!("{}", f);
|
||||||
|
|
||||||
|
assert!(f.contains("await"));
|
||||||
|
assert!(f.contains("test"));
|
||||||
|
}
|
||||||
|
9
tests/projects/await-expression/.swcrc
Normal file
9
tests/projects/await-expression/.swcrc
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"jsc": {
|
||||||
|
"target": "es2017",
|
||||||
|
"parser": {
|
||||||
|
"syntax": "ecmascript",
|
||||||
|
"topLevelAwait": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
tests/projects/await-expression/input.js
Normal file
1
tests/projects/await-expression/input.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
await test ;
|
Loading…
Reference in New Issue
Block a user