Skip to content

Commit 6a48be4

Browse files
authoredFeb 5, 2024
fix(es/quote): Allow variables typed AssignTarget (#8602)
**Description:** This is required to fix vercel/turborepo#7272 **Related issue:** - vercel/turborepo#7272
1 parent 5fe45db commit 6a48be4

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
 

‎crates/swc_ecma_quote/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mod clone;
1717
///
1818
/// - `Expr`
1919
/// - `Pat`
20+
/// - `AssignTarget`
2021
/// - `Stmt`
2122
/// - `ModuleItem`
2223
///

‎crates/swc_ecma_quote_macros/src/ctxt.rs

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub enum VarPos {
2424
Ident,
2525
Expr,
2626
Pat,
27+
AssignTarget,
2728
Str,
2829
}
2930

@@ -138,6 +139,7 @@ pub(super) fn prepare_vars(
138139
VarPos::Ident => "Ident",
139140
VarPos::Expr => "Expr",
140141
VarPos::Pat => "Pat",
142+
VarPos::AssignTarget => "AssignTarget",
141143
VarPos::Str => "Str",
142144
},
143145
call_site(),

‎crates/swc_ecma_quote_macros/src/ret_type.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::any::type_name;
22

33
use anyhow::{anyhow, bail, Context, Error};
44
use swc_common::{sync::Lrc, FileName, SourceMap};
5-
use swc_ecma_ast::EsVersion;
5+
use swc_ecma_ast::{AssignTarget, EsVersion};
66
use swc_ecma_parser::{lexer::Lexer, PResult, Parser, StringInput};
77
use syn::{GenericArgument, PathArguments, Type};
88

@@ -39,6 +39,12 @@ pub(crate) fn parse_input_type(input_str: &str, ty: &Type) -> Result<BoxWrapper,
3939
"Expr" => return parse(input_str, &mut |p| p.parse_expr().map(|v| *v)),
4040
"Pat" => return parse(input_str, &mut |p| p.parse_pat()),
4141
"Stmt" => return parse(input_str, &mut |p| p.parse_stmt_list_item(true)),
42+
"AssignTarget" => {
43+
return parse(input_str, &mut |p| {
44+
Ok(AssignTarget::try_from(p.parse_pat()?)
45+
.expect("failed to parse AssignTarget"))
46+
})
47+
}
4248
"ModuleItem" => return parse(input_str, &mut |p| p.parse_module_item()),
4349
_ => {}
4450
}

0 commit comments

Comments
 (0)
Please sign in to comment.