From 46540b2a745d6422592e1750705d7cfb4d0f4e64 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 12 Dec 2024 11:47:45 -0500 Subject: [PATCH 01/11] feat: TsImportType - support import attributes --- crates/swc_ecma_ast/src/typescript.rs | 4 +- crates/swc_ecma_codegen/src/typescript.rs | 5 + .../typescript/ts_import_type/input.js | 1 + .../typescript/ts_import_type/output.js | 5 + .../typescript/ts_import_type/output.min.js | 1 + .../swc_ecma_parser/src/parser/typescript.rs | 13 ++ .../tests/typescript/ts-import-type/input.ts | 7 + .../typescript/ts-import-type/input.ts.json | 197 ++++++++++++++++++ crates/swc_ecma_visit/src/generated.rs | 52 +++++ 9 files changed, 284 insertions(+), 1 deletion(-) create mode 100644 crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/input.js create mode 100644 crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/output.js create mode 100644 crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/output.min.js create mode 100644 crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts create mode 100644 crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts.json diff --git a/crates/swc_ecma_ast/src/typescript.rs b/crates/swc_ecma_ast/src/typescript.rs index 534e5eb860c5..434126c1bab1 100644 --- a/crates/swc_ecma_ast/src/typescript.rs +++ b/crates/swc_ecma_ast/src/typescript.rs @@ -16,7 +16,7 @@ use swc_common::{ast_node, EqIgnoreSpan, Span}; use crate::{ class::Decorator, - expr::Expr, + expr::{Expr, ObjectLit}, ident::Ident, lit::{Bool, Number, Str}, module::ModuleItem, @@ -546,6 +546,8 @@ pub struct TsImportType { pub qualifier: Option, #[cfg_attr(feature = "serde-impl", serde(rename = "typeArguments"))] pub type_args: Option>, + #[cfg_attr(feature = "serde-impl", serde(default))] + pub with: Option>, } #[ast_node("TsTypeLiteral")] diff --git a/crates/swc_ecma_codegen/src/typescript.rs b/crates/swc_ecma_codegen/src/typescript.rs index 73f9900d3bf6..77e8e8b1ab4f 100644 --- a/crates/swc_ecma_codegen/src/typescript.rs +++ b/crates/swc_ecma_codegen/src/typescript.rs @@ -845,6 +845,11 @@ where keyword!("import"); punct!("("); emit!(n.arg); + if let Some(with) = &n.with { + punct!(","); + formatting_space!(); + emit!(with); + } punct!(")"); if let Some(n) = &n.qualifier { diff --git a/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/input.js b/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/input.js new file mode 100644 index 000000000000..f3f11a6b1116 --- /dev/null +++ b/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/input.js @@ -0,0 +1 @@ +type Vite = typeof import("vite", { with: { "resolution-mode": "import" } }); diff --git a/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/output.js b/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/output.js new file mode 100644 index 000000000000..f3089eb0e942 --- /dev/null +++ b/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/output.js @@ -0,0 +1,5 @@ +type Vite = typeof import("vite", { + with: { + "resolution-mode": "import" + } +}); diff --git a/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/output.min.js b/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/output.min.js new file mode 100644 index 000000000000..f2d93b6ecfd2 --- /dev/null +++ b/crates/swc_ecma_codegen/tests/fixture/typescript/ts_import_type/output.min.js @@ -0,0 +1 @@ +type Vite=typeof import("vite",{with:{"resolution-mode":"import"}}); diff --git a/crates/swc_ecma_parser/src/parser/typescript.rs b/crates/swc_ecma_parser/src/parser/typescript.rs index 039ae34e777c..3537049d50cc 100644 --- a/crates/swc_ecma_parser/src/parser/typescript.rs +++ b/crates/swc_ecma_parser/src/parser/typescript.rs @@ -316,6 +316,18 @@ impl Parser { } }; + // the "assert" keyword is deprecated and this syntax is niche, so + // don't support it + let with = + if eat!(self, ',') && self.input.syntax().import_attributes() && is!(self, '{') { + match *self.parse_object::>()? { + Expr::Object(v) => Some(Box::new(v)), + _ => unreachable!(), + } + } else { + None + }; + expect!(self, ')'); let qualifier = if eat!(self, '.') { @@ -335,6 +347,7 @@ impl Parser { arg, qualifier, type_args, + with, }) } diff --git a/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts b/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts new file mode 100644 index 000000000000..7dace8d68287 --- /dev/null +++ b/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts @@ -0,0 +1,7 @@ +type Vite = typeof import("vite", { + with: { + "resolution-mode": "import" + } +}); +type Vite2 = typeof import("vite",); +type Vite3 = typeof import("vite"); diff --git a/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts.json b/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts.json new file mode 100644 index 000000000000..1ac01a34a19f --- /dev/null +++ b/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts.json @@ -0,0 +1,197 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 161 + }, + "body": [ + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 1, + "end": 88 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 6, + "end": 10 + }, + "ctxt": 0, + "value": "Vite", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsTypeQuery", + "span": { + "start": 13, + "end": 87 + }, + "exprName": { + "type": "TsImportType", + "span": { + "start": 20, + "end": 87 + }, + "argument": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 33 + }, + "value": "vite", + "raw": "\"vite\"" + }, + "qualifier": null, + "typeArguments": null, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 86 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 39, + "end": 43 + }, + "value": "with" + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 45, + "end": 84 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "StringLiteral", + "span": { + "start": 53, + "end": 70 + }, + "value": "resolution-mode", + "raw": "\"resolution-mode\"" + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 72, + "end": 80 + }, + "value": "import", + "raw": "\"import\"" + } + } + ] + } + } + ] + } + }, + "typeArguments": null + } + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 89, + "end": 125 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 94, + "end": 99 + }, + "ctxt": 0, + "value": "Vite2", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsTypeQuery", + "span": { + "start": 102, + "end": 124 + }, + "exprName": { + "type": "TsImportType", + "span": { + "start": 109, + "end": 124 + }, + "argument": { + "type": "StringLiteral", + "span": { + "start": 116, + "end": 122 + }, + "value": "vite", + "raw": "\"vite\"" + }, + "qualifier": null, + "typeArguments": null, + "with": null + }, + "typeArguments": null + } + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 126, + "end": 161 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 131, + "end": 136 + }, + "ctxt": 0, + "value": "Vite3", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsTypeQuery", + "span": { + "start": 139, + "end": 160 + }, + "exprName": { + "type": "TsImportType", + "span": { + "start": 146, + "end": 160 + }, + "argument": { + "type": "StringLiteral", + "span": { + "start": 153, + "end": 159 + }, + "value": "vite", + "raw": "\"vite\"" + }, + "qualifier": null, + "typeArguments": null, + "with": null + }, + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_visit/src/generated.rs b/crates/swc_ecma_visit/src/generated.rs index fb104d098181..d20c3d4397e5 100644 --- a/crates/swc_ecma_visit/src/generated.rs +++ b/crates/swc_ecma_visit/src/generated.rs @@ -13874,6 +13874,7 @@ impl VisitWith for TsImportType { arg, qualifier, type_args, + with, } => { { >::visit_with(span, visitor) @@ -13889,6 +13890,9 @@ impl VisitWith for TsImportType { type_args, visitor, ) }; + { + > as VisitWith>::visit_with(with, visitor) + }; } } } @@ -43014,6 +43018,7 @@ impl VisitWithAstPath for TsImportType { arg, qualifier, type_args, + with, } => { { let mut __ast_path = __ast_path.with_guard(AstParentNodeRef::TsImportType( @@ -43055,6 +43060,17 @@ impl VisitWithAstPath for TsImportType { )); < Option < Box < TsTypeParamInstantiation > > as VisitWithAstPath < V > > :: visit_with_ast_path (type_args , visitor , & mut * __ast_path) }; + { + let mut __ast_path = __ast_path.with_guard(AstParentNodeRef::TsImportType( + self, + self::fields::TsImportTypeField::With, + )); + > as VisitWithAstPath>::visit_with_ast_path( + with, + visitor, + &mut *__ast_path, + ) + }; } } } @@ -62508,6 +62524,7 @@ impl VisitMutWith for TsImportType { arg, qualifier, type_args, + with, } => { { >::visit_mut_with(span, visitor) @@ -62523,6 +62540,9 @@ impl VisitMutWith for TsImportType { type_args, visitor, ) }; + { + > as VisitMutWith>::visit_mut_with(with, visitor) + }; } } } @@ -87044,6 +87064,7 @@ impl VisitMutWithAstPath for TsImportType { arg, qualifier, type_args, + with, } => { { let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportType( @@ -87081,6 +87102,16 @@ impl VisitMutWithAstPath for TsImportType { )); < Option < Box < TsTypeParamInstantiation > > as VisitMutWithAstPath < V > > :: visit_mut_with_ast_path (type_args , visitor , & mut * __ast_path) }; + { + let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportType( + self::fields::TsImportTypeField::With, + )); + > as VisitMutWithAstPath>::visit_mut_with_ast_path( + with, + visitor, + &mut *__ast_path, + ) + }; } } } @@ -105448,6 +105479,7 @@ impl FoldWith for TsImportType { arg, qualifier, type_args, + with, } => { let span = { >::fold_with(span, visitor) }; let arg = { >::fold_with(arg, visitor) }; @@ -105458,11 +105490,13 @@ impl FoldWith for TsImportType { type_args, visitor, ) }; + let with = { > as FoldWith>::fold_with(with, visitor) }; TsImportType { span, arg, qualifier, type_args, + with, } } } @@ -131381,6 +131415,7 @@ impl FoldWithAstPath for TsImportType { arg, qualifier, type_args, + with, } => { let span = { let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportType( @@ -131414,11 +131449,22 @@ impl FoldWithAstPath for TsImportType { )); < Option < Box < TsTypeParamInstantiation > > as FoldWithAstPath < V > > :: fold_with_ast_path (type_args , visitor , & mut * __ast_path) }; + let with = { + let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportType( + self::fields::TsImportTypeField::With, + )); + > as FoldWithAstPath>::fold_with_ast_path( + with, + visitor, + &mut *__ast_path, + ) + }; TsImportType { span, arg, qualifier, type_args, + with, } } } @@ -138977,6 +139023,8 @@ pub mod fields { Qualifier, #[doc = "Represents [`TsImportType::type_args`]"] TypeArgs, + #[doc = "Represents [`TsImportType::with`]"] + With, } impl TsIndexSignatureField { pub(crate) fn set_index(&mut self, index: usize) { @@ -144693,6 +144741,10 @@ impl<'ast> NodeRef<'ast> { .chain(node.type_args.iter().flat_map(|item| { let item = &*item; ::std::iter::once(NodeRef::TsTypeParamInstantiation(&item)) + })) + .chain(node.with.iter().flat_map(|item| { + let item = &*item; + ::std::iter::once(NodeRef::ObjectLit(&item)) })); Box::new(iterator) } From 578103825a3a387d22ffabdd5b44a770be6d6b07 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 12 Dec 2024 11:51:12 -0500 Subject: [PATCH 02/11] format --- crates/swc_ecma_parser/src/parser/typescript.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/swc_ecma_parser/src/parser/typescript.rs b/crates/swc_ecma_parser/src/parser/typescript.rs index 3537049d50cc..6d0beeeac332 100644 --- a/crates/swc_ecma_parser/src/parser/typescript.rs +++ b/crates/swc_ecma_parser/src/parser/typescript.rs @@ -318,15 +318,14 @@ impl Parser { // the "assert" keyword is deprecated and this syntax is niche, so // don't support it - let with = - if eat!(self, ',') && self.input.syntax().import_attributes() && is!(self, '{') { - match *self.parse_object::>()? { - Expr::Object(v) => Some(Box::new(v)), - _ => unreachable!(), - } - } else { - None - }; + let with = if eat!(self, ',') && self.input.syntax().import_attributes() && is!(self, '{') { + match *self.parse_object::>()? { + Expr::Object(v) => Some(Box::new(v)), + _ => unreachable!(), + } + } else { + None + }; expect!(self, ')'); From a593892f91a2387718d8bc57c89b6ecc0d232102 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 31 Jan 2025 13:16:28 -0500 Subject: [PATCH 03/11] Add ImportCallOptions --- crates/swc_ecma_ast/src/lib.rs | 2 +- crates/swc_ecma_ast/src/typescript.rs | 11 +- crates/swc_ecma_codegen/src/typescript.rs | 18 +- crates/swc_ecma_parser/src/parser/expr.rs | 2 +- crates/swc_ecma_parser/src/parser/object.rs | 4 +- .../src/parser/stmt/module_item.rs | 6 +- .../swc_ecma_parser/src/parser/typescript.rs | 29 +- crates/swc_ecma_visit/src/generated.rs | 972 +++++++++++++++++- 8 files changed, 1001 insertions(+), 43 deletions(-) diff --git a/crates/swc_ecma_ast/src/lib.rs b/crates/swc_ecma_ast/src/lib.rs index dfbef4331ef3..601c762c414d 100644 --- a/crates/swc_ecma_ast/src/lib.rs +++ b/crates/swc_ecma_ast/src/lib.rs @@ -70,7 +70,7 @@ pub use self::{ TsTupleType, TsType, TsTypeAliasDecl, TsTypeAnn, TsTypeAssertion, TsTypeElement, TsTypeLit, TsTypeOperator, TsTypeOperatorOp, TsTypeParam, TsTypeParamDecl, TsTypeParamInstantiation, TsTypePredicate, TsTypeQuery, TsTypeQueryExpr, TsTypeRef, TsUnionOrIntersectionType, - TsUnionType, + TsUnionType, TsImportCallOptions }, }; diff --git a/crates/swc_ecma_ast/src/typescript.rs b/crates/swc_ecma_ast/src/typescript.rs index 434126c1bab1..bbf4c1250781 100644 --- a/crates/swc_ecma_ast/src/typescript.rs +++ b/crates/swc_ecma_ast/src/typescript.rs @@ -536,6 +536,15 @@ pub enum TsTypeQueryExpr { Import(TsImportType), } +#[ast_node("TsImportCallOptions")] +#[derive(Eq, Hash, EqIgnoreSpan)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +pub struct TsImportCallOptions { + pub span: Span, + #[cfg_attr(feature = "serde-impl", serde(default))] + pub with: Box, +} + #[ast_node("TsImportType")] #[derive(Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] @@ -547,7 +556,7 @@ pub struct TsImportType { #[cfg_attr(feature = "serde-impl", serde(rename = "typeArguments"))] pub type_args: Option>, #[cfg_attr(feature = "serde-impl", serde(default))] - pub with: Option>, + pub attributes: Option, } #[ast_node("TsTypeLiteral")] diff --git a/crates/swc_ecma_codegen/src/typescript.rs b/crates/swc_ecma_codegen/src/typescript.rs index 77e8e8b1ab4f..fde3d6e64493 100644 --- a/crates/swc_ecma_codegen/src/typescript.rs +++ b/crates/swc_ecma_codegen/src/typescript.rs @@ -845,10 +845,10 @@ where keyword!("import"); punct!("("); emit!(n.arg); - if let Some(with) = &n.with { + if let Some(attributes) = &n.attributes { punct!(","); formatting_space!(); - emit!(with); + emit!(attributes); } punct!(")"); @@ -860,6 +860,20 @@ where emit!(n.type_args); } + #[emitter] + fn emit_ts_import_call_options(&mut self, n: &TsImportCallOptions) -> Result { + punct!("{"); + + if let Some(with) = &n.with { + keyword!("with"); + punct!(":"); + formatting_space!(); + emit!(with); + } + + punct!("}"); + } + #[emitter] fn emit_ts_type_alias_decl(&mut self, n: &TsTypeAliasDecl) -> Result { self.emit_leading_comments_of_span(n.span(), false)?; diff --git a/crates/swc_ecma_parser/src/parser/expr.rs b/crates/swc_ecma_parser/src/parser/expr.rs index d782df1d3784..fd56d9adcaba 100644 --- a/crates/swc_ecma_parser/src/parser/expr.rs +++ b/crates/swc_ecma_parser/src/parser/expr.rs @@ -307,7 +307,7 @@ impl Parser { } tok!('{') => { - return self.parse_object(); + return self.parse_object::().map(Box::new); } // Handle FunctionExpression and GeneratorExpression diff --git a/crates/swc_ecma_parser/src/parser/object.rs b/crates/swc_ecma_parser/src/parser/object.rs index f01bf7c346f6..1e604becd2c5 100644 --- a/crates/swc_ecma_parser/src/parser/object.rs +++ b/crates/swc_ecma_parser/src/parser/object.rs @@ -122,7 +122,7 @@ impl Parser { } } -impl ParseObject> for Parser { +impl ParseObject for Parser { type Prop = PropOrSpread; fn make_object( @@ -130,7 +130,7 @@ impl ParseObject> for Parser { span: Span, props: Vec, trailing_comma: Option, - ) -> PResult> { + ) -> PResult { if let Some(trailing_comma) = trailing_comma { self.state.trailing_commas.insert(span.lo, trailing_comma); } diff --git a/crates/swc_ecma_parser/src/parser/stmt/module_item.rs b/crates/swc_ecma_parser/src/parser/stmt/module_item.rs index ebdef4d11d3e..4148354b795c 100644 --- a/crates/swc_ecma_parser/src/parser/stmt/module_item.rs +++ b/crates/swc_ecma_parser/src/parser/stmt/module_item.rs @@ -58,7 +58,7 @@ impl Parser { && !self.input.had_line_break_before_cur() && (eat!(self, "assert") || eat!(self, "with")) { - match *self.parse_object::>()? { + match self.parse_object::()? { Expr::Object(v) => Some(Box::new(v)), _ => unreachable!(), } @@ -183,7 +183,7 @@ impl Parser { && !self.input.had_line_break_before_cur() && (eat!(self, "assert") || eat!(self, "with")) { - match *self.parse_object::>()? { + match self.parse_object::()? { Expr::Object(v) => Some(Box::new(v)), _ => unreachable!(), } @@ -858,7 +858,7 @@ impl Parser { && !self.input.had_line_break_before_cur() && (eat!(self, "assert") || eat!(self, "with")) { - match *self.parse_object::>()? { + match self.parse_object::()? { Expr::Object(v) => Some(Box::new(v)), _ => unreachable!(), } diff --git a/crates/swc_ecma_parser/src/parser/typescript.rs b/crates/swc_ecma_parser/src/parser/typescript.rs index f22bdccad537..29a41d7edff9 100644 --- a/crates/swc_ecma_parser/src/parser/typescript.rs +++ b/crates/swc_ecma_parser/src/parser/typescript.rs @@ -318,11 +318,8 @@ impl Parser { // the "assert" keyword is deprecated and this syntax is niche, so // don't support it - let with = if eat!(self, ',') && self.input.syntax().import_attributes() && is!(self, '{') { - match *self.parse_object::>()? { - Expr::Object(v) => Some(Box::new(v)), - _ => unreachable!(), - } + let attributes = if eat!(self, ',') && self.input.syntax().import_attributes() && is!(self, '{') { + Some(self.parse_ts_call_options()?) } else { None }; @@ -351,7 +348,27 @@ impl Parser { arg, qualifier, type_args, - with, + attributes, + }) + } + + fn parse_ts_call_options(&mut self) -> PResult { + debug_assert!(self.input.syntax().typescript()); + let start = cur_pos!(self); + assert_and_bump!(self, '{'); + + expect!(self, "with"); + expect!(self, ':'); + + let value = match self.parse_object::()? { + Expr::Object(v) => v, + _ => unreachable!(), + }; + eat!(self, ','); + expect!(self, '}'); + Ok(TsImportCallOptions { + span: span!(self, start), + with: Box::new(value), }) } diff --git a/crates/swc_ecma_visit/src/generated.rs b/crates/swc_ecma_visit/src/generated.rs index d20c3d4397e5..23a133cee205 100644 --- a/crates/swc_ecma_visit/src/generated.rs +++ b/crates/swc_ecma_visit/src/generated.rs @@ -1023,6 +1023,13 @@ pub trait Visit { fn visit_opt_ts_entity_name(&mut self, node: &Option) { as VisitWith>::visit_children_with(node, self) } + #[doc = "Visit a node of type `Option < TsImportCallOptions >`.\n\nBy default, this method \ + calls [`Option < TsImportCallOptions >::visit_children_with`]. If you want to \ + recurse, you need to call it manually."] + #[inline] + fn visit_opt_ts_import_call_options(&mut self, node: &Option) { + as VisitWith>::visit_children_with(node, self) + } #[doc = "Visit a node of type `Option < TsNamespaceBody >`.\n\nBy default, this method calls \ [`Option < TsNamespaceBody >::visit_children_with`]. If you want to recurse, you need \ to call it manually."] @@ -1518,6 +1525,13 @@ pub trait Visit { fn visit_ts_getter_signature(&mut self, node: &TsGetterSignature) { >::visit_children_with(node, self) } + #[doc = "Visit a node of type `TsImportCallOptions`.\n\nBy default, this method calls \ + [`TsImportCallOptions::visit_children_with`]. If you want to recurse, you need to \ + call it manually."] + #[inline] + fn visit_ts_import_call_options(&mut self, node: &TsImportCallOptions) { + >::visit_children_with(node, self) + } #[doc = "Visit a node of type `TsImportEqualsDecl`.\n\nBy default, this method calls \ [`TsImportEqualsDecl::visit_children_with`]. If you want to recurse, you need to call \ it manually."] @@ -2758,6 +2772,11 @@ where ::visit_opt_ts_entity_name(&mut **self, node) } + #[inline] + fn visit_opt_ts_import_call_options(&mut self, node: &Option) { + ::visit_opt_ts_import_call_options(&mut **self, node) + } + #[inline] fn visit_opt_ts_namespace_body(&mut self, node: &Option) { ::visit_opt_ts_namespace_body(&mut **self, node) @@ -3121,6 +3140,11 @@ where ::visit_ts_getter_signature(&mut **self, node) } + #[inline] + fn visit_ts_import_call_options(&mut self, node: &TsImportCallOptions) { + ::visit_ts_import_call_options(&mut **self, node) + } + #[inline] fn visit_ts_import_equals_decl(&mut self, node: &TsImportEqualsDecl) { ::visit_ts_import_equals_decl(&mut **self, node) @@ -4220,6 +4244,11 @@ where ::visit_opt_ts_entity_name(&mut **self, node) } + #[inline] + fn visit_opt_ts_import_call_options(&mut self, node: &Option) { + ::visit_opt_ts_import_call_options(&mut **self, node) + } + #[inline] fn visit_opt_ts_namespace_body(&mut self, node: &Option) { ::visit_opt_ts_namespace_body(&mut **self, node) @@ -4583,6 +4612,11 @@ where ::visit_ts_getter_signature(&mut **self, node) } + #[inline] + fn visit_ts_import_call_options(&mut self, node: &TsImportCallOptions) { + ::visit_ts_import_call_options(&mut **self, node) + } + #[inline] fn visit_ts_import_equals_decl(&mut self, node: &TsImportEqualsDecl) { ::visit_ts_import_equals_decl(&mut **self, node) @@ -6145,6 +6179,18 @@ where } } + #[inline] + fn visit_opt_ts_import_call_options(&mut self, node: &Option) { + match self { + swc_visit::Either::Left(visitor) => { + Visit::visit_opt_ts_import_call_options(visitor, node) + } + swc_visit::Either::Right(visitor) => { + Visit::visit_opt_ts_import_call_options(visitor, node) + } + } + } + #[inline] fn visit_opt_ts_namespace_body(&mut self, node: &Option) { match self { @@ -6742,6 +6788,14 @@ where } } + #[inline] + fn visit_ts_import_call_options(&mut self, node: &TsImportCallOptions) { + match self { + swc_visit::Either::Left(visitor) => Visit::visit_ts_import_call_options(visitor, node), + swc_visit::Either::Right(visitor) => Visit::visit_ts_import_call_options(visitor, node), + } + } + #[inline] fn visit_ts_import_equals_decl(&mut self, node: &TsImportEqualsDecl) { match self { @@ -8510,6 +8564,14 @@ where } } + #[inline] + fn visit_opt_ts_import_call_options(&mut self, node: &Option) { + if self.enabled { + ::visit_opt_ts_import_call_options(&mut self.visitor, node) + } else { + } + } + #[inline] fn visit_opt_ts_namespace_body(&mut self, node: &Option) { if self.enabled { @@ -9089,6 +9151,14 @@ where } } + #[inline] + fn visit_ts_import_call_options(&mut self, node: &TsImportCallOptions) { + if self.enabled { + ::visit_ts_import_call_options(&mut self.visitor, node) + } else { + } + } + #[inline] fn visit_ts_import_equals_decl(&mut self, node: &TsImportEqualsDecl) { if self.enabled { @@ -13833,6 +13903,25 @@ impl VisitWith for TsGetterSignature { } } } +impl VisitWith for TsImportCallOptions { + #[doc = "Calls [Visit`::visit_ts_import_call_options`] with `self`."] + fn visit_with(&self, visitor: &mut V) { + ::visit_ts_import_call_options(visitor, self) + } + + fn visit_children_with(&self, visitor: &mut V) { + match self { + TsImportCallOptions { span, with } => { + { + >::visit_with(span, visitor) + }; + { + as VisitWith>::visit_with(with, visitor) + }; + } + } + } +} impl VisitWith for TsImportEqualsDecl { #[doc = "Calls [Visit`::visit_ts_import_equals_decl`] with `self`."] fn visit_with(&self, visitor: &mut V) { @@ -13874,7 +13963,7 @@ impl VisitWith for TsImportType { arg, qualifier, type_args, - with, + attributes, } => { { >::visit_with(span, visitor) @@ -13891,7 +13980,7 @@ impl VisitWith for TsImportType { ) }; { - > as VisitWith>::visit_with(with, visitor) + as VisitWith>::visit_with(attributes, visitor) }; } } @@ -15844,6 +15933,21 @@ impl VisitWith for Option { } } } +impl VisitWith for Option { + #[doc = "Calls [Visit`::visit_opt_ts_import_call_options`] with `self`. (Extra impl)"] + #[inline] + fn visit_with(&self, visitor: &mut V) { + ::visit_opt_ts_import_call_options(visitor, self) + } + + #[inline] + fn visit_children_with(&self, visitor: &mut V) { + match self { + Some(inner) => >::visit_with(inner, visitor), + None => {} + } + } +} impl VisitWith for Option { #[doc = "Calls [Visit`::visit_opt_ts_namespace_body`] with `self`. (Extra impl)"] #[inline] @@ -17969,6 +18073,19 @@ pub trait VisitAstPath { node, self, __ast_path, ) } + #[doc = "Visit a node of type `Option < TsImportCallOptions >`.\n\nBy default, this method \ + calls [`Option < TsImportCallOptions >::visit_children_with_ast_path`]. If you want \ + to recurse, you need to call it manually."] + #[inline] + fn visit_opt_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast Option, + __ast_path: &mut AstNodePath<'r>, + ) { + as VisitWithAstPath>::visit_children_with_ast_path( + node, self, __ast_path, + ) + } #[doc = "Visit a node of type `Option < TsNamespaceBody >`.\n\nBy default, this method calls \ [`Option < TsNamespaceBody >::visit_children_with_ast_path`]. If you want to recurse, \ you need to call it manually."] @@ -18798,6 +18915,19 @@ pub trait VisitAstPath { node, self, __ast_path, ) } + #[doc = "Visit a node of type `TsImportCallOptions`.\n\nBy default, this method calls \ + [`TsImportCallOptions::visit_children_with_ast_path`]. If you want to recurse, you \ + need to call it manually."] + #[inline] + fn visit_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast TsImportCallOptions, + __ast_path: &mut AstNodePath<'r>, + ) { + >::visit_children_with_ast_path( + node, self, __ast_path, + ) + } #[doc = "Visit a node of type `TsImportEqualsDecl`.\n\nBy default, this method calls \ [`TsImportEqualsDecl::visit_children_with_ast_path`]. If you want to recurse, you \ need to call it manually."] @@ -20974,6 +21104,15 @@ where ::visit_opt_ts_entity_name(&mut **self, node, __ast_path) } + #[inline] + fn visit_opt_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast Option, + __ast_path: &mut AstNodePath<'r>, + ) { + ::visit_opt_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn visit_opt_ts_namespace_body<'ast: 'r, 'r>( &mut self, @@ -21578,6 +21717,15 @@ where ::visit_ts_getter_signature(&mut **self, node, __ast_path) } + #[inline] + fn visit_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast TsImportCallOptions, + __ast_path: &mut AstNodePath<'r>, + ) { + ::visit_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn visit_ts_import_equals_decl<'ast: 'r, 'r>( &mut self, @@ -23503,6 +23651,15 @@ where ::visit_opt_ts_entity_name(&mut **self, node, __ast_path) } + #[inline] + fn visit_opt_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast Option, + __ast_path: &mut AstNodePath<'r>, + ) { + ::visit_opt_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn visit_opt_ts_namespace_body<'ast: 'r, 'r>( &mut self, @@ -24107,6 +24264,15 @@ where ::visit_ts_getter_signature(&mut **self, node, __ast_path) } + #[inline] + fn visit_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast TsImportCallOptions, + __ast_path: &mut AstNodePath<'r>, + ) { + ::visit_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn visit_ts_import_equals_decl<'ast: 'r, 'r>( &mut self, @@ -27051,6 +27217,22 @@ where } } + #[inline] + fn visit_opt_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast Option, + __ast_path: &mut AstNodePath<'r>, + ) { + match self { + swc_visit::Either::Left(visitor) => { + VisitAstPath::visit_opt_ts_import_call_options(visitor, node, __ast_path) + } + swc_visit::Either::Right(visitor) => { + VisitAstPath::visit_opt_ts_import_call_options(visitor, node, __ast_path) + } + } + } + #[inline] fn visit_opt_ts_namespace_body<'ast: 'r, 'r>( &mut self, @@ -28139,6 +28321,22 @@ where } } + #[inline] + fn visit_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast TsImportCallOptions, + __ast_path: &mut AstNodePath<'r>, + ) { + match self { + swc_visit::Either::Left(visitor) => { + VisitAstPath::visit_ts_import_call_options(visitor, node, __ast_path) + } + swc_visit::Either::Right(visitor) => { + VisitAstPath::visit_ts_import_call_options(visitor, node, __ast_path) + } + } + } + #[inline] fn visit_ts_import_equals_decl<'ast: 'r, 'r>( &mut self, @@ -31009,6 +31207,22 @@ where } } + #[inline] + fn visit_opt_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast Option, + __ast_path: &mut AstNodePath<'r>, + ) { + if self.enabled { + ::visit_opt_ts_import_call_options( + &mut self.visitor, + node, + __ast_path, + ) + } else { + } + } + #[inline] fn visit_opt_ts_namespace_body<'ast: 'r, 'r>( &mut self, @@ -31841,6 +32055,18 @@ where } } + #[inline] + fn visit_ts_import_call_options<'ast: 'r, 'r>( + &mut self, + node: &'ast TsImportCallOptions, + __ast_path: &mut AstNodePath<'r>, + ) { + if self.enabled { + ::visit_ts_import_call_options(&mut self.visitor, node, __ast_path) + } else { + } + } + #[inline] fn visit_ts_import_equals_decl<'ast: 'r, 'r>( &mut self, @@ -42932,6 +43158,53 @@ impl VisitWithAstPath for TsGetterSignature { } #[cfg(any(docsrs, feature = "path"))] #[cfg_attr(docsrs, doc(cfg(feature = "path")))] +impl VisitWithAstPath for TsImportCallOptions { + #[doc = "Calls [VisitAstPath`::visit_ts_import_call_options`] with `self`."] + fn visit_with_ast_path<'ast: 'r, 'r>( + &'ast self, + visitor: &mut V, + __ast_path: &mut AstNodePath<'r>, + ) { + ::visit_ts_import_call_options(visitor, self, __ast_path) + } + + fn visit_children_with_ast_path<'ast: 'r, 'r>( + &'ast self, + visitor: &mut V, + __ast_path: &mut AstNodePath<'r>, + ) { + match self { + TsImportCallOptions { span, with } => { + { + let mut __ast_path = + __ast_path.with_guard(AstParentNodeRef::TsImportCallOptions( + self, + self::fields::TsImportCallOptionsField::Span, + )); + >::visit_with_ast_path( + span, + visitor, + &mut *__ast_path, + ) + }; + { + let mut __ast_path = + __ast_path.with_guard(AstParentNodeRef::TsImportCallOptions( + self, + self::fields::TsImportCallOptionsField::With, + )); + > as VisitWithAstPath>::visit_with_ast_path( + with, + visitor, + &mut *__ast_path, + ) + }; + } + } + } +} +#[cfg(any(docsrs, feature = "path"))] +#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl VisitWithAstPath for TsImportEqualsDecl { #[doc = "Calls [VisitAstPath`::visit_ts_import_equals_decl`] with `self`."] fn visit_with_ast_path<'ast: 'r, 'r>( @@ -43018,7 +43291,7 @@ impl VisitWithAstPath for TsImportType { arg, qualifier, type_args, - with, + attributes, } => { { let mut __ast_path = __ast_path.with_guard(AstParentNodeRef::TsImportType( @@ -43063,10 +43336,10 @@ impl VisitWithAstPath for TsImportType { { let mut __ast_path = __ast_path.with_guard(AstParentNodeRef::TsImportType( self, - self::fields::TsImportTypeField::With, + self::fields::TsImportTypeField::Attributes, )); - > as VisitWithAstPath>::visit_with_ast_path( - with, + as VisitWithAstPath>::visit_with_ast_path( + attributes, visitor, &mut *__ast_path, ) @@ -47531,6 +47804,33 @@ impl VisitWithAstPath for Option { } #[cfg(any(docsrs, feature = "path"))] #[cfg_attr(docsrs, doc(cfg(feature = "path")))] +impl VisitWithAstPath for Option { + #[doc = "Calls [VisitAstPath`::visit_opt_ts_import_call_options`] with `self`. (Extra impl)"] + #[inline] + fn visit_with_ast_path<'ast: 'r, 'r>( + &'ast self, + visitor: &mut V, + __ast_path: &mut AstNodePath<'r>, + ) { + ::visit_opt_ts_import_call_options(visitor, self, __ast_path) + } + + #[inline] + fn visit_children_with_ast_path<'ast: 'r, 'r>( + &'ast self, + visitor: &mut V, + __ast_path: &mut AstNodePath<'r>, + ) { + match self { + Some(inner) => >::visit_with_ast_path( + inner, visitor, __ast_path, + ), + None => {} + } + } +} +#[cfg(any(docsrs, feature = "path"))] +#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl VisitWithAstPath for Option { #[doc = "Calls [VisitAstPath`::visit_opt_ts_namespace_body`] with `self`. (Extra impl)"] #[inline] @@ -49309,6 +49609,13 @@ pub trait VisitMut { fn visit_mut_opt_ts_entity_name(&mut self, node: &mut Option) { as VisitMutWith>::visit_mut_children_with(node, self) } + #[doc = "Visit a node of type `Option < TsImportCallOptions >`.\n\nBy default, this method \ + calls [`Option < TsImportCallOptions >::visit_mut_children_with`]. If you want to \ + recurse, you need to call it manually."] + #[inline] + fn visit_mut_opt_ts_import_call_options(&mut self, node: &mut Option) { + as VisitMutWith>::visit_mut_children_with(node, self) + } #[doc = "Visit a node of type `Option < TsNamespaceBody >`.\n\nBy default, this method calls \ [`Option < TsNamespaceBody >::visit_mut_children_with`]. If you want to recurse, you \ need to call it manually."] @@ -49815,6 +50122,13 @@ pub trait VisitMut { fn visit_mut_ts_getter_signature(&mut self, node: &mut TsGetterSignature) { >::visit_mut_children_with(node, self) } + #[doc = "Visit a node of type `TsImportCallOptions`.\n\nBy default, this method calls \ + [`TsImportCallOptions::visit_mut_children_with`]. If you want to recurse, you need to \ + call it manually."] + #[inline] + fn visit_mut_ts_import_call_options(&mut self, node: &mut TsImportCallOptions) { + >::visit_mut_children_with(node, self) + } #[doc = "Visit a node of type `TsImportEqualsDecl`.\n\nBy default, this method calls \ [`TsImportEqualsDecl::visit_mut_children_with`]. If you want to recurse, you need to \ call it manually."] @@ -51057,6 +51371,11 @@ where ::visit_mut_opt_ts_entity_name(&mut **self, node) } + #[inline] + fn visit_mut_opt_ts_import_call_options(&mut self, node: &mut Option) { + ::visit_mut_opt_ts_import_call_options(&mut **self, node) + } + #[inline] fn visit_mut_opt_ts_namespace_body(&mut self, node: &mut Option) { ::visit_mut_opt_ts_namespace_body(&mut **self, node) @@ -51420,6 +51739,11 @@ where ::visit_mut_ts_getter_signature(&mut **self, node) } + #[inline] + fn visit_mut_ts_import_call_options(&mut self, node: &mut TsImportCallOptions) { + ::visit_mut_ts_import_call_options(&mut **self, node) + } + #[inline] fn visit_mut_ts_import_equals_decl(&mut self, node: &mut TsImportEqualsDecl) { ::visit_mut_ts_import_equals_decl(&mut **self, node) @@ -52519,6 +52843,11 @@ where ::visit_mut_opt_ts_entity_name(&mut **self, node) } + #[inline] + fn visit_mut_opt_ts_import_call_options(&mut self, node: &mut Option) { + ::visit_mut_opt_ts_import_call_options(&mut **self, node) + } + #[inline] fn visit_mut_opt_ts_namespace_body(&mut self, node: &mut Option) { ::visit_mut_opt_ts_namespace_body(&mut **self, node) @@ -52882,6 +53211,11 @@ where ::visit_mut_ts_getter_signature(&mut **self, node) } + #[inline] + fn visit_mut_ts_import_call_options(&mut self, node: &mut TsImportCallOptions) { + ::visit_mut_ts_import_call_options(&mut **self, node) + } + #[inline] fn visit_mut_ts_import_equals_decl(&mut self, node: &mut TsImportEqualsDecl) { ::visit_mut_ts_import_equals_decl(&mut **self, node) @@ -54576,6 +54910,18 @@ where } } + #[inline] + fn visit_mut_opt_ts_import_call_options(&mut self, node: &mut Option) { + match self { + swc_visit::Either::Left(visitor) => { + VisitMut::visit_mut_opt_ts_import_call_options(visitor, node) + } + swc_visit::Either::Right(visitor) => { + VisitMut::visit_mut_opt_ts_import_call_options(visitor, node) + } + } + } + #[inline] fn visit_mut_opt_ts_namespace_body(&mut self, node: &mut Option) { match self { @@ -55235,6 +55581,18 @@ where } } + #[inline] + fn visit_mut_ts_import_call_options(&mut self, node: &mut TsImportCallOptions) { + match self { + swc_visit::Either::Left(visitor) => { + VisitMut::visit_mut_ts_import_call_options(visitor, node) + } + swc_visit::Either::Right(visitor) => { + VisitMut::visit_mut_ts_import_call_options(visitor, node) + } + } + } + #[inline] fn visit_mut_ts_import_equals_decl(&mut self, node: &mut TsImportEqualsDecl) { match self { @@ -57113,6 +57471,14 @@ where } } + #[inline] + fn visit_mut_opt_ts_import_call_options(&mut self, node: &mut Option) { + if self.enabled { + ::visit_mut_opt_ts_import_call_options(&mut self.visitor, node) + } else { + } + } + #[inline] fn visit_mut_opt_ts_namespace_body(&mut self, node: &mut Option) { if self.enabled { @@ -57692,6 +58058,14 @@ where } } + #[inline] + fn visit_mut_ts_import_call_options(&mut self, node: &mut TsImportCallOptions) { + if self.enabled { + ::visit_mut_ts_import_call_options(&mut self.visitor, node) + } else { + } + } + #[inline] fn visit_mut_ts_import_equals_decl(&mut self, node: &mut TsImportEqualsDecl) { if self.enabled { @@ -62483,6 +62857,25 @@ impl VisitMutWith for TsGetterSignature { } } } +impl VisitMutWith for TsImportCallOptions { + #[doc = "Calls [VisitMut`::visit_mut_ts_import_call_options`] with `self`."] + fn visit_mut_with(&mut self, visitor: &mut V) { + ::visit_mut_ts_import_call_options(visitor, self) + } + + fn visit_mut_children_with(&mut self, visitor: &mut V) { + match self { + TsImportCallOptions { span, with } => { + { + >::visit_mut_with(span, visitor) + }; + { + as VisitMutWith>::visit_mut_with(with, visitor) + }; + } + } + } +} impl VisitMutWith for TsImportEqualsDecl { #[doc = "Calls [VisitMut`::visit_mut_ts_import_equals_decl`] with `self`."] fn visit_mut_with(&mut self, visitor: &mut V) { @@ -62524,7 +62917,7 @@ impl VisitMutWith for TsImportType { arg, qualifier, type_args, - with, + attributes, } => { { >::visit_mut_with(span, visitor) @@ -62541,7 +62934,9 @@ impl VisitMutWith for TsImportType { ) }; { - > as VisitMutWith>::visit_mut_with(with, visitor) + as VisitMutWith>::visit_mut_with( + attributes, visitor, + ) }; } } @@ -64508,6 +64903,21 @@ impl VisitMutWith for Option { } } } +impl VisitMutWith for Option { + #[doc = "Calls [VisitMut`::visit_mut_opt_ts_import_call_options`] with `self`. (Extra impl)"] + #[inline] + fn visit_mut_with(&mut self, visitor: &mut V) { + ::visit_mut_opt_ts_import_call_options(visitor, self) + } + + #[inline] + fn visit_mut_children_with(&mut self, visitor: &mut V) { + match self { + Some(inner) => >::visit_mut_with(inner, visitor), + None => {} + } + } +} impl VisitMutWith for Option { #[doc = "Calls [VisitMut`::visit_mut_opt_ts_namespace_body`] with `self`. (Extra impl)"] #[inline] @@ -66398,6 +66808,19 @@ pub trait VisitMutAstPath { node, self, __ast_path, ) } + #[doc = "Visit a node of type `Option < TsImportCallOptions >`.\n\nBy default, this method \ + calls [`Option < TsImportCallOptions >::visit_mut_children_with_ast_path`]. If you \ + want to recurse, you need to call it manually."] + #[inline] + fn visit_mut_opt_ts_import_call_options( + &mut self, + node: &mut Option, + __ast_path: &mut AstKindPath, + ) { + as VisitMutWithAstPath>::visit_mut_children_with_ast_path( + node, self, __ast_path, + ) + } #[doc = "Visit a node of type `Option < TsNamespaceBody >`.\n\nBy default, this method calls \ [`Option < TsNamespaceBody >::visit_mut_children_with_ast_path`]. If you want to \ recurse, you need to call it manually."] @@ -67149,6 +67572,19 @@ pub trait VisitMutAstPath { node, self, __ast_path, ) } + #[doc = "Visit a node of type `TsImportCallOptions`.\n\nBy default, this method calls \ + [`TsImportCallOptions::visit_mut_children_with_ast_path`]. If you want to recurse, \ + you need to call it manually."] + #[inline] + fn visit_mut_ts_import_call_options( + &mut self, + node: &mut TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) { + >::visit_mut_children_with_ast_path( + node, self, __ast_path, + ) + } #[doc = "Visit a node of type `TsImportEqualsDecl`.\n\nBy default, this method calls \ [`TsImportEqualsDecl::visit_mut_children_with_ast_path`]. If you want to recurse, you \ need to call it manually."] @@ -68891,6 +69327,15 @@ where ::visit_mut_opt_ts_entity_name(&mut **self, node, __ast_path) } + #[inline] + fn visit_mut_opt_ts_import_call_options( + &mut self, + node: &mut Option, + __ast_path: &mut AstKindPath, + ) { + ::visit_mut_opt_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn visit_mut_opt_ts_namespace_body( &mut self, @@ -69367,6 +69812,15 @@ where ::visit_mut_ts_getter_signature(&mut **self, node, __ast_path) } + #[inline] + fn visit_mut_ts_import_call_options( + &mut self, + node: &mut TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) { + ::visit_mut_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn visit_mut_ts_import_equals_decl( &mut self, @@ -70828,6 +71282,15 @@ where ::visit_mut_opt_ts_entity_name(&mut **self, node, __ast_path) } + #[inline] + fn visit_mut_opt_ts_import_call_options( + &mut self, + node: &mut Option, + __ast_path: &mut AstKindPath, + ) { + ::visit_mut_opt_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn visit_mut_opt_ts_namespace_body( &mut self, @@ -71304,6 +71767,15 @@ where ::visit_mut_ts_getter_signature(&mut **self, node, __ast_path) } + #[inline] + fn visit_mut_ts_import_call_options( + &mut self, + node: &mut TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) { + ::visit_mut_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn visit_mut_ts_import_equals_decl( &mut self, @@ -73802,6 +74274,22 @@ where } } + #[inline] + fn visit_mut_opt_ts_import_call_options( + &mut self, + node: &mut Option, + __ast_path: &mut AstKindPath, + ) { + match self { + swc_visit::Either::Left(visitor) => { + VisitMutAstPath::visit_mut_opt_ts_import_call_options(visitor, node, __ast_path) + } + swc_visit::Either::Right(visitor) => { + VisitMutAstPath::visit_mut_opt_ts_import_call_options(visitor, node, __ast_path) + } + } + } + #[inline] fn visit_mut_opt_ts_namespace_body( &mut self, @@ -74782,6 +75270,22 @@ where } } + #[inline] + fn visit_mut_ts_import_call_options( + &mut self, + node: &mut TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) { + match self { + swc_visit::Either::Left(visitor) => { + VisitMutAstPath::visit_mut_ts_import_call_options(visitor, node, __ast_path) + } + swc_visit::Either::Right(visitor) => { + VisitMutAstPath::visit_mut_ts_import_call_options(visitor, node, __ast_path) + } + } + } + #[inline] fn visit_mut_ts_import_equals_decl( &mut self, @@ -77292,6 +77796,22 @@ where } } + #[inline] + fn visit_mut_opt_ts_import_call_options( + &mut self, + node: &mut Option, + __ast_path: &mut AstKindPath, + ) { + if self.enabled { + ::visit_mut_opt_ts_import_call_options( + &mut self.visitor, + node, + __ast_path, + ) + } else { + } + } + #[inline] fn visit_mut_opt_ts_namespace_body( &mut self, @@ -78056,6 +78576,22 @@ where } } + #[inline] + fn visit_mut_ts_import_call_options( + &mut self, + node: &mut TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) { + if self.enabled { + ::visit_mut_ts_import_call_options( + &mut self.visitor, + node, + __ast_path, + ) + } else { + } + } + #[inline] fn visit_mut_ts_import_equals_decl( &mut self, @@ -87000,6 +87536,41 @@ impl VisitMutWithAstPath for TsGetterSignature { } #[cfg(any(docsrs, feature = "path"))] #[cfg_attr(docsrs, doc(cfg(feature = "path")))] +impl VisitMutWithAstPath for TsImportCallOptions { + #[doc = "Calls [VisitMutAstPath`::visit_mut_ts_import_call_options`] with `self`."] + fn visit_mut_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { + ::visit_mut_ts_import_call_options(visitor, self, __ast_path) + } + + fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { + match self { + TsImportCallOptions { span, with } => { + { + let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportCallOptions( + self::fields::TsImportCallOptionsField::Span, + )); + >::visit_mut_with_ast_path( + span, + visitor, + &mut *__ast_path, + ) + }; + { + let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportCallOptions( + self::fields::TsImportCallOptionsField::With, + )); + > as VisitMutWithAstPath>::visit_mut_with_ast_path( + with, + visitor, + &mut *__ast_path, + ) + }; + } + } + } +} +#[cfg(any(docsrs, feature = "path"))] +#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl VisitMutWithAstPath for TsImportEqualsDecl { #[doc = "Calls [VisitMutAstPath`::visit_mut_ts_import_equals_decl`] with `self`."] fn visit_mut_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { @@ -87064,7 +87635,7 @@ impl VisitMutWithAstPath for TsImportType { arg, qualifier, type_args, - with, + attributes, } => { { let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportType( @@ -87104,10 +87675,10 @@ impl VisitMutWithAstPath for TsImportType { }; { let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportType( - self::fields::TsImportTypeField::With, + self::fields::TsImportTypeField::Attributes, )); - > as VisitMutWithAstPath>::visit_mut_with_ast_path( - with, + as VisitMutWithAstPath>::visit_mut_with_ast_path( + attributes, visitor, &mut *__ast_path, ) @@ -90577,6 +91148,28 @@ impl VisitMutWithAstPath for Option VisitMutWithAstPath for Option { + #[doc = "Calls [VisitMutAstPath`::visit_mut_opt_ts_import_call_options`] with `self`. (Extra \ + impl)"] + #[inline] + fn visit_mut_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { + ::visit_mut_opt_ts_import_call_options(visitor, self, __ast_path) + } + + #[inline] + fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { + match self { + Some(inner) => { + >::visit_mut_with_ast_path( + inner, visitor, __ast_path, + ) + } + None => {} + } + } +} +#[cfg(any(docsrs, feature = "path"))] +#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl VisitMutWithAstPath for Option { #[doc = "Calls [VisitMutAstPath`::visit_mut_opt_ts_namespace_body`] with `self`. (Extra impl)"] #[inline] @@ -92138,6 +92731,16 @@ pub trait Fold { fn fold_opt_ts_entity_name(&mut self, node: Option) -> Option { as FoldWith>::fold_children_with(node, self) } + #[doc = "Visit a node of type `Option < TsImportCallOptions >`.\n\nBy default, this method \ + calls [`Option < TsImportCallOptions >::fold_children_with`]. If you want to recurse, \ + you need to call it manually."] + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + ) -> Option { + as FoldWith>::fold_children_with(node, self) + } #[doc = "Visit a node of type `Option < TsNamespaceBody >`.\n\nBy default, this method calls \ [`Option < TsNamespaceBody >::fold_children_with`]. If you want to recurse, you need \ to call it manually."] @@ -92653,6 +93256,13 @@ pub trait Fold { fn fold_ts_getter_signature(&mut self, node: TsGetterSignature) -> TsGetterSignature { >::fold_children_with(node, self) } + #[doc = "Visit a node of type `TsImportCallOptions`.\n\nBy default, this method calls \ + [`TsImportCallOptions::fold_children_with`]. If you want to recurse, you need to call \ + it manually."] + #[inline] + fn fold_ts_import_call_options(&mut self, node: TsImportCallOptions) -> TsImportCallOptions { + >::fold_children_with(node, self) + } #[doc = "Visit a node of type `TsImportEqualsDecl`.\n\nBy default, this method calls \ [`TsImportEqualsDecl::fold_children_with`]. If you want to recurse, you need to call \ it manually."] @@ -93921,6 +94531,14 @@ where ::fold_opt_ts_entity_name(&mut **self, node) } + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + ) -> Option { + ::fold_opt_ts_import_call_options(&mut **self, node) + } + #[inline] fn fold_opt_ts_namespace_body( &mut self, @@ -94308,6 +94926,11 @@ where ::fold_ts_getter_signature(&mut **self, node) } + #[inline] + fn fold_ts_import_call_options(&mut self, node: TsImportCallOptions) -> TsImportCallOptions { + ::fold_ts_import_call_options(&mut **self, node) + } + #[inline] fn fold_ts_import_equals_decl(&mut self, node: TsImportEqualsDecl) -> TsImportEqualsDecl { ::fold_ts_import_equals_decl(&mut **self, node) @@ -95437,6 +96060,14 @@ where ::fold_opt_ts_entity_name(&mut **self, node) } + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + ) -> Option { + ::fold_opt_ts_import_call_options(&mut **self, node) + } + #[inline] fn fold_opt_ts_namespace_body( &mut self, @@ -95824,6 +96455,11 @@ where ::fold_ts_getter_signature(&mut **self, node) } + #[inline] + fn fold_ts_import_call_options(&mut self, node: TsImportCallOptions) -> TsImportCallOptions { + ::fold_ts_import_call_options(&mut **self, node) + } + #[inline] fn fold_ts_import_equals_decl(&mut self, node: TsImportEqualsDecl) -> TsImportEqualsDecl { ::fold_ts_import_equals_decl(&mut **self, node) @@ -97402,6 +98038,21 @@ where } } + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + ) -> Option { + match self { + swc_visit::Either::Left(visitor) => { + Fold::fold_opt_ts_import_call_options(visitor, node) + } + swc_visit::Either::Right(visitor) => { + Fold::fold_opt_ts_import_call_options(visitor, node) + } + } + } + #[inline] fn fold_opt_ts_namespace_body( &mut self, @@ -98015,6 +98666,14 @@ where } } + #[inline] + fn fold_ts_import_call_options(&mut self, node: TsImportCallOptions) -> TsImportCallOptions { + match self { + swc_visit::Either::Left(visitor) => Fold::fold_ts_import_call_options(visitor, node), + swc_visit::Either::Right(visitor) => Fold::fold_ts_import_call_options(visitor, node), + } + } + #[inline] fn fold_ts_import_equals_decl(&mut self, node: TsImportEqualsDecl) -> TsImportEqualsDecl { match self { @@ -99957,6 +100616,18 @@ where } } + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + ) -> Option { + if self.enabled { + ::fold_opt_ts_import_call_options(&mut self.visitor, node) + } else { + node + } + } + #[inline] fn fold_opt_ts_namespace_body( &mut self, @@ -100632,6 +101303,15 @@ where } } + #[inline] + fn fold_ts_import_call_options(&mut self, node: TsImportCallOptions) -> TsImportCallOptions { + if self.enabled { + ::fold_ts_import_call_options(&mut self.visitor, node) + } else { + node + } + } + #[inline] fn fold_ts_import_equals_decl(&mut self, node: TsImportEqualsDecl) -> TsImportEqualsDecl { if self.enabled { @@ -105437,6 +106117,22 @@ impl FoldWith for TsGetterSignature { } } } +impl FoldWith for TsImportCallOptions { + #[doc = "Calls [Fold`::fold_ts_import_call_options`] with `self`."] + fn fold_with(self, visitor: &mut V) -> Self { + ::fold_ts_import_call_options(visitor, self) + } + + fn fold_children_with(self, visitor: &mut V) -> Self { + match self { + TsImportCallOptions { span, with } => { + let span = { >::fold_with(span, visitor) }; + let with = { as FoldWith>::fold_with(with, visitor) }; + TsImportCallOptions { span, with } + } + } + } +} impl FoldWith for TsImportEqualsDecl { #[doc = "Calls [Fold`::fold_ts_import_equals_decl`] with `self`."] fn fold_with(self, visitor: &mut V) -> Self { @@ -105479,7 +106175,7 @@ impl FoldWith for TsImportType { arg, qualifier, type_args, - with, + attributes, } => { let span = { >::fold_with(span, visitor) }; let arg = { >::fold_with(arg, visitor) }; @@ -105490,13 +106186,15 @@ impl FoldWith for TsImportType { type_args, visitor, ) }; - let with = { > as FoldWith>::fold_with(with, visitor) }; + let attributes = { + as FoldWith>::fold_with(attributes, visitor) + }; TsImportType { span, arg, qualifier, type_args, - with, + attributes, } } } @@ -107393,6 +108091,18 @@ impl FoldWith for Option { self.map(|inner| >::fold_with(inner, visitor)) } } +impl FoldWith for Option { + #[doc = "Calls [Fold`::fold_opt_ts_import_call_options`] with `self`. (Extra impl)"] + #[inline] + fn fold_with(self, visitor: &mut V) -> Self { + ::fold_opt_ts_import_call_options(visitor, self) + } + + #[inline] + fn fold_children_with(self, visitor: &mut V) -> Self { + self.map(|inner| >::fold_with(inner, visitor)) + } +} impl FoldWith for Option { #[doc = "Calls [Fold`::fold_opt_ts_namespace_body`] with `self`. (Extra impl)"] #[inline] @@ -109230,6 +109940,19 @@ pub trait FoldAstPath { node, self, __ast_path, ) } + #[doc = "Visit a node of type `Option < TsImportCallOptions >`.\n\nBy default, this method \ + calls [`Option < TsImportCallOptions >::fold_children_with_ast_path`]. If you want to \ + recurse, you need to call it manually."] + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + __ast_path: &mut AstKindPath, + ) -> Option { + as FoldWithAstPath>::fold_children_with_ast_path( + node, self, __ast_path, + ) + } #[doc = "Visit a node of type `Option < TsNamespaceBody >`.\n\nBy default, this method calls \ [`Option < TsNamespaceBody >::fold_children_with_ast_path`]. If you want to recurse, \ you need to call it manually."] @@ -109965,6 +110688,19 @@ pub trait FoldAstPath { node, self, __ast_path, ) } + #[doc = "Visit a node of type `TsImportCallOptions`.\n\nBy default, this method calls \ + [`TsImportCallOptions::fold_children_with_ast_path`]. If you want to recurse, you \ + need to call it manually."] + #[inline] + fn fold_ts_import_call_options( + &mut self, + node: TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) -> TsImportCallOptions { + >::fold_children_with_ast_path( + node, self, __ast_path, + ) + } #[doc = "Visit a node of type `TsImportEqualsDecl`.\n\nBy default, this method calls \ [`TsImportEqualsDecl::fold_children_with_ast_path`]. If you want to recurse, you need \ to call it manually."] @@ -111835,6 +112571,15 @@ where ::fold_opt_ts_entity_name(&mut **self, node, __ast_path) } + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + __ast_path: &mut AstKindPath, + ) -> Option { + ::fold_opt_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn fold_opt_ts_namespace_body( &mut self, @@ -112359,6 +113104,15 @@ where ::fold_ts_getter_signature(&mut **self, node, __ast_path) } + #[inline] + fn fold_ts_import_call_options( + &mut self, + node: TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) -> TsImportCallOptions { + ::fold_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn fold_ts_import_equals_decl( &mut self, @@ -114004,6 +114758,15 @@ where ::fold_opt_ts_entity_name(&mut **self, node, __ast_path) } + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + __ast_path: &mut AstKindPath, + ) -> Option { + ::fold_opt_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn fold_opt_ts_namespace_body( &mut self, @@ -114528,6 +115291,15 @@ where ::fold_ts_getter_signature(&mut **self, node, __ast_path) } + #[inline] + fn fold_ts_import_call_options( + &mut self, + node: TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) -> TsImportCallOptions { + ::fold_ts_import_call_options(&mut **self, node, __ast_path) + } + #[inline] fn fold_ts_import_equals_decl( &mut self, @@ -117162,6 +117934,22 @@ where } } + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + __ast_path: &mut AstKindPath, + ) -> Option { + match self { + swc_visit::Either::Left(visitor) => { + FoldAstPath::fold_opt_ts_import_call_options(visitor, node, __ast_path) + } + swc_visit::Either::Right(visitor) => { + FoldAstPath::fold_opt_ts_import_call_options(visitor, node, __ast_path) + } + } + } + #[inline] fn fold_opt_ts_namespace_body( &mut self, @@ -118142,6 +118930,22 @@ where } } + #[inline] + fn fold_ts_import_call_options( + &mut self, + node: TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) -> TsImportCallOptions { + match self { + swc_visit::Either::Left(visitor) => { + FoldAstPath::fold_ts_import_call_options(visitor, node, __ast_path) + } + swc_visit::Either::Right(visitor) => { + FoldAstPath::fold_ts_import_call_options(visitor, node, __ast_path) + } + } + } + #[inline] fn fold_ts_import_equals_decl( &mut self, @@ -120874,6 +121678,19 @@ where } } + #[inline] + fn fold_opt_ts_import_call_options( + &mut self, + node: Option, + __ast_path: &mut AstKindPath, + ) -> Option { + if self.enabled { + ::fold_opt_ts_import_call_options(&mut self.visitor, node, __ast_path) + } else { + node + } + } + #[inline] fn fold_opt_ts_namespace_body( &mut self, @@ -121694,6 +122511,19 @@ where } } + #[inline] + fn fold_ts_import_call_options( + &mut self, + node: TsImportCallOptions, + __ast_path: &mut AstKindPath, + ) -> TsImportCallOptions { + if self.enabled { + ::fold_ts_import_call_options(&mut self.visitor, node, __ast_path) + } else { + node + } + } + #[inline] fn fold_ts_import_equals_decl( &mut self, @@ -131348,6 +132178,42 @@ impl FoldWithAstPath for TsGetterSignature { } #[cfg(any(docsrs, feature = "path"))] #[cfg_attr(docsrs, doc(cfg(feature = "path")))] +impl FoldWithAstPath for TsImportCallOptions { + #[doc = "Calls [FoldAstPath`::fold_ts_import_call_options`] with `self`."] + fn fold_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { + ::fold_ts_import_call_options(visitor, self, __ast_path) + } + + fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { + match self { + TsImportCallOptions { span, with } => { + let span = { + let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportCallOptions( + self::fields::TsImportCallOptionsField::Span, + )); + >::fold_with_ast_path( + span, + visitor, + &mut *__ast_path, + ) + }; + let with = { + let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportCallOptions( + self::fields::TsImportCallOptionsField::With, + )); + > as FoldWithAstPath>::fold_with_ast_path( + with, + visitor, + &mut *__ast_path, + ) + }; + TsImportCallOptions { span, with } + } + } + } +} +#[cfg(any(docsrs, feature = "path"))] +#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl FoldWithAstPath for TsImportEqualsDecl { #[doc = "Calls [FoldAstPath`::fold_ts_import_equals_decl`] with `self`."] fn fold_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { @@ -131415,7 +132281,7 @@ impl FoldWithAstPath for TsImportType { arg, qualifier, type_args, - with, + attributes, } => { let span = { let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportType( @@ -131449,12 +132315,12 @@ impl FoldWithAstPath for TsImportType { )); < Option < Box < TsTypeParamInstantiation > > as FoldWithAstPath < V > > :: fold_with_ast_path (type_args , visitor , & mut * __ast_path) }; - let with = { + let attributes = { let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportType( - self::fields::TsImportTypeField::With, + self::fields::TsImportTypeField::Attributes, )); - > as FoldWithAstPath>::fold_with_ast_path( - with, + as FoldWithAstPath>::fold_with_ast_path( + attributes, visitor, &mut *__ast_path, ) @@ -131464,7 +132330,7 @@ impl FoldWithAstPath for TsImportType { arg, qualifier, type_args, - with, + attributes, } } } @@ -135138,6 +136004,24 @@ impl FoldWithAstPath for Option { } #[cfg(any(docsrs, feature = "path"))] #[cfg_attr(docsrs, doc(cfg(feature = "path")))] +impl FoldWithAstPath for Option { + #[doc = "Calls [FoldAstPath`::fold_opt_ts_import_call_options`] with `self`. (Extra impl)"] + #[inline] + fn fold_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { + ::fold_opt_ts_import_call_options(visitor, self, __ast_path) + } + + #[inline] + fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { + self.map(|inner| { + >::fold_with_ast_path( + inner, visitor, __ast_path, + ) + }) + } +} +#[cfg(any(docsrs, feature = "path"))] +#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl FoldWithAstPath for Option { #[doc = "Calls [FoldAstPath`::fold_opt_ts_namespace_body`] with `self`. (Extra impl)"] #[inline] @@ -138984,6 +139868,21 @@ pub mod fields { #[doc = "Represents [`TsGetterSignature::type_ann`]"] TypeAnn, } + impl TsImportCallOptionsField { + pub(crate) fn set_index(&mut self, index: usize) { + match self { + _ => swc_visit::wrong_ast_path(), + } + } + } + #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + #[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))] + pub enum TsImportCallOptionsField { + #[doc = "Represents [`TsImportCallOptions::span`]"] + Span, + #[doc = "Represents [`TsImportCallOptions::with`]"] + With, + } impl TsImportEqualsDeclField { pub(crate) fn set_index(&mut self, index: usize) { match self { @@ -139023,8 +139922,8 @@ pub mod fields { Qualifier, #[doc = "Represents [`TsImportType::type_args`]"] TypeArgs, - #[doc = "Represents [`TsImportType::with`]"] - With, + #[doc = "Represents [`TsImportType::attributes`]"] + Attributes, } impl TsIndexSignatureField { pub(crate) fn set_index(&mut self, index: usize) { @@ -140422,6 +141321,7 @@ pub mod fields { TsFnParam(TsFnParamField), TsFnType(TsFnTypeField), TsGetterSignature(TsGetterSignatureField), + TsImportCallOptions(TsImportCallOptionsField), TsImportEqualsDecl(TsImportEqualsDeclField), TsImportType(TsImportTypeField), TsIndexSignature(TsIndexSignatureField), @@ -140662,6 +141562,7 @@ pub mod fields { Self::TsFnParam(v) => v.set_index(index), Self::TsFnType(v) => v.set_index(index), Self::TsGetterSignature(v) => v.set_index(index), + Self::TsImportCallOptions(v) => v.set_index(index), Self::TsImportEqualsDecl(v) => v.set_index(index), Self::TsImportType(v) => v.set_index(index), Self::TsIndexSignature(v) => v.set_index(index), @@ -140908,6 +141809,7 @@ pub mod fields { TsFnParam(&'ast TsFnParam, TsFnParamField), TsFnType(&'ast TsFnType, TsFnTypeField), TsGetterSignature(&'ast TsGetterSignature, TsGetterSignatureField), + TsImportCallOptions(&'ast TsImportCallOptions, TsImportCallOptionsField), TsImportEqualsDecl(&'ast TsImportEqualsDecl, TsImportEqualsDeclField), TsImportType(&'ast TsImportType, TsImportTypeField), TsIndexSignature(&'ast TsIndexSignature, TsIndexSignatureField), @@ -141160,6 +142062,7 @@ pub mod fields { Self::TsFnParam(_, __field_kind) => __field_kind.set_index(index), Self::TsFnType(_, __field_kind) => __field_kind.set_index(index), Self::TsGetterSignature(_, __field_kind) => __field_kind.set_index(index), + Self::TsImportCallOptions(_, __field_kind) => __field_kind.set_index(index), Self::TsImportEqualsDecl(_, __field_kind) => __field_kind.set_index(index), Self::TsImportType(_, __field_kind) => __field_kind.set_index(index), Self::TsIndexSignature(_, __field_kind) => __field_kind.set_index(index), @@ -141481,6 +142384,9 @@ pub mod fields { Self::TsGetterSignature(_, __field_kind) => { AstParentKind::TsGetterSignature(*__field_kind) } + Self::TsImportCallOptions(_, __field_kind) => { + AstParentKind::TsImportCallOptions(*__field_kind) + } Self::TsImportEqualsDecl(_, __field_kind) => { AstParentKind::TsImportEqualsDecl(*__field_kind) } @@ -142456,6 +143362,11 @@ impl<'ast> From<&'ast TsGetterSignature> for NodeRef<'ast> { NodeRef::TsGetterSignature(node) } } +impl<'ast> From<&'ast TsImportCallOptions> for NodeRef<'ast> { + fn from(node: &'ast TsImportCallOptions) -> Self { + NodeRef::TsImportCallOptions(node) + } +} impl<'ast> From<&'ast TsImportEqualsDecl> for NodeRef<'ast> { fn from(node: &'ast TsImportEqualsDecl) -> Self { NodeRef::TsImportEqualsDecl(node) @@ -142957,6 +143868,7 @@ pub enum NodeRef<'ast> { TsFnParam(&'ast TsFnParam), TsFnType(&'ast TsFnType), TsGetterSignature(&'ast TsGetterSignature), + TsImportCallOptions(&'ast TsImportCallOptions), TsImportEqualsDecl(&'ast TsImportEqualsDecl), TsImportType(&'ast TsImportType), TsIndexSignature(&'ast TsIndexSignature), @@ -144724,6 +145636,12 @@ impl<'ast> NodeRef<'ast> { })); Box::new(iterator) } + NodeRef::TsImportCallOptions(node) => { + let iterator = ::std::iter::empty::>().chain( + ::std::iter::once(NodeRef::ObjectLit(&node.with)) + ); + Box::new(iterator) + } NodeRef::TsImportEqualsDecl(node) => { let iterator = ::std::iter::empty::>() .chain(::std::iter::once(NodeRef::Ident(&node.id))) @@ -144731,7 +145649,8 @@ impl<'ast> NodeRef<'ast> { Box::new(iterator) } NodeRef::TsImportType(node) => { - let iterator = ::std::iter::empty::>() + let iterator = + ::std::iter::empty::>() .chain(::std::iter::once(NodeRef::Str(&node.arg))) .chain( node.qualifier @@ -144742,9 +145661,8 @@ impl<'ast> NodeRef<'ast> { let item = &*item; ::std::iter::once(NodeRef::TsTypeParamInstantiation(&item)) })) - .chain(node.with.iter().flat_map(|item| { - let item = &*item; - ::std::iter::once(NodeRef::ObjectLit(&item)) + .chain(node.attributes.iter().flat_map(|item| { + ::std::iter::once(NodeRef::TsImportCallOptions(&item)) })); Box::new(iterator) } From f9abcd42075552b69fc9df02f256e8eb18e260a3 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 31 Jan 2025 13:23:23 -0500 Subject: [PATCH 04/11] Update swc_ecma_codegen --- crates/swc_ecma_codegen/src/typescript.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/swc_ecma_codegen/src/typescript.rs b/crates/swc_ecma_codegen/src/typescript.rs index fde3d6e64493..bc949add30bf 100644 --- a/crates/swc_ecma_codegen/src/typescript.rs +++ b/crates/swc_ecma_codegen/src/typescript.rs @@ -863,14 +863,20 @@ where #[emitter] fn emit_ts_import_call_options(&mut self, n: &TsImportCallOptions) -> Result { punct!("{"); - - if let Some(with) = &n.with { - keyword!("with"); - punct!(":"); - formatting_space!(); - emit!(with); + if !self.cfg.minify { + self.wr.write_line()?; + self.wr.increase_indent()?; } + keyword!("with"); + punct!(":"); + formatting_space!(); + emit!(n.with); + + if !self.cfg.minify { + self.wr.decrease_indent()?; + self.wr.write_line()?; + } punct!("}"); } From 1ac5b26c140b1d87ef91ee1f23a2a11cae5d6c24 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 31 Jan 2025 13:23:30 -0500 Subject: [PATCH 05/11] update expectations --- .../tsc/allowImportingTypesDtsExtension.json | 3 +- .../tests/tsc/allowsImportingTsExtension.json | 6 +- .../tests/tsc/importTypeAmbient.json | 9 ++- .../tests/tsc/importTypeAmbientMissing.json | 3 +- .../tests/tsc/importTypeAmdBundleRewrite.json | 6 +- .../tests/tsc/importTypeGenericTypes.json | 9 ++- .../tests/tsc/importTypeLocal.json | 9 ++- .../tests/tsc/importTypeLocalMissing.json | 12 ++- .../tests/tsc/moduleExportAssignment7.json | 42 ++++++---- .../tests/tsc/privateNamesUnique-2.json | 3 +- .../verbatimModuleSyntaxRestrictionsCJS.json | 3 +- .../import-type/typeof/as/input.ts.json | 3 +- .../import-type/typeof/simple/input.ts.json | 3 +- .../tests/typescript/issue-9802/input.ts.json | 9 ++- .../typescript/ts-import-type/input.ts.json | 77 ++++++++----------- .../typescript/vercel/web-875/input.ts.json | 3 +- 16 files changed, 114 insertions(+), 86 deletions(-) diff --git a/crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.json b/crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.json index ad67b62dc3d3..60fb86d6e314 100644 --- a/crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.json +++ b/crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.json @@ -332,7 +332,8 @@ "value": "User", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } diff --git a/crates/swc_ecma_parser/tests/tsc/allowsImportingTsExtension.json b/crates/swc_ecma_parser/tests/tsc/allowsImportingTsExtension.json index c2c0aa3e78db..b1519f8bc53f 100644 --- a/crates/swc_ecma_parser/tests/tsc/allowsImportingTsExtension.json +++ b/crates/swc_ecma_parser/tests/tsc/allowsImportingTsExtension.json @@ -223,7 +223,8 @@ "value": "A", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } }, { @@ -440,7 +441,8 @@ "value": "A", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } }, { diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeAmbient.json b/crates/swc_ecma_parser/tests/tsc/importTypeAmbient.json index a7682324bb8b..a3c057314a8f 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeAmbient.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeAmbient.json @@ -195,7 +195,8 @@ "raw": "\"foo\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, @@ -775,7 +776,8 @@ "value": "I" } }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, @@ -1120,7 +1122,8 @@ "raw": "\"foo2\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeAmbientMissing.json b/crates/swc_ecma_parser/tests/tsc/importTypeAmbientMissing.json index 1b7a06f73ef4..56b7a85f8219 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeAmbientMissing.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeAmbientMissing.json @@ -195,7 +195,8 @@ "raw": "\"fo\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeAmdBundleRewrite.json b/crates/swc_ecma_parser/tests/tsc/importTypeAmdBundleRewrite.json index 1ced63208a66..c20aba5afeed 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeAmdBundleRewrite.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeAmdBundleRewrite.json @@ -140,7 +140,8 @@ "value": "Foo", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, @@ -268,7 +269,8 @@ "raw": "\"./a/inner\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null }, diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeGenericTypes.json b/crates/swc_ecma_parser/tests/tsc/importTypeGenericTypes.json index d160196e434e..44201af0c0b1 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeGenericTypes.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeGenericTypes.json @@ -1018,7 +1018,8 @@ ] } ] - } + }, + "attributes": null } } }, @@ -1245,7 +1246,8 @@ ] } ] - } + }, + "attributes": null } } }, @@ -1719,7 +1721,8 @@ "raw": "\"./foo2\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeLocal.json b/crates/swc_ecma_parser/tests/tsc/importTypeLocal.json index 752afc149b4d..d71256568572 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeLocal.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeLocal.json @@ -659,7 +659,8 @@ "raw": "\"./foo\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, @@ -794,7 +795,8 @@ "value": "I" } }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, @@ -1153,7 +1155,8 @@ "raw": "\"./foo2\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeLocalMissing.json b/crates/swc_ecma_parser/tests/tsc/importTypeLocalMissing.json index 66dcf7d3b261..f34451f58384 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeLocalMissing.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeLocalMissing.json @@ -659,7 +659,8 @@ "raw": "\"./fo\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, @@ -794,7 +795,8 @@ "value": "I" } }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, @@ -929,7 +931,8 @@ "value": "Q" } }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } }, @@ -1288,7 +1291,8 @@ "raw": "\"./fo2\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/tsc/moduleExportAssignment7.json b/crates/swc_ecma_parser/tests/tsc/moduleExportAssignment7.json index db8325a80f30..d78ec0f4e569 100644 --- a/crates/swc_ecma_parser/tests/tsc/moduleExportAssignment7.json +++ b/crates/swc_ecma_parser/tests/tsc/moduleExportAssignment7.json @@ -1216,7 +1216,8 @@ "value": "Thing", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } @@ -1268,7 +1269,8 @@ "value": "AnotherThing", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } @@ -1320,7 +1322,8 @@ "value": "foo", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } @@ -1372,7 +1375,8 @@ "value": "qux", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } @@ -1424,7 +1428,8 @@ "value": "baz", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } @@ -1476,7 +1481,8 @@ "value": "buz", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } @@ -1528,7 +1534,8 @@ "value": "literal", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } @@ -1832,7 +1839,8 @@ "value": "Thing", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } @@ -1892,7 +1900,8 @@ "value": "AnotherThing", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } @@ -1952,7 +1961,8 @@ "value": "foo", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } @@ -2012,7 +2022,8 @@ "value": "qux", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } @@ -2072,7 +2083,8 @@ "value": "baz", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } @@ -2132,7 +2144,8 @@ "value": "buz", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } @@ -2192,7 +2205,8 @@ "value": "literal", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.json b/crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.json index 56d800522c0a..5717b8dad8e9 100644 --- a/crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.json +++ b/crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.json @@ -119,7 +119,8 @@ "value": "Foo", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null } } } diff --git a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsCJS.json b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsCJS.json index b69d3f669f96..f5d8fe14ffee 100644 --- a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsCJS.json +++ b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsCJS.json @@ -442,7 +442,8 @@ "raw": "\"./decl\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/typescript/custom/import-type/typeof/as/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/import-type/typeof/as/input.ts.json index ef79b24b9494..eed74d9ac5af 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/import-type/typeof/as/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/import-type/typeof/as/input.ts.json @@ -93,7 +93,8 @@ "raw": "\"tty\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/typescript/custom/import-type/typeof/simple/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/import-type/typeof/simple/input.ts.json index 0fef4713d0ad..f251e706f381 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/import-type/typeof/simple/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/import-type/typeof/simple/input.ts.json @@ -58,7 +58,8 @@ "raw": "\"readline\"" }, "qualifier": null, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/typescript/issue-9802/input.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-9802/input.ts.json index 5a808ca0edbd..cad7fb9ab74e 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-9802/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-9802/input.ts.json @@ -1310,7 +1310,8 @@ "kind": "number" } ] - } + }, + "attributes": null } } }, @@ -1528,10 +1529,12 @@ "kind": "number" } ] - } + }, + "attributes": null } ] - } + }, + "attributes": null } } } diff --git a/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts.json b/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts.json index 1ac01a34a19f..ad02f985cfaa 100644 --- a/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/ts-import-type/input.ts.json @@ -46,55 +46,42 @@ }, "qualifier": null, "typeArguments": null, - "with": { - "type": "ObjectExpression", + "attributes": { + "type": "TsImportCallOptions", "span": { "start": 35, "end": 86 }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 39, - "end": 43 + "with": { + "type": "ObjectExpression", + "span": { + "start": 45, + "end": 84 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "StringLiteral", + "span": { + "start": 53, + "end": 70 + }, + "value": "resolution-mode", + "raw": "\"resolution-mode\"" }, - "value": "with" - }, - "value": { - "type": "ObjectExpression", - "span": { - "start": 45, - "end": 84 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "StringLiteral", - "span": { - "start": 53, - "end": 70 - }, - "value": "resolution-mode", - "raw": "\"resolution-mode\"" - }, - "value": { - "type": "StringLiteral", - "span": { - "start": 72, - "end": 80 - }, - "value": "import", - "raw": "\"import\"" - } - } - ] + "value": { + "type": "StringLiteral", + "span": { + "start": 72, + "end": 80 + }, + "value": "import", + "raw": "\"import\"" + } } - } - ] + ] + } } }, "typeArguments": null @@ -141,7 +128,7 @@ }, "qualifier": null, "typeArguments": null, - "with": null + "attributes": null }, "typeArguments": null } @@ -187,7 +174,7 @@ }, "qualifier": null, "typeArguments": null, - "with": null + "attributes": null }, "typeArguments": null } diff --git a/crates/swc_ecma_parser/tests/typescript/vercel/web-875/input.ts.json b/crates/swc_ecma_parser/tests/typescript/vercel/web-875/input.ts.json index f1a9ba13fb3d..8e7b709dcc61 100644 --- a/crates/swc_ecma_parser/tests/typescript/vercel/web-875/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/vercel/web-875/input.ts.json @@ -373,7 +373,8 @@ "value": "default", "optional": false }, - "typeArguments": null + "typeArguments": null, + "attributes": null }, "typeArguments": null } From 4d891f873664003ee6737581d14be1266b69ec19 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 31 Jan 2025 13:29:57 -0500 Subject: [PATCH 06/11] Fix unused --- crates/swc_ecma_transforms_typescript/src/typescript.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/swc_ecma_transforms_typescript/src/typescript.rs b/crates/swc_ecma_transforms_typescript/src/typescript.rs index 2918d7befe7b..2dcf624363c4 100644 --- a/crates/swc_ecma_transforms_typescript/src/typescript.rs +++ b/crates/swc_ecma_transforms_typescript/src/typescript.rs @@ -1,6 +1,5 @@ use std::mem; -use once_cell::sync::Lazy; use swc_common::{ collections::AHashSet, comments::Comments, sync::Lrc, util::take::Take, Mark, SourceMap, Span, Spanned, @@ -15,7 +14,7 @@ use crate::{strip_import_export::StripImportExport, strip_type::StripType, trans #[cfg(feature = "concurrent")] macro_rules! static_str { ($s:expr) => {{ - static VAL: Lazy> = Lazy::new(|| Lrc::new($s.into())); + static VAL: once_cell::sync::Lazy> = once_cell::sync::Lazy::new(|| Lrc::new($s.into())); VAL.clone() }}; } From 19581c20c96df2c41506974df47f374acaa39f8f Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 31 Jan 2025 13:31:43 -0500 Subject: [PATCH 07/11] format --- crates/swc_ecma_ast/src/lib.rs | 22 +++++++-------- .../swc_ecma_parser/src/parser/typescript.rs | 11 ++++---- .../src/typescript.rs | 3 ++- crates/swc_ecma_visit/src/generated.rs | 27 +++++++++---------- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/crates/swc_ecma_ast/src/lib.rs b/crates/swc_ecma_ast/src/lib.rs index 601c762c414d..50cbe1598353 100644 --- a/crates/swc_ecma_ast/src/lib.rs +++ b/crates/swc_ecma_ast/src/lib.rs @@ -60,17 +60,17 @@ pub use self::{ TsConditionalType, TsConstAssertion, TsConstructSignatureDecl, TsConstructorType, TsEntityName, TsEnumDecl, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExprWithTypeArgs, TsExternalModuleRef, TsFnOrConstructorType, TsFnParam, TsFnType, - TsGetterSignature, TsImportEqualsDecl, TsImportType, TsIndexSignature, TsIndexedAccessType, - TsInferType, TsInstantiation, TsInterfaceBody, TsInterfaceDecl, TsIntersectionType, - TsKeywordType, TsKeywordTypeKind, TsLit, TsLitType, TsMappedType, TsMethodSignature, - TsModuleBlock, TsModuleDecl, TsModuleName, TsModuleRef, TsNamespaceBody, TsNamespaceDecl, - TsNamespaceExportDecl, TsNonNullExpr, TsOptionalType, TsParamProp, TsParamPropParam, - TsParenthesizedType, TsPropertySignature, TsQualifiedName, TsRestType, TsSatisfiesExpr, - TsSetterSignature, TsThisType, TsThisTypeOrIdent, TsTplLitType, TsTupleElement, - TsTupleType, TsType, TsTypeAliasDecl, TsTypeAnn, TsTypeAssertion, TsTypeElement, TsTypeLit, - TsTypeOperator, TsTypeOperatorOp, TsTypeParam, TsTypeParamDecl, TsTypeParamInstantiation, - TsTypePredicate, TsTypeQuery, TsTypeQueryExpr, TsTypeRef, TsUnionOrIntersectionType, - TsUnionType, TsImportCallOptions + TsGetterSignature, TsImportCallOptions, TsImportEqualsDecl, TsImportType, TsIndexSignature, + TsIndexedAccessType, TsInferType, TsInstantiation, TsInterfaceBody, TsInterfaceDecl, + TsIntersectionType, TsKeywordType, TsKeywordTypeKind, TsLit, TsLitType, TsMappedType, + TsMethodSignature, TsModuleBlock, TsModuleDecl, TsModuleName, TsModuleRef, TsNamespaceBody, + TsNamespaceDecl, TsNamespaceExportDecl, TsNonNullExpr, TsOptionalType, TsParamProp, + TsParamPropParam, TsParenthesizedType, TsPropertySignature, TsQualifiedName, TsRestType, + TsSatisfiesExpr, TsSetterSignature, TsThisType, TsThisTypeOrIdent, TsTplLitType, + TsTupleElement, TsTupleType, TsType, TsTypeAliasDecl, TsTypeAnn, TsTypeAssertion, + TsTypeElement, TsTypeLit, TsTypeOperator, TsTypeOperatorOp, TsTypeParam, TsTypeParamDecl, + TsTypeParamInstantiation, TsTypePredicate, TsTypeQuery, TsTypeQueryExpr, TsTypeRef, + TsUnionOrIntersectionType, TsUnionType, }, }; diff --git a/crates/swc_ecma_parser/src/parser/typescript.rs b/crates/swc_ecma_parser/src/parser/typescript.rs index 29a41d7edff9..5ccacc053ba9 100644 --- a/crates/swc_ecma_parser/src/parser/typescript.rs +++ b/crates/swc_ecma_parser/src/parser/typescript.rs @@ -318,11 +318,12 @@ impl Parser { // the "assert" keyword is deprecated and this syntax is niche, so // don't support it - let attributes = if eat!(self, ',') && self.input.syntax().import_attributes() && is!(self, '{') { - Some(self.parse_ts_call_options()?) - } else { - None - }; + let attributes = + if eat!(self, ',') && self.input.syntax().import_attributes() && is!(self, '{') { + Some(self.parse_ts_call_options()?) + } else { + None + }; expect!(self, ')'); diff --git a/crates/swc_ecma_transforms_typescript/src/typescript.rs b/crates/swc_ecma_transforms_typescript/src/typescript.rs index 2dcf624363c4..b1aeb2fe01b5 100644 --- a/crates/swc_ecma_transforms_typescript/src/typescript.rs +++ b/crates/swc_ecma_transforms_typescript/src/typescript.rs @@ -14,7 +14,8 @@ use crate::{strip_import_export::StripImportExport, strip_type::StripType, trans #[cfg(feature = "concurrent")] macro_rules! static_str { ($s:expr) => {{ - static VAL: once_cell::sync::Lazy> = once_cell::sync::Lazy::new(|| Lrc::new($s.into())); + static VAL: once_cell::sync::Lazy> = + once_cell::sync::Lazy::new(|| Lrc::new($s.into())); VAL.clone() }}; } diff --git a/crates/swc_ecma_visit/src/generated.rs b/crates/swc_ecma_visit/src/generated.rs index 23a133cee205..d82d3dd39e69 100644 --- a/crates/swc_ecma_visit/src/generated.rs +++ b/crates/swc_ecma_visit/src/generated.rs @@ -145637,9 +145637,8 @@ impl<'ast> NodeRef<'ast> { Box::new(iterator) } NodeRef::TsImportCallOptions(node) => { - let iterator = ::std::iter::empty::>().chain( - ::std::iter::once(NodeRef::ObjectLit(&node.with)) - ); + let iterator = ::std::iter::empty::>() + .chain(::std::iter::once(NodeRef::ObjectLit(&node.with))); Box::new(iterator) } NodeRef::TsImportEqualsDecl(node) => { @@ -145651,19 +145650,19 @@ impl<'ast> NodeRef<'ast> { NodeRef::TsImportType(node) => { let iterator = ::std::iter::empty::>() - .chain(::std::iter::once(NodeRef::Str(&node.arg))) - .chain( - node.qualifier - .iter() - .flat_map(|item| ::std::iter::once(NodeRef::TsEntityName(&item))), - ) - .chain(node.type_args.iter().flat_map(|item| { - let item = &*item; - ::std::iter::once(NodeRef::TsTypeParamInstantiation(&item)) - })) + .chain(::std::iter::once(NodeRef::Str(&node.arg))) + .chain( + node.qualifier + .iter() + .flat_map(|item| ::std::iter::once(NodeRef::TsEntityName(&item))), + ) + .chain(node.type_args.iter().flat_map(|item| { + let item = &*item; + ::std::iter::once(NodeRef::TsTypeParamInstantiation(&item)) + })) .chain(node.attributes.iter().flat_map(|item| { ::std::iter::once(NodeRef::TsImportCallOptions(&item)) - })); + })); Box::new(iterator) } NodeRef::TsIndexSignature(node) => { From 2c4961a1ccf41d12864f6d34eb8659a3341eac1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sat, 1 Feb 2025 20:24:49 +0900 Subject: [PATCH 08/11] GEN --- crates/swc_css_visit/src/generated.rs | 4 +++- crates/swc_ecma_visit/src/generated.rs | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/swc_css_visit/src/generated.rs b/crates/swc_css_visit/src/generated.rs index a7973ca8edba..7334bdd9907b 100644 --- a/crates/swc_css_visit/src/generated.rs +++ b/crates/swc_css_visit/src/generated.rs @@ -84590,7 +84590,9 @@ impl FoldWith for Token { let raw = { >::fold_with(raw, visitor) }; Token::BadUrl { raw } } - Token::Delim { value } => Token::Delim { value }, + Token::Delim { value } => { + Token::Delim { value } + } Token::Number { value, raw, diff --git a/crates/swc_ecma_visit/src/generated.rs b/crates/swc_ecma_visit/src/generated.rs index d82d3dd39e69..b25c4e198666 100644 --- a/crates/swc_ecma_visit/src/generated.rs +++ b/crates/swc_ecma_visit/src/generated.rs @@ -43193,7 +43193,7 @@ impl VisitWithAstPath for TsImportCallOptions { self, self::fields::TsImportCallOptionsField::With, )); - > as VisitWithAstPath>::visit_with_ast_path( + as VisitWithAstPath>::visit_with_ast_path( with, visitor, &mut *__ast_path, @@ -87559,7 +87559,7 @@ impl VisitMutWithAstPath for TsImportCallOptions let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportCallOptions( self::fields::TsImportCallOptionsField::With, )); - > as VisitMutWithAstPath>::visit_mut_with_ast_path( + as VisitMutWithAstPath>::visit_mut_with_ast_path( with, visitor, &mut *__ast_path, @@ -132201,7 +132201,7 @@ impl FoldWithAstPath for TsImportCallOptions { let mut __ast_path = __ast_path.with_guard(AstParentKind::TsImportCallOptions( self::fields::TsImportCallOptionsField::With, )); - > as FoldWithAstPath>::fold_with_ast_path( + as FoldWithAstPath>::fold_with_ast_path( with, visitor, &mut *__ast_path, @@ -145637,8 +145637,10 @@ impl<'ast> NodeRef<'ast> { Box::new(iterator) } NodeRef::TsImportCallOptions(node) => { - let iterator = ::std::iter::empty::>() - .chain(::std::iter::once(NodeRef::ObjectLit(&node.with))); + let iterator = ::std::iter::empty::>().chain({ + let item = &*node.with; + ::std::iter::once(NodeRef::ObjectLit(&item)) + }); Box::new(iterator) } NodeRef::TsImportEqualsDecl(node) => { From 6d64b02e3018651312a69c051d0818e46a8fefc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Sat, 1 Feb 2025 20:28:44 +0900 Subject: [PATCH 09/11] fmt --- crates/swc_css_visit/src/generated.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/swc_css_visit/src/generated.rs b/crates/swc_css_visit/src/generated.rs index 7334bdd9907b..a7973ca8edba 100644 --- a/crates/swc_css_visit/src/generated.rs +++ b/crates/swc_css_visit/src/generated.rs @@ -84590,9 +84590,7 @@ impl FoldWith for Token { let raw = { >::fold_with(raw, visitor) }; Token::BadUrl { raw } } - Token::Delim { value } => { - Token::Delim { value } - } + Token::Delim { value } => Token::Delim { value }, Token::Number { value, raw, From e233e793d370e5b145eeeb8073beacdf18439e86 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 4 Feb 2025 11:42:44 -0500 Subject: [PATCH 10/11] fix merge --- crates/swc_ecma_transforms_typescript/src/typescript.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/swc_ecma_transforms_typescript/src/typescript.rs b/crates/swc_ecma_transforms_typescript/src/typescript.rs index 501d0dbc092c..06ae673bda6f 100644 --- a/crates/swc_ecma_transforms_typescript/src/typescript.rs +++ b/crates/swc_ecma_transforms_typescript/src/typescript.rs @@ -1,9 +1,5 @@ use std::mem; -use swc_common::{ - collections::AHashSet, comments::Comments, sync::Lrc, util::take::Take, Mark, SourceMap, Span, - Spanned, -}; use once_cell::sync::Lazy; use rustc_hash::FxHashSet; use swc_common::{comments::Comments, sync::Lrc, util::take::Take, Mark, SourceMap, Span, Spanned}; From b26878b219c0b1a3e177392dbdd7cf6475d7eda0 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 4 Feb 2025 11:58:25 -0500 Subject: [PATCH 11/11] clippy --- crates/swc_ecma_transforms_typescript/src/typescript.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/swc_ecma_transforms_typescript/src/typescript.rs b/crates/swc_ecma_transforms_typescript/src/typescript.rs index 06ae673bda6f..eaa698c8418f 100644 --- a/crates/swc_ecma_transforms_typescript/src/typescript.rs +++ b/crates/swc_ecma_transforms_typescript/src/typescript.rs @@ -1,6 +1,5 @@ use std::mem; -use once_cell::sync::Lazy; use rustc_hash::FxHashSet; use swc_common::{comments::Comments, sync::Lrc, util::take::Take, Mark, SourceMap, Span, Spanned}; use swc_ecma_ast::*;