mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 15:12:08 +03:00
fix(es/quote): Allow variables typed AssignTarget
(#8602)
**Description:** This is required to fix https://github.com/vercel/turbo/pull/7272 **Related issue:** - https://github.com/vercel/turbo/pull/7272
This commit is contained in:
parent
5fe45dbc44
commit
6a48be4b6b
@ -17,6 +17,7 @@ mod clone;
|
|||||||
///
|
///
|
||||||
/// - `Expr`
|
/// - `Expr`
|
||||||
/// - `Pat`
|
/// - `Pat`
|
||||||
|
/// - `AssignTarget`
|
||||||
/// - `Stmt`
|
/// - `Stmt`
|
||||||
/// - `ModuleItem`
|
/// - `ModuleItem`
|
||||||
///
|
///
|
||||||
|
@ -24,6 +24,7 @@ pub enum VarPos {
|
|||||||
Ident,
|
Ident,
|
||||||
Expr,
|
Expr,
|
||||||
Pat,
|
Pat,
|
||||||
|
AssignTarget,
|
||||||
Str,
|
Str,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +139,7 @@ pub(super) fn prepare_vars(
|
|||||||
VarPos::Ident => "Ident",
|
VarPos::Ident => "Ident",
|
||||||
VarPos::Expr => "Expr",
|
VarPos::Expr => "Expr",
|
||||||
VarPos::Pat => "Pat",
|
VarPos::Pat => "Pat",
|
||||||
|
VarPos::AssignTarget => "AssignTarget",
|
||||||
VarPos::Str => "Str",
|
VarPos::Str => "Str",
|
||||||
},
|
},
|
||||||
call_site(),
|
call_site(),
|
||||||
|
@ -2,7 +2,7 @@ use std::any::type_name;
|
|||||||
|
|
||||||
use anyhow::{anyhow, bail, Context, Error};
|
use anyhow::{anyhow, bail, Context, Error};
|
||||||
use swc_common::{sync::Lrc, FileName, SourceMap};
|
use swc_common::{sync::Lrc, FileName, SourceMap};
|
||||||
use swc_ecma_ast::EsVersion;
|
use swc_ecma_ast::{AssignTarget, EsVersion};
|
||||||
use swc_ecma_parser::{lexer::Lexer, PResult, Parser, StringInput};
|
use swc_ecma_parser::{lexer::Lexer, PResult, Parser, StringInput};
|
||||||
use syn::{GenericArgument, PathArguments, Type};
|
use syn::{GenericArgument, PathArguments, Type};
|
||||||
|
|
||||||
@ -39,6 +39,12 @@ pub(crate) fn parse_input_type(input_str: &str, ty: &Type) -> Result<BoxWrapper,
|
|||||||
"Expr" => return parse(input_str, &mut |p| p.parse_expr().map(|v| *v)),
|
"Expr" => return parse(input_str, &mut |p| p.parse_expr().map(|v| *v)),
|
||||||
"Pat" => return parse(input_str, &mut |p| p.parse_pat()),
|
"Pat" => return parse(input_str, &mut |p| p.parse_pat()),
|
||||||
"Stmt" => return parse(input_str, &mut |p| p.parse_stmt_list_item(true)),
|
"Stmt" => return parse(input_str, &mut |p| p.parse_stmt_list_item(true)),
|
||||||
|
"AssignTarget" => {
|
||||||
|
return parse(input_str, &mut |p| {
|
||||||
|
Ok(AssignTarget::try_from(p.parse_pat()?)
|
||||||
|
.expect("failed to parse AssignTarget"))
|
||||||
|
})
|
||||||
|
}
|
||||||
"ModuleItem" => return parse(input_str, &mut |p| p.parse_module_item()),
|
"ModuleItem" => return parse(input_str, &mut |p| p.parse_module_item()),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user