mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
fix(es/parser): Allow as
in destructuring assignment (#5948)
This commit is contained in:
parent
e5ba9636ac
commit
cdd69d0145
@ -510,6 +510,15 @@ fn issue_3672_2() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_5947() {
|
||||
test_parser(
|
||||
"[a as number, b as number, c as string] = [1, 2, '3']",
|
||||
Syntax::Typescript(Default::default()),
|
||||
|p| p.parse_module(),
|
||||
);
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_new_expr_ts(b: &mut Bencher) {
|
||||
bench_parser(
|
||||
|
@ -566,7 +566,8 @@ impl<I: Tokens> Parser<I> {
|
||||
| Expr::Fn(..)
|
||||
| Expr::Class(..)
|
||||
| Expr::Paren(..)
|
||||
| Expr::Tpl(..) => {
|
||||
| Expr::Tpl(..)
|
||||
| Expr::TsAs(..) => {
|
||||
if !expr.is_valid_simple_assignment_target(self.ctx().strict) {
|
||||
self.emit_err(span, SyntaxError::NotSimpleAssign)
|
||||
}
|
||||
|
@ -0,0 +1,2 @@
|
||||
let a, b;
|
||||
[a as number, b as number] = [1, 2];
|
@ -0,0 +1,2 @@
|
||||
let a, b;
|
||||
[a, b] = [1, 2];
|
Loading…
Reference in New Issue
Block a user