diff --git a/crates/swc/src/lib.rs b/crates/swc/src/lib.rs index c3a7968c0ac3..0a29f12587ed 100644 --- a/crates/swc/src/lib.rs +++ b/crates/swc/src/lib.rs @@ -1110,7 +1110,7 @@ impl Compiler { jsx: true, decorators: true, decorators_before_export: true, - import_assertions: true, + import_attributes: true, ..Default::default() }), IsModule::Bool(true), diff --git a/crates/swc_bundler/src/bundler/chunk/computed_key.rs b/crates/swc_bundler/src/bundler/chunk/computed_key.rs index 27ea5f3f70fe..660d1140a3b4 100644 --- a/crates/swc_bundler/src/bundler/chunk/computed_key.rs +++ b/crates/swc_bundler/src/bundler/chunk/computed_key.rs @@ -84,7 +84,7 @@ where specifiers: vec![specifier], src: None, type_only: false, - asserts: None, + with: None, })), )); } diff --git a/crates/swc_bundler/src/bundler/chunk/merge.rs b/crates/swc_bundler/src/bundler/chunk/merge.rs index d8c08cb83316..281725d4b81c 100644 --- a/crates/swc_bundler/src/bundler/chunk/merge.rs +++ b/crates/swc_bundler/src/bundler/chunk/merge.rs @@ -768,7 +768,7 @@ where specifiers: vec![specifier], src: None, type_only: false, - asserts: None, + with: None, }, ))); } @@ -816,7 +816,7 @@ where specifiers: vec![specifier], src: None, type_only: false, - asserts: None, + with: None, }, ))); } @@ -883,7 +883,7 @@ where .collect(), src: None, type_only: false, - asserts: None, + with: None, })); extra.push(export); continue; @@ -925,7 +925,7 @@ where specifiers: vec![specifier], src: None, type_only: false, - asserts: None, + with: None, }, ))); } @@ -1140,7 +1140,7 @@ where span: ns.span, specifiers: vec![specifier], src: None, - asserts: None, + with: None, type_only: false, }), )); diff --git a/crates/swc_bundler/src/bundler/import/mod.rs b/crates/swc_bundler/src/bundler/import/mod.rs index 7c3a56c98f1e..be8ab29a2c47 100644 --- a/crates/swc_bundler/src/bundler/import/mod.rs +++ b/crates/swc_bundler/src/bundler/import/mod.rs @@ -250,7 +250,7 @@ where specifiers: vec![], src: Box::new(src.clone()), type_only: false, - asserts: None, + with: None, }; if self.top_level { @@ -657,7 +657,7 @@ where .collect(), src: Box::new(src), type_only: false, - asserts: None, + with: None, }; // if self.top_level { diff --git a/crates/swc_bundler/src/bundler/load.rs b/crates/swc_bundler/src/bundler/load.rs index 19edeb4a9161..a50f6d0f2b82 100644 --- a/crates/swc_bundler/src/bundler/load.rs +++ b/crates/swc_bundler/src/bundler/load.rs @@ -304,7 +304,7 @@ where specifiers: vec![], src: Box::new(src), type_only: false, - asserts: None, + with: None, }, true, false, diff --git a/crates/swc_ecma_ast/src/module_decl.rs b/crates/swc_ecma_ast/src/module_decl.rs index 2de89636369a..368299b14097 100644 --- a/crates/swc_ecma_ast/src/module_decl.rs +++ b/crates/swc_ecma_ast/src/module_decl.rs @@ -84,7 +84,7 @@ pub struct ImportDecl { pub type_only: bool, #[cfg_attr(feature = "serde-impl", serde(default))] - pub asserts: Option>, + pub with: Option>, } impl Take for ImportDecl { @@ -94,7 +94,7 @@ impl Take for ImportDecl { specifiers: Take::dummy(), src: Take::dummy(), type_only: Default::default(), - asserts: Take::dummy(), + with: Take::dummy(), } } } @@ -113,7 +113,7 @@ pub struct ExportAll { pub type_only: bool, #[cfg_attr(feature = "serde-impl", serde(default))] - pub asserts: Option>, + pub with: Option>, } impl Take for ExportAll { @@ -122,7 +122,7 @@ impl Take for ExportAll { span: DUMMY_SP, src: Take::dummy(), type_only: Default::default(), - asserts: Take::dummy(), + with: Take::dummy(), } } } @@ -144,7 +144,7 @@ pub struct NamedExport { pub type_only: bool, #[cfg_attr(feature = "serde-impl", serde(default))] - pub asserts: Option>, + pub with: Option>, } impl Take for NamedExport { @@ -154,7 +154,7 @@ impl Take for NamedExport { specifiers: Take::dummy(), src: Take::dummy(), type_only: Default::default(), - asserts: Take::dummy(), + with: Take::dummy(), } } } diff --git a/crates/swc_ecma_codegen/src/lib.rs b/crates/swc_ecma_codegen/src/lib.rs index 7ea9a005dc16..16dfb9bb5074 100644 --- a/crates/swc_ecma_codegen/src/lib.rs +++ b/crates/swc_ecma_codegen/src/lib.rs @@ -308,11 +308,11 @@ where emit!(n.src); - if let Some(asserts) = &n.asserts { + if let Some(with) = &n.with { formatting_space!(); - keyword!("assert"); + keyword!("with"); formatting_space!(); - emit!(asserts); + emit!(with); } semi!(); @@ -451,11 +451,11 @@ where formatting_space!(); emit!(src); - if let Some(asserts) = &node.asserts { + if let Some(with) = &node.with { formatting_space!(); - keyword!("assert"); + keyword!("with"); formatting_space!(); - emit!(asserts); + emit!(with); } } semi!(); @@ -477,11 +477,11 @@ where formatting_space!(); emit!(node.src); - if let Some(asserts) = &node.asserts { + if let Some(with) = &node.with { formatting_space!(); - keyword!("assert"); + keyword!("with"); formatting_space!(); - emit!(asserts); + emit!(with); } semi!(); diff --git a/crates/swc_ecma_codegen/tests/fixture/issues/3110/output.js b/crates/swc_ecma_codegen/tests/fixture/issues/3110/output.js index 6d41a2485a89..f730093a0634 100644 --- a/crates/swc_ecma_codegen/tests/fixture/issues/3110/output.js +++ b/crates/swc_ecma_codegen/tests/fixture/issues/3110/output.js @@ -1,13 +1,13 @@ -import data from "./data.json" assert { +import data from "./data.json" with { type: "json" }; -import "./data2.json" assert { +import "./data2.json" with { type: "json" }; -export { default as data3 } from "./data3.json" assert { +export { default as data3 } from "./data3.json" with { type: "json" }; -export * as data4 from "./data4.json" assert { +export * as data4 from "./data4.json" with { type: "json" }; console.log(data); diff --git a/crates/swc_ecma_codegen/tests/fixture/issues/3110/output.min.js b/crates/swc_ecma_codegen/tests/fixture/issues/3110/output.min.js index acdc28771174..463de56a1cc5 100644 --- a/crates/swc_ecma_codegen/tests/fixture/issues/3110/output.min.js +++ b/crates/swc_ecma_codegen/tests/fixture/issues/3110/output.min.js @@ -1 +1 @@ -import data from"./data.json"assert{type:"json"};import"./data2.json"assert{type:"json"};export{default as data3}from"./data3.json"assert{type:"json"};export*as data4 from"./data4.json"assert{type:"json"};console.log(data); +import data from"./data.json"with{type:"json"};import"./data2.json"with{type:"json"};export{default as data3}from"./data3.json"with{type:"json"};export*as data4 from"./data4.json"with{type:"json"};console.log(data); diff --git a/crates/swc_ecma_dep_graph/src/lib.rs b/crates/swc_ecma_dep_graph/src/lib.rs index db84d697fae6..64e3eb11edde 100644 --- a/crates/swc_ecma_dep_graph/src/lib.rs +++ b/crates/swc_ecma_dep_graph/src/lib.rs @@ -41,7 +41,7 @@ pub enum ImportAssertion { } #[derive(Clone, Debug, Eq, PartialEq)] -pub enum ImportAssertions { +pub enum ImportAttributes { /// There was no import assertions object literal. None, /// The set of assertion keys could not be statically analyzed. @@ -51,16 +51,16 @@ pub enum ImportAssertions { Known(HashMap), } -impl Default for ImportAssertions { +impl Default for ImportAttributes { fn default() -> Self { - ImportAssertions::None + ImportAttributes::None } } -impl ImportAssertions { +impl ImportAttributes { pub fn get(&self, key: &str) -> Option<&String> { match self { - ImportAssertions::Known(map) => match map.get(key) { + ImportAttributes::Known(map) => match map.get(key) { Some(ImportAssertion::Known(value)) => Some(value), _ => None, }, @@ -84,7 +84,7 @@ pub struct DependencyDescriptor { /// The span of the specifier. pub specifier_span: Span, /// Import assertions for this dependency. - pub import_assertions: ImportAssertions, + pub import_attributes: ImportAttributes, } struct DependencyCollector<'a> { @@ -110,7 +110,7 @@ impl<'a> Visit for DependencyCollector<'a> { } else { DependencyKind::Import }; - let import_assertions = parse_import_assertions(node.asserts.as_deref()); + let import_attributes = parse_import_attributes(node.with.as_deref()); self.items.push(DependencyDescriptor { kind, is_dynamic: false, @@ -118,7 +118,7 @@ impl<'a> Visit for DependencyCollector<'a> { span: node.span, specifier, specifier_span: node.src.span, - import_assertions, + import_attributes, }); } @@ -131,7 +131,7 @@ impl<'a> Visit for DependencyCollector<'a> { } else { DependencyKind::Export }; - let import_assertions = parse_import_assertions(node.asserts.as_deref()); + let import_attributes = parse_import_attributes(node.with.as_deref()); self.items.push(DependencyDescriptor { kind, is_dynamic: false, @@ -139,7 +139,7 @@ impl<'a> Visit for DependencyCollector<'a> { span: node.span, specifier, specifier_span: src.span, - import_assertions, + import_attributes, }); } } @@ -152,7 +152,7 @@ impl<'a> Visit for DependencyCollector<'a> { } else { DependencyKind::Export }; - let import_assertions = parse_import_assertions(node.asserts.as_deref()); + let import_attributes = parse_import_attributes(node.with.as_deref()); self.items.push(DependencyDescriptor { kind, is_dynamic: false, @@ -160,7 +160,7 @@ impl<'a> Visit for DependencyCollector<'a> { span: node.span, specifier, specifier_span: node.src.span, - import_assertions, + import_attributes, }); } @@ -175,7 +175,7 @@ impl<'a> Visit for DependencyCollector<'a> { span: node.span, specifier, specifier_span: node.arg.span, - import_assertions: Default::default(), + import_attributes: Default::default(), }); } @@ -230,7 +230,7 @@ impl<'a> Visit for DependencyCollector<'a> { span: node.span, specifier, specifier_span: str_.span, - import_assertions: dynamic_import_assertions, + import_attributes: dynamic_import_assertions, }); } } @@ -259,7 +259,7 @@ impl<'a> Visit for DependencyCollector<'a> { span: node.span, specifier, specifier_span: expr.span, - import_assertions: Default::default(), + import_attributes: Default::default(), }); } } @@ -268,13 +268,13 @@ impl<'a> Visit for DependencyCollector<'a> { /// Parses import assertions into a hashmap. According to proposal the values /// can only be strings (https://github.com/tc39/proposal-import-assertions#should-more-than-just-strings-be-supported-as-attribute-values) /// and thus non-string values are skipped. -fn parse_import_assertions(asserts: Option<&ast::ObjectLit>) -> ImportAssertions { - let asserts = match asserts { - Some(asserts) => asserts, - None => return ImportAssertions::None, +fn parse_import_attributes(attrs: Option<&ast::ObjectLit>) -> ImportAttributes { + let attrs = match attrs { + Some(with) => with, + None => return ImportAttributes::None, }; let mut import_assertions = HashMap::new(); - for prop in asserts.props.iter() { + for prop in attrs.props.iter() { if let ast::PropOrSpread::Prop(prop) = prop { if let ast::Prop::KeyValue(key_value) = &**prop { let maybe_key = match &key_value.key { @@ -292,23 +292,23 @@ fn parse_import_assertions(asserts: Option<&ast::ObjectLit>) -> ImportAssertions } } } - ImportAssertions::Known(import_assertions) + ImportAttributes::Known(import_assertions) } /// Parses import assertions from the second arg of a dynamic import. -fn parse_dynamic_import_assertions(arg: Option<&ast::ExprOrSpread>) -> ImportAssertions { +fn parse_dynamic_import_assertions(arg: Option<&ast::ExprOrSpread>) -> ImportAttributes { let arg = match arg { Some(arg) => arg, - None => return ImportAssertions::None, + None => return ImportAttributes::None, }; if arg.spread.is_some() { - return ImportAssertions::Unknown; + return ImportAttributes::Unknown; } let object_lit = match &*arg.expr { ast::Expr::Object(object_lit) => object_lit, - _ => return ImportAssertions::Unknown, + _ => return ImportAttributes::Unknown, }; let mut assertions_map = HashMap::new(); @@ -317,37 +317,37 @@ fn parse_dynamic_import_assertions(arg: Option<&ast::ExprOrSpread>) -> ImportAss for prop in object_lit.props.iter() { let prop = match prop { ast::PropOrSpread::Prop(prop) => prop, - _ => return ImportAssertions::Unknown, + _ => return ImportAttributes::Unknown, }; let key_value = match &**prop { ast::Prop::KeyValue(key_value) => key_value, - _ => return ImportAssertions::Unknown, + _ => return ImportAttributes::Unknown, }; let key = match &key_value.key { ast::PropName::Str(key) => key.value.to_string(), ast::PropName::Ident(ident) => ident.sym.to_string(), - _ => return ImportAssertions::Unknown, + _ => return ImportAttributes::Unknown, }; - if key == "assert" { + if key == "assert" || key == "with" { had_assert_key = true; let assertions_lit = match &*key_value.value { ast::Expr::Object(assertions_lit) => assertions_lit, - _ => return ImportAssertions::Unknown, + _ => return ImportAttributes::Unknown, }; for prop in assertions_lit.props.iter() { let prop = match prop { ast::PropOrSpread::Prop(prop) => prop, - _ => return ImportAssertions::Unknown, + _ => return ImportAttributes::Unknown, }; let key_value = match &**prop { ast::Prop::KeyValue(key_value) => key_value, - _ => return ImportAssertions::Unknown, + _ => return ImportAttributes::Unknown, }; let key = match &key_value.key { ast::PropName::Str(key) => key.value.to_string(), ast::PropName::Ident(ident) => ident.sym.to_string(), - _ => return ImportAssertions::Unknown, + _ => return ImportAttributes::Unknown, }; if let ast::Expr::Lit(value_lit) = &*key_value.value { assertions_map.insert( @@ -366,9 +366,9 @@ fn parse_dynamic_import_assertions(arg: Option<&ast::ExprOrSpread>) -> ImportAss } if had_assert_key { - ImportAssertions::Known(assertions_map) + ImportAttributes::Known(assertions_map) } else { - ImportAssertions::None + ImportAttributes::None } } @@ -477,7 +477,7 @@ try { span: Span::new(BytePos(1), BytePos(34), Default::default()), specifier: JsWord::from("./test.ts"), specifier_span: Span::new(BytePos(22), BytePos(33), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::ImportType, @@ -490,7 +490,7 @@ try { span: Span::new(BytePos(48), BytePos(86), Default::default()), specifier: JsWord::from("./foo.d.ts"), specifier_span: Span::new(BytePos(73), BytePos(85), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Export, @@ -503,7 +503,7 @@ try { span: Span::new(BytePos(115), BytePos(149), Default::default()), specifier: JsWord::from("./buzz.ts"), specifier_span: Span::new(BytePos(137), BytePos(148), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::ExportType, @@ -523,7 +523,7 @@ try { span: Span::new(BytePos(181), BytePos(221), Default::default()), specifier: JsWord::from("./fizz.d.ts"), specifier_span: Span::new(BytePos(207), BytePos(220), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Require, @@ -532,7 +532,7 @@ try { span: Span::new(BytePos(239), BytePos(254), Default::default()), specifier: JsWord::from("path"), specifier_span: Span::new(BytePos(247), BytePos(253), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Import, @@ -541,7 +541,7 @@ try { span: Span::new(BytePos(274), BytePos(293), Default::default()), specifier: JsWord::from("./foo1.ts"), specifier_span: Span::new(BytePos(281), BytePos(292), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Import, @@ -550,7 +550,7 @@ try { span: Span::new(BytePos(324), BytePos(342), Default::default()), specifier: JsWord::from("./foo.ts"), specifier_span: Span::new(BytePos(331), BytePos(341), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Require, @@ -559,7 +559,7 @@ try { span: Span::new(BytePos(395), BytePos(418), Default::default()), specifier: JsWord::from("some_package"), specifier_span: Span::new(BytePos(403), BytePos(417), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::ImportEquals, @@ -568,7 +568,7 @@ try { span: Span::new(BytePos(449), BytePos(491), Default::default()), specifier: JsWord::from("some_package_foo"), specifier_span: Span::new(BytePos(471), BytePos(489), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::ImportType, @@ -577,7 +577,7 @@ try { span: Span::new(BytePos(492), BytePos(547), Default::default()), specifier: JsWord::from("some_package_foo_type"), specifier_span: Span::new(BytePos(522), BytePos(545), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::ExportEquals, @@ -586,7 +586,7 @@ try { span: Span::new(BytePos(548), BytePos(597), Default::default()), specifier: JsWord::from("some_package_bar"), specifier_span: Span::new(BytePos(577), BytePos(595), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Require, @@ -595,7 +595,7 @@ try { span: Span::new(BytePos(612), BytePos(651), Default::default()), specifier: JsWord::from("some_package_resolve"), specifier_span: Span::new(BytePos(628), BytePos(650), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Require, @@ -604,7 +604,7 @@ try { span: Span::new(BytePos(676), BytePos(719), Default::default()), specifier: JsWord::from("some_package_resolve_foo"), specifier_span: Span::new(BytePos(692), BytePos(718), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, ] ); @@ -630,7 +630,7 @@ const d9 = await import("./d9.json", { assert: { type: "json", ...bar } }); const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" } }); "#; let (module, comments) = helper("test.ts", source).unwrap(); - let expected_assertions1 = ImportAssertions::Known({ + let expected_assertions1 = ImportAttributes::Known({ let mut map = HashMap::new(); map.insert( "type".to_string(), @@ -638,7 +638,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" ); map }); - let expected_assertions2 = ImportAssertions::Known({ + let expected_assertions2 = ImportAttributes::Known({ let mut map = HashMap::new(); map.insert( "type".to_string(), @@ -646,7 +646,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" ); map }); - let dynamic_expected_assertions2 = ImportAssertions::Known({ + let dynamic_expected_assertions2 = ImportAttributes::Known({ let mut map = HashMap::new(); map.insert( "type".to_string(), @@ -666,7 +666,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(1), BytePos(66), Default::default()), specifier: JsWord::from("./test.ts"), specifier_span: Span::new(BytePos(22), BytePos(33), Default::default()), - import_assertions: expected_assertions1.clone(), + import_attributes: expected_assertions1.clone(), }, DependencyDescriptor { kind: DependencyKind::Export, @@ -675,7 +675,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(67), BytePos(125), Default::default()), specifier: JsWord::from("./test.ts"), specifier_span: Span::new(BytePos(81), BytePos(92), Default::default()), - import_assertions: expected_assertions1, + import_attributes: expected_assertions1, }, DependencyDescriptor { kind: DependencyKind::Export, @@ -684,7 +684,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(126), BytePos(186), Default::default()), specifier: JsWord::from("./test.json"), specifier_span: Span::new(BytePos(146), BytePos(159), Default::default()), - import_assertions: expected_assertions2.clone(), + import_attributes: expected_assertions2.clone(), }, DependencyDescriptor { kind: DependencyKind::Import, @@ -693,7 +693,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(187), BytePos(240), Default::default()), specifier: JsWord::from("./foo.json"), specifier_span: Span::new(BytePos(203), BytePos(215), Default::default()), - import_assertions: expected_assertions2, + import_attributes: expected_assertions2, }, DependencyDescriptor { kind: DependencyKind::Import, @@ -702,7 +702,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(260), BytePos(313), Default::default()), specifier: JsWord::from("./fizz.json"), specifier_span: Span::new(BytePos(267), BytePos(280), Default::default()), - import_assertions: dynamic_expected_assertions2.clone(), + import_attributes: dynamic_expected_assertions2.clone(), }, DependencyDescriptor { kind: DependencyKind::Import, @@ -711,7 +711,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(334), BytePos(387), Default::default()), specifier: JsWord::from("./buzz.json"), specifier_span: Span::new(BytePos(341), BytePos(354), Default::default()), - import_assertions: dynamic_expected_assertions2, + import_attributes: dynamic_expected_assertions2, }, DependencyDescriptor { kind: DependencyKind::Import, @@ -720,7 +720,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(406), BytePos(425), Default::default()), specifier: JsWord::from("./d1.json"), specifier_span: Span::new(BytePos(413), BytePos(424), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Import, @@ -729,7 +729,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(444), BytePos(467), Default::default()), specifier: JsWord::from("./d2.json"), specifier_span: Span::new(BytePos(451), BytePos(462), Default::default()), - import_assertions: Default::default(), + import_attributes: Default::default(), }, DependencyDescriptor { kind: DependencyKind::Import, @@ -738,7 +738,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(486), BytePos(510), Default::default()), specifier: JsWord::from("./d3.json"), specifier_span: Span::new(BytePos(493), BytePos(504), Default::default()), - import_assertions: ImportAssertions::Unknown, + import_attributes: ImportAttributes::Unknown, }, DependencyDescriptor { kind: DependencyKind::Import, @@ -747,7 +747,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(529), BytePos(564), Default::default()), specifier: JsWord::from("./d4.json"), specifier_span: Span::new(BytePos(536), BytePos(547), Default::default()), - import_assertions: ImportAssertions::Known(HashMap::new()), + import_attributes: ImportAttributes::Known(HashMap::new()), }, DependencyDescriptor { kind: DependencyKind::Import, @@ -756,7 +756,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(583), BytePos(619), Default::default()), specifier: JsWord::from("./d5.json"), specifier_span: Span::new(BytePos(590), BytePos(601), Default::default()), - import_assertions: ImportAssertions::Unknown, + import_attributes: ImportAttributes::Unknown, }, DependencyDescriptor { kind: DependencyKind::Import, @@ -765,7 +765,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(638), BytePos(681), Default::default()), specifier: JsWord::from("./d6.json"), specifier_span: Span::new(BytePos(645), BytePos(656), Default::default()), - import_assertions: ImportAssertions::Unknown, + import_attributes: ImportAttributes::Unknown, }, DependencyDescriptor { kind: DependencyKind::Import, @@ -774,7 +774,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(700), BytePos(754), Default::default()), specifier: JsWord::from("./d7.json"), specifier_span: Span::new(BytePos(707), BytePos(718), Default::default()), - import_assertions: ImportAssertions::Unknown, + import_attributes: ImportAttributes::Unknown, }, DependencyDescriptor { kind: DependencyKind::Import, @@ -783,7 +783,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(773), BytePos(819), Default::default()), specifier: JsWord::from("./d8.json"), specifier_span: Span::new(BytePos(780), BytePos(791), Default::default()), - import_assertions: ImportAssertions::Known({ + import_attributes: ImportAttributes::Known({ let mut map = HashMap::new(); map.insert("type".to_string(), ImportAssertion::Unknown); map @@ -796,7 +796,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(838), BytePos(895), Default::default()), specifier: JsWord::from("./d9.json"), specifier_span: Span::new(BytePos(845), BytePos(856), Default::default()), - import_assertions: ImportAssertions::Unknown, + import_attributes: ImportAttributes::Unknown, }, DependencyDescriptor { kind: DependencyKind::Import, @@ -805,7 +805,7 @@ const d10 = await import("./d10.json", { assert: { type: "json", ["type"]: "bad" span: Span::new(BytePos(915), BytePos(982), Default::default()), specifier: JsWord::from("./d10.json"), specifier_span: Span::new(BytePos(922), BytePos(934), Default::default()), - import_assertions: ImportAssertions::Unknown, + import_attributes: ImportAttributes::Unknown, }, ] ); diff --git a/crates/swc_ecma_minifier/src/pass/merge_exports.rs b/crates/swc_ecma_minifier/src/pass/merge_exports.rs index 6b9958083bf1..7e9b0bf5c59d 100644 --- a/crates/swc_ecma_minifier/src/pass/merge_exports.rs +++ b/crates/swc_ecma_minifier/src/pass/merge_exports.rs @@ -48,7 +48,7 @@ impl VisitMut for Merger { specifiers: self.specifiers.take(), span: DUMMY_SP, type_only: Default::default(), - asserts: Default::default(), + with: Default::default(), }, ))); } @@ -61,7 +61,7 @@ impl VisitMut for Merger { specifiers: Default::default(), span: DUMMY_SP, type_only: Default::default(), - asserts: Default::default(), + with: Default::default(), }, ))); } diff --git a/crates/swc_ecma_parser/src/lib.rs b/crates/swc_ecma_parser/src/lib.rs index e3f25e721226..415dc49606fc 100644 --- a/crates/swc_ecma_parser/src/lib.rs +++ b/crates/swc_ecma_parser/src/lib.rs @@ -175,11 +175,11 @@ impl Syntax { } } - pub fn import_assertions(self) -> bool { + pub fn import_attributes(self) -> bool { match self { Syntax::Es(EsConfig { - import_assertions, .. - }) => import_assertions, + import_attributes, .. + }) => import_attributes, Syntax::Typescript(_) => true, } } @@ -284,7 +284,10 @@ impl Syntax { pub fn explicit_resource_management(&self) -> bool { match self { - Syntax::Es(EsConfig { using_decl, .. }) => *using_decl, + Syntax::Es(EsConfig { + explicit_resource_management: using_decl, + .. + }) => *using_decl, Syntax::Typescript(_) => true, } } @@ -341,8 +344,8 @@ pub struct EsConfig { pub export_default_from: bool, /// Stage 3. - #[serde(default)] - pub import_assertions: bool, + #[serde(default, alias = "importAssertions")] + pub import_attributes: bool, #[serde(default, rename = "allowSuperOutsideMethod")] pub allow_super_outside_method: bool, @@ -354,7 +357,7 @@ pub struct EsConfig { pub auto_accessors: bool, #[serde(default)] - pub using_decl: bool, + pub explicit_resource_management: bool, } /// Syntactic context. diff --git a/crates/swc_ecma_parser/src/parser/expr.rs b/crates/swc_ecma_parser/src/parser/expr.rs index f6d6d4dfac48..b077d891f56c 100644 --- a/crates/swc_ecma_parser/src/parser/expr.rs +++ b/crates/swc_ecma_parser/src/parser/expr.rs @@ -740,7 +740,7 @@ impl Parser { expect!(p, ','); // Handle trailing comma. if is!(p, ')') { - if is_dynamic_import && !p.input.syntax().import_assertions() { + if is_dynamic_import && !p.input.syntax().import_attributes() { syntax_error!( p, span!(p, start), diff --git a/crates/swc_ecma_parser/src/parser/stmt.rs b/crates/swc_ecma_parser/src/parser/stmt.rs index 7556a81038a6..00f0c164cd53 100644 --- a/crates/swc_ecma_parser/src/parser/stmt.rs +++ b/crates/swc_ecma_parser/src/parser/stmt.rs @@ -2434,7 +2434,7 @@ export default function waitUntil(callback, options = {}) { test_parser( src, Syntax::Es(EsConfig { - import_assertions: true, + import_attributes: true, ..Default::default() }), |p| p.parse_expr(), 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 d2b2003f2da7..9ddc999e36d3 100644 --- a/crates/swc_ecma_parser/src/parser/stmt/module_item.rs +++ b/crates/swc_ecma_parser/src/parser/stmt/module_item.rs @@ -63,9 +63,9 @@ impl Parser { _ => unreachable!(), }; let _ = cur!(self, false); - let asserts = if self.input.syntax().import_assertions() + let with = if self.input.syntax().import_attributes() && !self.input.had_line_break_before_cur() - && eat!(self, "assert") + && (eat!(self, "assert") || eat!(self, "with")) { match *self.parse_object::>()? { Expr::Object(v) => Some(Box::new(v)), @@ -80,7 +80,7 @@ impl Parser { src, specifiers: vec![], type_only: false, - asserts, + with, })) .map(ModuleItem::from); } @@ -157,9 +157,9 @@ impl Parser { }; let _ = cur!(self, false); - let asserts = if self.input.syntax().import_assertions() + let with = if self.input.syntax().import_attributes() && !self.input.had_line_break_before_cur() - && eat!(self, "assert") + && (eat!(self, "assert") || eat!(self, "with")) { match *self.parse_object::>()? { Expr::Object(v) => Some(Box::new(v)), @@ -176,7 +176,7 @@ impl Parser { specifiers, src, type_only, - asserts, + with, })) .map(ModuleItem::from) } @@ -570,12 +570,12 @@ impl Parser { assert_and_bump!(self, '*'); // improve error message for `export * from foo` - let (src, asserts) = self.parse_from_clause_and_semi()?; + let (src, with) = self.parse_from_clause_and_semi()?; return Ok(ModuleDecl::ExportAll(ExportAll { span: span!(self, start), src, type_only, - asserts, + with, })); } @@ -617,13 +617,13 @@ impl Parser { if has_default || has_ns { if is!(self, "from") { - let (src, asserts) = self.parse_from_clause_and_semi()?; + let (src, with) = self.parse_from_clause_and_semi()?; return Ok(ModuleDecl::ExportNamed(NamedExport { span: span!(self, start), specifiers, src: Some(src), type_only, - asserts, + with, })); } else if !self.input.syntax().export_default_from() { // emit error @@ -667,7 +667,7 @@ impl Parser { } None }; - let (src, asserts) = match opt { + let (src, with) = match opt { Some(v) => (Some(v.0), v.1), None => (None, None), }; @@ -676,7 +676,7 @@ impl Parser { specifiers, src, type_only, - asserts, + with, })); }; @@ -793,7 +793,7 @@ impl Parser { }) } - /// Parses `from 'foo.js' assert {};` + /// Parses `from 'foo.js' with {};` or `from 'foo.js' assert {};` fn parse_from_clause_and_semi(&mut self) -> PResult<(Box, Option>)> { expect!(self, "from"); @@ -810,9 +810,9 @@ impl Parser { _ => unexpected!(self, "a string literal"), }; let _ = cur!(self, false); - let asserts = if self.input.syntax().import_assertions() + let with = if self.input.syntax().import_attributes() && !self.input.had_line_break_before_cur() - && eat!(self, "assert") + && (eat!(self, "assert") || eat!(self, "with")) { match *self.parse_object::>()? { Expr::Object(v) => Some(Box::new(v)), @@ -822,7 +822,7 @@ impl Parser { None }; expect!(self, ';'); - Ok((src, asserts)) + Ok((src, with)) } } diff --git a/crates/swc_ecma_parser/tests/comments.rs b/crates/swc_ecma_parser/tests/comments.rs index 397571d2f869..65b7f9b19847 100644 --- a/crates/swc_ecma_parser/tests/comments.rs +++ b/crates/swc_ecma_parser/tests/comments.rs @@ -29,7 +29,7 @@ fn test(input: PathBuf) { decorators: true, decorators_before_export: false, export_default_from: true, - import_assertions: true, + import_attributes: true, ..Default::default() }), "ts" | "tsx" => Syntax::Typescript(TsConfig { diff --git a/crates/swc_ecma_parser/tests/errors.rs b/crates/swc_ecma_parser/tests/errors.rs index ff6892256483..973b5c9bd153 100644 --- a/crates/swc_ecma_parser/tests/errors.rs +++ b/crates/swc_ecma_parser/tests/errors.rs @@ -47,7 +47,7 @@ where } else { ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { jsx: is_jsx, - using_decl: true, + explicit_resource_management: true, ..Default::default() }) }; diff --git a/crates/swc_ecma_parser/tests/js.rs b/crates/swc_ecma_parser/tests/js.rs index 507c532da487..a7de707d50ad 100644 --- a/crates/swc_ecma_parser/tests/js.rs +++ b/crates/swc_ecma_parser/tests/js.rs @@ -91,7 +91,8 @@ where let lexer = Lexer::new( Syntax::Es(EsConfig { - using_decl: true, + explicit_resource_management: true, + import_attributes: true, ..Default::default() }), EsVersion::Es2015, diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js new file mode 100644 index 000000000000..baa60fc43c5f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js @@ -0,0 +1 @@ +import("foo.json", { with: { type: "json" } }) diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js.json new file mode 100644 index 000000000000..19232204d4fb --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/dynamic-import-with-valid-syntax/input.js.json @@ -0,0 +1,110 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 18, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 20, + "end": 46, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 22, + "end": 26, + "ctxt": 0 + }, + "value": "with", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 28, + "end": 44, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 30, + "end": 34, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 36, + "end": 42, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/options.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/options.json new file mode 100644 index 000000000000..94e3f3742509 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + [ + "importAssertions" + ] + ], + "sourceType": "module" +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/string-literal/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/string-literal/input.js new file mode 100644 index 000000000000..8af887a3cc06 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/string-literal/input.js @@ -0,0 +1,2 @@ +import foo from "foo.json" with { for: "for" } +export { foo } from "foo.json" with { for: "for" } diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/string-literal/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/string-literal/input.js.json new file mode 100644 index 000000000000..7d7551301b94 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/string-literal/input.js.json @@ -0,0 +1,157 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 98, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 47, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 38, + "ctxt": 0 + }, + "value": "for", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 40, + "end": 45, + "ctxt": 0 + }, + "value": "for", + "raw": "\"for\"" + } + } + ] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 48, + "end": 98, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 57, + "end": 60, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 57, + "end": 60, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 68, + "end": 78, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 84, + "end": 98, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 86, + "end": 89, + "ctxt": 0 + }, + "value": "for", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 91, + "end": 96, + "ctxt": 0 + }, + "value": "for", + "raw": "\"for\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma-dynamic/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma-dynamic/input.js new file mode 100644 index 000000000000..0be461789922 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma-dynamic/input.js @@ -0,0 +1,2 @@ +import("foo.js",); +import("foo.json", { with: { type: "json" } },); diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma-dynamic/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma-dynamic/input.js.json new file mode 100644 index 000000000000..f444874d38ce --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma-dynamic/input.js.json @@ -0,0 +1,150 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 68, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 19, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 18, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 16, + "ctxt": 0 + }, + "value": "foo.js", + "raw": "\"foo.js\"" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 20, + "end": 68, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 20, + "end": 67, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 20, + "end": 26, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 37, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 39, + "end": 65, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 41, + "end": 45, + "ctxt": 0 + }, + "value": "with", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 47, + "end": 63, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 49, + "end": 53, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 55, + "end": 61, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma/input.js new file mode 100644 index 000000000000..10bc32278776 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma/input.js @@ -0,0 +1,2 @@ +import foo from "foo" with { type: "json", } +export { default as foo } from "foo" with { type: "json", } diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma/input.js.json new file mode 100644 index 000000000000..ed75c95085e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/trailing-comma/input.js.json @@ -0,0 +1,166 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 105, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 45, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 22, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 28, + "end": 45, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 30, + "end": 34, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 36, + "end": 42, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 46, + "end": 105, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 55, + "end": 69, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 55, + "end": 62, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 66, + "end": 69, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 77, + "end": 82, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 88, + "end": 105, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 90, + "end": 94, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 96, + "end": 102, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-empty-assertion/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-empty-assertion/input.js new file mode 100644 index 000000000000..8bde57a92d52 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-empty-assertion/input.js @@ -0,0 +1,4 @@ +import foo, { bar } from "foo" with {}; +import * as ns from "foo" with {}; +export { quux } from "foo" with {}; +export * as ns2 from "foo" with {}; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-empty-assertion/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-empty-assertion/input.js.json new file mode 100644 index 000000000000..35cd77cd1213 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-empty-assertion/input.js.json @@ -0,0 +1,225 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 147, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 40, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + }, + { + "type": "ImportSpecifier", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "value": "bar", + "optional": false + }, + "imported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 26, + "end": 31, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 37, + "end": 39, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ImportDeclaration", + "span": { + "start": 41, + "end": 75, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "span": { + "start": 48, + "end": 55, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 53, + "end": 55, + "ctxt": 0 + }, + "value": "ns", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 61, + "end": 66, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 72, + "end": 74, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 76, + "end": 111, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 85, + "end": 89, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 85, + "end": 89, + "ctxt": 0 + }, + "value": "quux", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 97, + "end": 102, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 108, + "end": 110, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 112, + "end": 147, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "span": { + "start": 119, + "end": 127, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 124, + "end": 127, + "ctxt": 0 + }, + "value": "ns2", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 133, + "end": 138, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 144, + "end": 146, + "ctxt": 0 + }, + "properties": [] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-class/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-class/input.js new file mode 100644 index 000000000000..223d0a8b395b --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-class/input.js @@ -0,0 +1 @@ +export class Foo {} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-class/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-class/input.js.json new file mode 100644 index 000000000000..d7e53ed74170 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-class/input.js.json @@ -0,0 +1,45 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 20, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 20, + "ctxt": 0 + }, + "declaration": { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "span": { + "start": 8, + "end": 20, + "ctxt": 0 + }, + "decorators": [], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-function/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-function/input.js new file mode 100644 index 000000000000..f99d4277774f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-function/input.js @@ -0,0 +1 @@ +export function foo() {} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-function/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-function/input.js.json new file mode 100644 index 000000000000..f7da5fd89c1e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-function/input.js.json @@ -0,0 +1,53 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "declaration": { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 17, + "end": 20, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "declare": false, + "params": [], + "decorators": [], + "span": { + "start": 8, + "end": 25, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 23, + "end": 25, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-variable/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-variable/input.js new file mode 100644 index 000000000000..b30bd489f951 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-variable/input.js @@ -0,0 +1 @@ +export const foo = ""; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-variable/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-variable/input.js.json new file mode 100644 index 000000000000..72319783c4d1 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-variable/input.js.json @@ -0,0 +1,61 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "declaration": { + "type": "VariableDeclaration", + "span": { + "start": 8, + "end": 23, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 14, + "end": 22, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "StringLiteral", + "span": { + "start": 20, + "end": 22, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "definite": false + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-without-from/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-without-from/input.js new file mode 100644 index 000000000000..b8017e6930e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-without-from/input.js @@ -0,0 +1,3 @@ +const foo = ""; + +export { foo }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-without-from/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-without-from/input.js.json new file mode 100644 index 000000000000..eeb553cc541f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-export-without-from/input.js.json @@ -0,0 +1,86 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 1, + "end": 16, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 7, + "end": 15, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 7, + "end": 10, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "StringLiteral", + "span": { + "start": 13, + "end": 15, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "definite": false + } + ] + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 18, + "end": 33, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": null, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-string-assertion-key/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-string-assertion-key/input.js new file mode 100644 index 000000000000..74070b3d002e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-string-assertion-key/input.js @@ -0,0 +1 @@ +import "foo" with { "type": "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-string-assertion-key/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-string-assertion-key/input.js.json new file mode 100644 index 000000000000..1144c1ec4a1f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-string-assertion-key/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 38, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 38, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 19, + "end": 37, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "StringLiteral", + "span": { + "start": 21, + "end": 27, + "ctxt": 0 + }, + "value": "type", + "raw": "\"type\"" + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 29, + "end": 35, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js new file mode 100644 index 000000000000..4e9fbefb8919 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js @@ -0,0 +1 @@ +export * as foo from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js.json new file mode 100644 index 000000000000..31ff2700f508 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-as-with-assertions/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 55, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 55, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "span": { + "start": 8, + "end": 16, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 13, + "end": 16, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 22, + "end": 32, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 38, + "end": 54, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 40, + "end": 44, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 46, + "end": 52, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js new file mode 100644 index 000000000000..70566cfaf1f3 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js @@ -0,0 +1 @@ +export * from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js.json new file mode 100644 index 000000000000..de088e63f124 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-star-with-assertions/input.js.json @@ -0,0 +1,63 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 48, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportAllDeclaration", + "span": { + "start": 1, + "end": 48, + "ctxt": 0 + }, + "source": { + "type": "StringLiteral", + "span": { + "start": 15, + "end": 25, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 31, + "end": 47, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 33, + "end": 37, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 39, + "end": 45, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js new file mode 100644 index 000000000000..e8a58d263541 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js @@ -0,0 +1,2 @@ +export { default as x } from "foo" with +{ type: "json" } diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js.json new file mode 100644 index 000000000000..8e059e69e3b3 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-and-assertions-multiple-lines/input.js.json @@ -0,0 +1,94 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 57, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 57, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 22, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 21, + "end": 22, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 30, + "end": 35, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 41, + "end": 57, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 49, + "end": 55, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js new file mode 100644 index 000000000000..458d863897b5 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js @@ -0,0 +1,2 @@ +export { "default" as x } from "foo" with { type: "json" } +[0] diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js.json new file mode 100644 index 000000000000..5e0193073017 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions-and-value/input.js.json @@ -0,0 +1,125 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 63, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 59, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 24, + "ctxt": 0 + }, + "orig": { + "type": "StringLiteral", + "span": { + "start": 10, + "end": 19, + "ctxt": 0 + }, + "value": "default", + "raw": "\"default\"" + }, + "exported": { + "type": "Identifier", + "span": { + "start": 23, + "end": 24, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 32, + "end": 37, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 59, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 60, + "end": 63, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 60, + "end": 63, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 61, + "end": 62, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js new file mode 100644 index 000000000000..8d791f4fe480 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js.json new file mode 100644 index 000000000000..9a904f8fa354 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-assertions/input.js.json @@ -0,0 +1,94 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 65, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 65, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 24, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 21, + "end": 24, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 32, + "end": 42, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 48, + "end": 64, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 50, + "end": 54, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 56, + "end": 62, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js new file mode 100644 index 000000000000..7a70c7f04630 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js.json new file mode 100644 index 000000000000..3db03e505e89 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/input.js.json @@ -0,0 +1,130 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 86, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 86, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 41, + "end": 85, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 49, + "end": 55, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 57, + "end": 61, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 63, + "end": 67, + "ctxt": 0 + }, + "value": true + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 69, + "end": 80, + "ctxt": 0 + }, + "value": "startAtLine", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 82, + "end": 83, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json new file mode 100644 index 000000000000..3b039e9a62e8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:62)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js new file mode 100644 index 000000000000..4553d256b1cb --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" with { lazy: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js.json new file mode 100644 index 000000000000..aebfcf2f2050 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-no-type-assertion/input.js.json @@ -0,0 +1,85 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 58, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 58, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 41, + "end": 57, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 49, + "end": 55, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js new file mode 100644 index 000000000000..0e8993714a3f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" with { type: "json", hasOwnProperty: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js.json new file mode 100644 index 000000000000..9bde76e2db26 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-with-object-method-assertion/input.js.json @@ -0,0 +1,108 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 82, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 82, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 41, + "end": 81, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 49, + "end": 55, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 57, + "end": 71, + "ctxt": 0 + }, + "value": "hasOwnProperty", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 73, + "end": 79, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-without-assertions/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-without-assertions/input.js new file mode 100644 index 000000000000..9408920b3f74 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-without-assertions/input.js @@ -0,0 +1 @@ +export { foo } from "foo.json"; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-without-assertions/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-without-assertions/input.js.json new file mode 100644 index 000000000000..1fab6f46fa47 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-export-without-assertions/input.js.json @@ -0,0 +1,53 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 32, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 32, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 13, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 21, + "end": 31, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js new file mode 100644 index 000000000000..b9907829ef29 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js @@ -0,0 +1,2 @@ +import "x" with { type: "json" } +[0] diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js.json new file mode 100644 index 000000000000..11ca16be006d --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-and-value/input.js.json @@ -0,0 +1,95 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 37, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 17, + "end": 33, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 19, + "end": 23, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 31, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 34, + "end": 37, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 34, + "end": 37, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 35, + "end": 36, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js new file mode 100644 index 000000000000..e78e2c90f72d --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js @@ -0,0 +1,2 @@ +import "x" with +{ type: "json" } diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js.json new file mode 100644 index 000000000000..dc2332b10b3f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions-multiple-lines/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 17, + "end": 33, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 19, + "end": 23, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 31, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions/input.js new file mode 100644 index 000000000000..83c51c971889 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions/input.js.json new file mode 100644 index 000000000000..6d1ec7a3ddb7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-assertions/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js new file mode 100644 index 000000000000..3f350904e07f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js.json new file mode 100644 index 000000000000..b8f5c7f70ffd --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/input.js.json @@ -0,0 +1,128 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 78, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 78, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 77, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 49, + "end": 53, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 55, + "end": 59, + "ctxt": 0 + }, + "value": true + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 61, + "end": 72, + "ctxt": 0 + }, + "value": "startAtLine", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 74, + "end": 75, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json new file mode 100644 index 000000000000..9326901e4d93 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:54)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js new file mode 100644 index 000000000000..1858e49c2022 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { lazy: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js.json new file mode 100644 index 000000000000..9c200d6135d2 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-no-type-assertion/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js new file mode 100644 index 000000000000..2ec8345c8e15 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json", hasOwnProperty: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js.json new file mode 100644 index 000000000000..1a2283544bc9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-with-object-method-assertion/input.js.json @@ -0,0 +1,106 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 74, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 74, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 73, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 49, + "end": 63, + "ctxt": 0 + }, + "value": "hasOwnProperty", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 65, + "end": 71, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-without-assertions/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-without-assertions/input.js new file mode 100644 index 000000000000..92901ed56b38 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-without-assertions/input.js @@ -0,0 +1 @@ +import foo from "foo.json"; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-without-assertions/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-without-assertions/input.js.json new file mode 100644 index 000000000000..ceee136de005 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/valid-syntax-without-assertions/input.js.json @@ -0,0 +1,51 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 28, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 28, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/input.js b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/input.js new file mode 100644 index 000000000000..83c51c971889 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/input.js.json new file mode 100644 index 000000000000..6d1ec7a3ddb7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/options.json b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/options.json new file mode 100644 index 000000000000..a1899f538d7e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions-with-keyword/without-plugin/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:32)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/dynamic-import-with-valid-syntax/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/dynamic-import-with-valid-syntax/input.js new file mode 100644 index 000000000000..481c52e1c75f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/dynamic-import-with-valid-syntax/input.js @@ -0,0 +1 @@ +import("foo.json", { assert: { type: "json" } }) diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/dynamic-import-with-valid-syntax/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/dynamic-import-with-valid-syntax/input.js.json new file mode 100644 index 000000000000..206b7d871acf --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/dynamic-import-with-valid-syntax/input.js.json @@ -0,0 +1,110 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 49, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 49, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 49, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 18, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 20, + "end": 48, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 22, + "end": 28, + "ctxt": 0 + }, + "value": "assert", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 30, + "end": 46, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 32, + "end": 36, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 38, + "end": 44, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/import-assert-call-expression/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/import-assert-call-expression/input.js new file mode 100644 index 000000000000..5b6c5fa3373a --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/import-assert-call-expression/input.js @@ -0,0 +1,2 @@ +import "x" +assert ({}); diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/import-assert-call-expression/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/import-assert-call-expression/input.js.json new file mode 100644 index 000000000000..3db741256e66 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/import-assert-call-expression/input.js.json @@ -0,0 +1,73 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 24, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 11, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": null + }, + { + "type": "ExpressionStatement", + "span": { + "start": 12, + "end": 24, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 12, + "end": 23, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 12, + "end": 18, + "ctxt": 0 + }, + "value": "assert", + "optional": false + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 20, + "end": 22, + "ctxt": 0 + }, + "properties": [] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/options.json b/crates/swc_ecma_parser/tests/js/import-assertions/options.json new file mode 100644 index 000000000000..51a9e56a5cbd --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["importAssertions"], + "sourceType": "module" +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/string-literal/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/string-literal/input.js new file mode 100644 index 000000000000..1c1e4b79e789 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/string-literal/input.js @@ -0,0 +1,2 @@ +import foo from "foo.json" assert { for: "for" } +export { foo } from "foo.json" assert { for: "for" } diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/string-literal/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/string-literal/input.js.json new file mode 100644 index 000000000000..07d0b11960ef --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/string-literal/input.js.json @@ -0,0 +1,157 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 102, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 49, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 40, + "ctxt": 0 + }, + "value": "for", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 42, + "end": 47, + "ctxt": 0 + }, + "value": "for", + "raw": "\"for\"" + } + } + ] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 50, + "end": 102, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 59, + "end": 62, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 59, + "end": 62, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 70, + "end": 80, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 88, + "end": 102, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 90, + "end": 93, + "ctxt": 0 + }, + "value": "for", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 95, + "end": 100, + "ctxt": 0 + }, + "value": "for", + "raw": "\"for\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma-dynamic/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma-dynamic/input.js new file mode 100644 index 000000000000..b448aa280c34 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma-dynamic/input.js @@ -0,0 +1,2 @@ +import("foo.js",); +import("foo.json", { assert: { type: "json" } },); diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma-dynamic/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma-dynamic/input.js.json new file mode 100644 index 000000000000..9f9aeca6124a --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma-dynamic/input.js.json @@ -0,0 +1,150 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 70, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 19, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 18, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 16, + "ctxt": 0 + }, + "value": "foo.js", + "raw": "\"foo.js\"" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 20, + "end": 70, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 20, + "end": 69, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 20, + "end": 26, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 37, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 39, + "end": 67, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "assert", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 49, + "end": 65, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 51, + "end": 55, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 57, + "end": 63, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma/input.js new file mode 100644 index 000000000000..077d150d81ae --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma/input.js @@ -0,0 +1,2 @@ +import foo from "foo" assert { type: "json", } +export { default as foo } from "foo" assert { type: "json", } diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma/input.js.json new file mode 100644 index 000000000000..e87ce65888f1 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/trailing-comma/input.js.json @@ -0,0 +1,166 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 109, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 22, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 30, + "end": 47, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 32, + "end": 36, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 38, + "end": 44, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 48, + "end": 109, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 57, + "end": 71, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 57, + "end": 64, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 68, + "end": 71, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 79, + "end": 84, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 92, + "end": 109, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 94, + "end": 98, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 100, + "end": 106, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-empty-assertion/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-empty-assertion/input.js new file mode 100644 index 000000000000..758659de4037 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-empty-assertion/input.js @@ -0,0 +1,4 @@ +import foo, { bar } from "foo" assert {}; +import * as ns from "foo" assert {}; +export { quux } from "foo" assert {}; +export * as ns2 from "foo" assert {}; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-empty-assertion/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-empty-assertion/input.js.json new file mode 100644 index 000000000000..6920136614ca --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-empty-assertion/input.js.json @@ -0,0 +1,225 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 155, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 42, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + }, + { + "type": "ImportSpecifier", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "value": "bar", + "optional": false + }, + "imported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 26, + "end": 31, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 39, + "end": 41, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ImportDeclaration", + "span": { + "start": 43, + "end": 79, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "span": { + "start": 50, + "end": 57, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 55, + "end": 57, + "ctxt": 0 + }, + "value": "ns", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 63, + "end": 68, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 76, + "end": 78, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 80, + "end": 117, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 89, + "end": 93, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 89, + "end": 93, + "ctxt": 0 + }, + "value": "quux", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 101, + "end": 106, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 114, + "end": 116, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 118, + "end": 155, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "span": { + "start": 125, + "end": 133, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 130, + "end": 133, + "ctxt": 0 + }, + "value": "ns2", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 139, + "end": 144, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 152, + "end": 154, + "ctxt": 0 + }, + "properties": [] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-class/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-class/input.js new file mode 100644 index 000000000000..223d0a8b395b --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-class/input.js @@ -0,0 +1 @@ +export class Foo {} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-class/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-class/input.js.json new file mode 100644 index 000000000000..d7e53ed74170 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-class/input.js.json @@ -0,0 +1,45 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 20, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 20, + "ctxt": 0 + }, + "declaration": { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "span": { + "start": 8, + "end": 20, + "ctxt": 0 + }, + "decorators": [], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-function/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-function/input.js new file mode 100644 index 000000000000..f99d4277774f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-function/input.js @@ -0,0 +1 @@ +export function foo() {} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-function/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-function/input.js.json new file mode 100644 index 000000000000..f7da5fd89c1e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-function/input.js.json @@ -0,0 +1,53 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "declaration": { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 17, + "end": 20, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "declare": false, + "params": [], + "decorators": [], + "span": { + "start": 8, + "end": 25, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 23, + "end": 25, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-variable/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-variable/input.js new file mode 100644 index 000000000000..b30bd489f951 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-variable/input.js @@ -0,0 +1 @@ +export const foo = ""; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-variable/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-variable/input.js.json new file mode 100644 index 000000000000..72319783c4d1 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-variable/input.js.json @@ -0,0 +1,61 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "declaration": { + "type": "VariableDeclaration", + "span": { + "start": 8, + "end": 23, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 14, + "end": 22, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "StringLiteral", + "span": { + "start": 20, + "end": 22, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "definite": false + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-without-from/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-without-from/input.js new file mode 100644 index 000000000000..b8017e6930e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-without-from/input.js @@ -0,0 +1,3 @@ +const foo = ""; + +export { foo }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-without-from/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-without-from/input.js.json new file mode 100644 index 000000000000..eeb553cc541f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-export-without-from/input.js.json @@ -0,0 +1,86 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 1, + "end": 16, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 7, + "end": 15, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 7, + "end": 10, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "StringLiteral", + "span": { + "start": 13, + "end": 15, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "definite": false + } + ] + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 18, + "end": 33, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": null, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-string-assertion-key/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-string-assertion-key/input.js new file mode 100644 index 000000000000..dcc37efe8067 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-string-assertion-key/input.js @@ -0,0 +1 @@ +import "foo" assert { "type": "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-string-assertion-key/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-string-assertion-key/input.js.json new file mode 100644 index 000000000000..9b1ed90d9a16 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-string-assertion-key/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 40, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 40, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 21, + "end": 39, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "StringLiteral", + "span": { + "start": 23, + "end": 29, + "ctxt": 0 + }, + "value": "type", + "raw": "\"type\"" + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 31, + "end": 37, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-as-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-as-with-attributes/input.js new file mode 100644 index 000000000000..f97e9ee25718 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-as-with-attributes/input.js @@ -0,0 +1 @@ +export * as foo from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-as-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-as-with-attributes/input.js.json new file mode 100644 index 000000000000..4e709ea2d4c2 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-as-with-attributes/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 57, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 57, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "span": { + "start": 8, + "end": 16, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 13, + "end": 16, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 22, + "end": 32, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 40, + "end": 56, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 42, + "end": 46, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 48, + "end": 54, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-with-attributes/input.js new file mode 100644 index 000000000000..b8a5d6580862 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-with-attributes/input.js @@ -0,0 +1 @@ +export * from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-with-attributes/input.js.json new file mode 100644 index 000000000000..99eb05a6997c --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-star-with-attributes/input.js.json @@ -0,0 +1,63 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportAllDeclaration", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "source": { + "type": "StringLiteral", + "span": { + "start": 15, + "end": 25, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..a3830551716f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +export { default as x } from "foo" assert +{ type: "json" } diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json new file mode 100644 index 000000000000..ee17967ba2e8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json @@ -0,0 +1,94 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 59, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 59, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 22, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 21, + "end": 22, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 30, + "end": 35, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 59, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes-and-value/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes-and-value/input.js new file mode 100644 index 000000000000..567f6335c84c --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +export { "default" as x } from "foo" assert { type: "json" } +[0] diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes-and-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes-and-value/input.js.json new file mode 100644 index 000000000000..1aeff17ea1c5 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes-and-value/input.js.json @@ -0,0 +1,125 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 65, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 61, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 24, + "ctxt": 0 + }, + "orig": { + "type": "StringLiteral", + "span": { + "start": 10, + "end": 19, + "ctxt": 0 + }, + "value": "default", + "raw": "\"default\"" + }, + "exported": { + "type": "Identifier", + "span": { + "start": 23, + "end": 24, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 32, + "end": 37, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 45, + "end": 61, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 47, + "end": 51, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 53, + "end": 59, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 62, + "end": 65, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 62, + "end": 65, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 63, + "end": 64, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes/input.js new file mode 100644 index 000000000000..08775ba22ed4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes/input.js.json new file mode 100644 index 000000000000..a22b0993e613 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-attributes/input.js.json @@ -0,0 +1,94 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 67, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 67, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 24, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 21, + "end": 24, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 32, + "end": 42, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 50, + "end": 66, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 52, + "end": 56, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 58, + "end": 64, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/input.js new file mode 100644 index 000000000000..23710fef0b6d --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/input.js.json new file mode 100644 index 000000000000..248933380c0d --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/input.js.json @@ -0,0 +1,130 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 88, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 88, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 87, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 59, + "end": 63, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 65, + "end": 69, + "ctxt": 0 + }, + "value": true + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 71, + "end": 82, + "ctxt": 0 + }, + "value": "startAtLine", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 84, + "end": 85, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/options.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/options.json new file mode 100644 index 000000000000..6b41733141f4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:64)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-no-type-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-no-type-attribute/input.js new file mode 100644 index 000000000000..5dbd2c429901 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-no-type-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { lazy: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-no-type-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-no-type-attribute/input.js.json new file mode 100644 index 000000000000..3e91223af25e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-no-type-attribute/input.js.json @@ -0,0 +1,85 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 60, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 60, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 59, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-object-method-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-object-method-attribute/input.js new file mode 100644 index 000000000000..8acdf464a395 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-object-method-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-object-method-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-object-method-attribute/input.js.json new file mode 100644 index 000000000000..484d1fa93845 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-with-object-method-attribute/input.js.json @@ -0,0 +1,108 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 84, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 84, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 83, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 59, + "end": 73, + "ctxt": 0 + }, + "value": "hasOwnProperty", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 75, + "end": 81, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-without-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-without-attributes/input.js new file mode 100644 index 000000000000..9408920b3f74 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-without-attributes/input.js @@ -0,0 +1 @@ +export { foo } from "foo.json"; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-without-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-without-attributes/input.js.json new file mode 100644 index 000000000000..1fab6f46fa47 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-export-without-attributes/input.js.json @@ -0,0 +1,53 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 32, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 32, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 13, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 21, + "end": 31, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-and-value/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-and-value/input.js new file mode 100644 index 000000000000..4f1ee63fb3a6 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +import "x" assert { type: "json" } +[0] diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-and-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-and-value/input.js.json new file mode 100644 index 000000000000..60c0a26524b0 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-and-value/input.js.json @@ -0,0 +1,95 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 35, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 19, + "end": 35, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 21, + "end": 25, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 33, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 36, + "end": 39, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 36, + "end": 39, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 37, + "end": 38, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-multiple-lines/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..92c0d33eddd0 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +import "x" assert +{ type: "json" } diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-multiple-lines/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-multiple-lines/input.js.json new file mode 100644 index 000000000000..e09eaa1d96b1 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes-multiple-lines/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 35, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 35, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 19, + "end": 35, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 21, + "end": 25, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 33, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes/input.js.json new file mode 100644 index 000000000000..b840bcf6b2d4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-attributes/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 51, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/input.js new file mode 100644 index 000000000000..01425ab2e2e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/input.js.json new file mode 100644 index 000000000000..501c1f581cf8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/input.js.json @@ -0,0 +1,128 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 80, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 80, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 79, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 51, + "end": 55, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 57, + "end": 61, + "ctxt": 0 + }, + "value": true + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 63, + "end": 74, + "ctxt": 0 + }, + "value": "startAtLine", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 76, + "end": 77, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/options.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/options.json new file mode 100644 index 000000000000..64ca989b41fc --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:56)" +} \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-no-type-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-no-type-attribute/input.js new file mode 100644 index 000000000000..bdcedd93bb26 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-no-type-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { lazy: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-no-type-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-no-type-attribute/input.js.json new file mode 100644 index 000000000000..ae7d82d1cc31 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-no-type-attribute/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 51, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-object-method-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-object-method-attribute/input.js new file mode 100644 index 000000000000..828d93472261 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-object-method-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-object-method-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-object-method-attribute/input.js.json new file mode 100644 index 000000000000..24bc02221c53 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-with-object-method-attribute/input.js.json @@ -0,0 +1,106 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 76, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 76, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 75, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 51, + "end": 65, + "ctxt": 0 + }, + "value": "hasOwnProperty", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 67, + "end": 73, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-without-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-without-attributes/input.js new file mode 100644 index 000000000000..92901ed56b38 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-without-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json"; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-without-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-without-attributes/input.js.json new file mode 100644 index 000000000000..ceee136de005 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/valid-syntax-without-attributes/input.js.json @@ -0,0 +1,51 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 28, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 28, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/input.js new file mode 100644 index 000000000000..1c8a0e797620 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/input.js @@ -0,0 +1 @@ +; \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/input.js.json new file mode 100644 index 000000000000..286235fd10e0 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/input.js.json @@ -0,0 +1,19 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 2, + "ctxt": 0 + }, + "body": [ + { + "type": "EmptyStatement", + "span": { + "start": 1, + "end": 2, + "ctxt": 0 + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/options.json b/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/options.json new file mode 100644 index 000000000000..f93381a098e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/with-import-attributes/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + "importAttributes", + "importAssertions" + ], + "sourceType": "module", + "throws": "Cannot combine importAssertions and importAttributes plugins." +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/input.js b/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/input.js.json b/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/input.js.json new file mode 100644 index 000000000000..b840bcf6b2d4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 51, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/options.json b/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/options.json new file mode 100644 index 000000000000..43b0784e30a8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-assertions/without-plugin/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"importAttributes\", \"importAssertions\". (1:27)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js new file mode 100644 index 000000000000..e93bcb742ad0 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js @@ -0,0 +1 @@ +import "foo" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js.json new file mode 100644 index 000000000000..f5a02b2121ce --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 38, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 38, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 21, + "end": 37, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 23, + "end": 27, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 29, + "end": 35, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/options.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/options.json new file mode 100644 index 000000000000..cc7fb4a170d9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/_deprecated-syntax-not-enabled/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["importAttributes"], + "sourceType": "module" +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/input.js new file mode 100644 index 000000000000..481c52e1c75f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/input.js @@ -0,0 +1 @@ +import("foo.json", { assert: { type: "json" } }) diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/input.js.json new file mode 100644 index 000000000000..206b7d871acf --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/dynamic-import-with-valid-syntax/input.js.json @@ -0,0 +1,110 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 49, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 49, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 49, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 18, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 20, + "end": 48, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 22, + "end": 28, + "ctxt": 0 + }, + "value": "assert", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 30, + "end": 46, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 32, + "end": 36, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 38, + "end": 44, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/input.js new file mode 100644 index 000000000000..5b6c5fa3373a --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/input.js @@ -0,0 +1,2 @@ +import "x" +assert ({}); diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/input.js.json new file mode 100644 index 000000000000..3db741256e66 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/import-assert-call-expression/input.js.json @@ -0,0 +1,73 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 24, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 11, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": null + }, + { + "type": "ExpressionStatement", + "span": { + "start": 12, + "end": 24, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 12, + "end": 23, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 12, + "end": 18, + "ctxt": 0 + }, + "value": "assert", + "optional": false + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 20, + "end": 22, + "ctxt": 0 + }, + "properties": [] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/incorrect-arity/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/incorrect-arity/input.js new file mode 100644 index 000000000000..0863c2ee4884 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/incorrect-arity/input.js @@ -0,0 +1,2 @@ +import(); +import("./foo.json", { assert: { type: "json"} }, "unsupported"); diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/incorrect-arity/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/incorrect-arity/input.js.json new file mode 100644 index 000000000000..8ed0a7d7ca29 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/incorrect-arity/input.js.json @@ -0,0 +1,149 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 76, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 10, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 9, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 11, + "end": 76, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 11, + "end": 75, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 11, + "end": 17, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 18, + "end": 30, + "ctxt": 0 + }, + "value": "./foo.json", + "raw": "\"./foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 32, + "end": 59, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 34, + "end": 40, + "ctxt": 0 + }, + "value": "assert", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 42, + "end": 57, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 44, + "end": 48, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 50, + "end": 56, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + }, + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 61, + "end": 74, + "ctxt": 0 + }, + "value": "unsupported", + "raw": "\"unsupported\"" + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/options.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/options.json new file mode 100644 index 000000000000..49dd7647ae83 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + ["importAttributes", { "deprecatedAssertSyntax": true }] + ], + "sourceType": "module" +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/string-literal/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/string-literal/input.js new file mode 100644 index 000000000000..1c1e4b79e789 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/string-literal/input.js @@ -0,0 +1,2 @@ +import foo from "foo.json" assert { for: "for" } +export { foo } from "foo.json" assert { for: "for" } diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/string-literal/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/string-literal/input.js.json new file mode 100644 index 000000000000..07d0b11960ef --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/string-literal/input.js.json @@ -0,0 +1,157 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 102, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 49, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 40, + "ctxt": 0 + }, + "value": "for", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 42, + "end": 47, + "ctxt": 0 + }, + "value": "for", + "raw": "\"for\"" + } + } + ] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 50, + "end": 102, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 59, + "end": 62, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 59, + "end": 62, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 70, + "end": 80, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 88, + "end": 102, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 90, + "end": 93, + "ctxt": 0 + }, + "value": "for", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 95, + "end": 100, + "ctxt": 0 + }, + "value": "for", + "raw": "\"for\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/input.js new file mode 100644 index 000000000000..b448aa280c34 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/input.js @@ -0,0 +1,2 @@ +import("foo.js",); +import("foo.json", { assert: { type: "json" } },); diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/input.js.json new file mode 100644 index 000000000000..9f9aeca6124a --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma-dynamic/input.js.json @@ -0,0 +1,150 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 70, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 19, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 18, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 16, + "ctxt": 0 + }, + "value": "foo.js", + "raw": "\"foo.js\"" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 20, + "end": 70, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 20, + "end": 69, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 20, + "end": 26, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 37, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 39, + "end": 67, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "assert", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 49, + "end": 65, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 51, + "end": 55, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 57, + "end": 63, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma/input.js new file mode 100644 index 000000000000..077d150d81ae --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma/input.js @@ -0,0 +1,2 @@ +import foo from "foo" assert { type: "json", } +export { default as foo } from "foo" assert { type: "json", } diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma/input.js.json new file mode 100644 index 000000000000..e87ce65888f1 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/trailing-comma/input.js.json @@ -0,0 +1,166 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 109, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 22, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 30, + "end": 47, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 32, + "end": 36, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 38, + "end": 44, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 48, + "end": 109, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 57, + "end": 71, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 57, + "end": 64, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 68, + "end": 71, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 79, + "end": 84, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 92, + "end": 109, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 94, + "end": 98, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 100, + "end": 106, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/input.js new file mode 100644 index 000000000000..758659de4037 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/input.js @@ -0,0 +1,4 @@ +import foo, { bar } from "foo" assert {}; +import * as ns from "foo" assert {}; +export { quux } from "foo" assert {}; +export * as ns2 from "foo" assert {}; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/input.js.json new file mode 100644 index 000000000000..6920136614ca --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-empty-attribute/input.js.json @@ -0,0 +1,225 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 155, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 42, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + }, + { + "type": "ImportSpecifier", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "value": "bar", + "optional": false + }, + "imported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 26, + "end": 31, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 39, + "end": 41, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ImportDeclaration", + "span": { + "start": 43, + "end": 79, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "span": { + "start": 50, + "end": 57, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 55, + "end": 57, + "ctxt": 0 + }, + "value": "ns", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 63, + "end": 68, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 76, + "end": 78, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 80, + "end": 117, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 89, + "end": 93, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 89, + "end": 93, + "ctxt": 0 + }, + "value": "quux", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 101, + "end": 106, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 114, + "end": 116, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 118, + "end": 155, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "span": { + "start": 125, + "end": 133, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 130, + "end": 133, + "ctxt": 0 + }, + "value": "ns2", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 139, + "end": 144, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 152, + "end": 154, + "ctxt": 0 + }, + "properties": [] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-class/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-class/input.js new file mode 100644 index 000000000000..223d0a8b395b --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-class/input.js @@ -0,0 +1 @@ +export class Foo {} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-class/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-class/input.js.json new file mode 100644 index 000000000000..d7e53ed74170 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-class/input.js.json @@ -0,0 +1,45 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 20, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 20, + "ctxt": 0 + }, + "declaration": { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "span": { + "start": 8, + "end": 20, + "ctxt": 0 + }, + "decorators": [], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-function/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-function/input.js new file mode 100644 index 000000000000..f99d4277774f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-function/input.js @@ -0,0 +1 @@ +export function foo() {} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-function/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-function/input.js.json new file mode 100644 index 000000000000..f7da5fd89c1e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-function/input.js.json @@ -0,0 +1,53 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "declaration": { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 17, + "end": 20, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "declare": false, + "params": [], + "decorators": [], + "span": { + "start": 8, + "end": 25, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 23, + "end": 25, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-variable/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-variable/input.js new file mode 100644 index 000000000000..b30bd489f951 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-variable/input.js @@ -0,0 +1 @@ +export const foo = ""; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-variable/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-variable/input.js.json new file mode 100644 index 000000000000..72319783c4d1 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-variable/input.js.json @@ -0,0 +1,61 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "declaration": { + "type": "VariableDeclaration", + "span": { + "start": 8, + "end": 23, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 14, + "end": 22, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "StringLiteral", + "span": { + "start": 20, + "end": 22, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "definite": false + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-without-from/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-without-from/input.js new file mode 100644 index 000000000000..b8017e6930e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-without-from/input.js @@ -0,0 +1,3 @@ +const foo = ""; + +export { foo }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-without-from/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-without-from/input.js.json new file mode 100644 index 000000000000..eeb553cc541f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-export-without-from/input.js.json @@ -0,0 +1,86 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 1, + "end": 16, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 7, + "end": 15, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 7, + "end": 10, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "StringLiteral", + "span": { + "start": 13, + "end": 15, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "definite": false + } + ] + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 18, + "end": 33, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": null, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/input.js new file mode 100644 index 000000000000..dcc37efe8067 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/input.js @@ -0,0 +1 @@ +import "foo" assert { "type": "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/input.js.json new file mode 100644 index 000000000000..9b1ed90d9a16 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-string-attribute-key/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 40, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 40, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 21, + "end": 39, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "StringLiteral", + "span": { + "start": 23, + "end": 29, + "ctxt": 0 + }, + "value": "type", + "raw": "\"type\"" + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 31, + "end": 37, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/input.js new file mode 100644 index 000000000000..f97e9ee25718 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/input.js @@ -0,0 +1 @@ +export * as foo from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/input.js.json new file mode 100644 index 000000000000..4e709ea2d4c2 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-as-with-attributes/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 57, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 57, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "span": { + "start": 8, + "end": 16, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 13, + "end": 16, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 22, + "end": 32, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 40, + "end": 56, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 42, + "end": 46, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 48, + "end": 54, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/input.js new file mode 100644 index 000000000000..b8a5d6580862 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/input.js @@ -0,0 +1 @@ +export * from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/input.js.json new file mode 100644 index 000000000000..99eb05a6997c --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-star-with-attributes/input.js.json @@ -0,0 +1,63 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportAllDeclaration", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "source": { + "type": "StringLiteral", + "span": { + "start": 15, + "end": 25, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..a3830551716f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +export { default as x } from "foo" assert +{ type: "json" } diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json new file mode 100644 index 000000000000..ee17967ba2e8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json @@ -0,0 +1,94 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 59, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 59, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 22, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 21, + "end": 22, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 30, + "end": 35, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 59, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/input.js new file mode 100644 index 000000000000..567f6335c84c --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +export { "default" as x } from "foo" assert { type: "json" } +[0] diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/input.js.json new file mode 100644 index 000000000000..1aeff17ea1c5 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes-and-value/input.js.json @@ -0,0 +1,125 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 65, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 61, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 24, + "ctxt": 0 + }, + "orig": { + "type": "StringLiteral", + "span": { + "start": 10, + "end": 19, + "ctxt": 0 + }, + "value": "default", + "raw": "\"default\"" + }, + "exported": { + "type": "Identifier", + "span": { + "start": 23, + "end": 24, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 32, + "end": 37, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 45, + "end": 61, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 47, + "end": 51, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 53, + "end": 59, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 62, + "end": 65, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 62, + "end": 65, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 63, + "end": 64, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/input.js new file mode 100644 index 000000000000..08775ba22ed4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/input.js.json new file mode 100644 index 000000000000..a22b0993e613 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-attributes/input.js.json @@ -0,0 +1,94 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 67, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 67, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 24, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 21, + "end": 24, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 32, + "end": 42, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 50, + "end": 66, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 52, + "end": 56, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 58, + "end": 64, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/input.js new file mode 100644 index 000000000000..23710fef0b6d --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/input.js.json new file mode 100644 index 000000000000..248933380c0d --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/input.js.json @@ -0,0 +1,130 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 88, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 88, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 87, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 59, + "end": 63, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 65, + "end": 69, + "ctxt": 0 + }, + "value": true + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 71, + "end": 82, + "ctxt": 0 + }, + "value": "startAtLine", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 84, + "end": 85, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/options.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/options.json new file mode 100644 index 000000000000..6b41733141f4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:64)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/input.js new file mode 100644 index 000000000000..5dbd2c429901 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { lazy: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/input.js.json new file mode 100644 index 000000000000..3e91223af25e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-no-type-attribute/input.js.json @@ -0,0 +1,85 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 60, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 60, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 59, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/input.js new file mode 100644 index 000000000000..8acdf464a395 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/input.js.json new file mode 100644 index 000000000000..484d1fa93845 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-with-object-method-attribute/input.js.json @@ -0,0 +1,108 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 84, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 84, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 83, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 59, + "end": 73, + "ctxt": 0 + }, + "value": "hasOwnProperty", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 75, + "end": 81, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/input.js new file mode 100644 index 000000000000..9408920b3f74 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/input.js @@ -0,0 +1 @@ +export { foo } from "foo.json"; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/input.js.json new file mode 100644 index 000000000000..1fab6f46fa47 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-export-without-attributes/input.js.json @@ -0,0 +1,53 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 32, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 32, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 13, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 21, + "end": 31, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/input.js new file mode 100644 index 000000000000..4f1ee63fb3a6 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +import "x" assert { type: "json" } +[0] diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/input.js.json new file mode 100644 index 000000000000..60c0a26524b0 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-and-value/input.js.json @@ -0,0 +1,95 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 39, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 35, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 19, + "end": 35, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 21, + "end": 25, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 33, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 36, + "end": 39, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 36, + "end": 39, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 37, + "end": 38, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..92c0d33eddd0 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +import "x" assert +{ type: "json" } diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/input.js.json new file mode 100644 index 000000000000..e09eaa1d96b1 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes-multiple-lines/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 35, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 35, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 19, + "end": 35, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 21, + "end": 25, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 33, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/input.js.json new file mode 100644 index 000000000000..b840bcf6b2d4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-attributes/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 51, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/input.js new file mode 100644 index 000000000000..01425ab2e2e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/input.js.json new file mode 100644 index 000000000000..501c1f581cf8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/input.js.json @@ -0,0 +1,128 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 80, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 80, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 79, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 51, + "end": 55, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 57, + "end": 61, + "ctxt": 0 + }, + "value": true + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 63, + "end": 74, + "ctxt": 0 + }, + "value": "startAtLine", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 76, + "end": 77, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/options.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/options.json new file mode 100644 index 000000000000..64ca989b41fc --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:56)" +} \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/input.js new file mode 100644 index 000000000000..bdcedd93bb26 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { lazy: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/input.js.json new file mode 100644 index 000000000000..ae7d82d1cc31 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-no-type-attribute/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 51, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/input.js new file mode 100644 index 000000000000..828d93472261 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json", hasOwnProperty: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/input.js.json new file mode 100644 index 000000000000..24bc02221c53 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-with-object-method-attribute/input.js.json @@ -0,0 +1,106 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 76, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 76, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 75, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 51, + "end": 65, + "ctxt": 0 + }, + "value": "hasOwnProperty", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 67, + "end": 73, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/input.js new file mode 100644 index 000000000000..92901ed56b38 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json"; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/input.js.json new file mode 100644 index 000000000000..ceee136de005 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/valid-syntax-without-attributes/input.js.json @@ -0,0 +1,51 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 28, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 28, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/input.js b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/input.js new file mode 100644 index 000000000000..7b43091236b9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/input.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/input.js.json new file mode 100644 index 000000000000..b840bcf6b2d4 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 52, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 35, + "end": 51, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 37, + "end": 41, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 43, + "end": 49, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/options.json b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/options.json new file mode 100644 index 000000000000..43b0784e30a8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes-deprecatedAssertKeyword/without-plugin/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"importAttributes\", \"importAssertions\". (1:27)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/dynamic-import-with-valid-syntax/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/dynamic-import-with-valid-syntax/input.js new file mode 100644 index 000000000000..baa60fc43c5f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/dynamic-import-with-valid-syntax/input.js @@ -0,0 +1 @@ +import("foo.json", { with: { type: "json" } }) diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/dynamic-import-with-valid-syntax/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/dynamic-import-with-valid-syntax/input.js.json new file mode 100644 index 000000000000..19232204d4fb --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/dynamic-import-with-valid-syntax/input.js.json @@ -0,0 +1,110 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 18, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 20, + "end": 46, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 22, + "end": 26, + "ctxt": 0 + }, + "value": "with", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 28, + "end": 44, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 30, + "end": 34, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 36, + "end": 42, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/options.json b/crates/swc_ecma_parser/tests/js/import-attributes/options.json new file mode 100644 index 000000000000..cc7fb4a170d9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["importAttributes"], + "sourceType": "module" +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/string-literal/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/string-literal/input.js new file mode 100644 index 000000000000..8af887a3cc06 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/string-literal/input.js @@ -0,0 +1,2 @@ +import foo from "foo.json" with { for: "for" } +export { foo } from "foo.json" with { for: "for" } diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/string-literal/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/string-literal/input.js.json new file mode 100644 index 000000000000..7d7551301b94 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/string-literal/input.js.json @@ -0,0 +1,157 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 98, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 47, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 47, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 38, + "ctxt": 0 + }, + "value": "for", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 40, + "end": 45, + "ctxt": 0 + }, + "value": "for", + "raw": "\"for\"" + } + } + ] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 48, + "end": 98, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 57, + "end": 60, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 57, + "end": 60, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 68, + "end": 78, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 84, + "end": 98, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 86, + "end": 89, + "ctxt": 0 + }, + "value": "for", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 91, + "end": 96, + "ctxt": 0 + }, + "value": "for", + "raw": "\"for\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma-dynamic/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma-dynamic/input.js new file mode 100644 index 000000000000..0be461789922 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma-dynamic/input.js @@ -0,0 +1,2 @@ +import("foo.js",); +import("foo.json", { with: { type: "json" } },); diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma-dynamic/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma-dynamic/input.js.json new file mode 100644 index 000000000000..f444874d38ce --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma-dynamic/input.js.json @@ -0,0 +1,150 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 68, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 1, + "end": 19, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1, + "end": 18, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 1, + "end": 7, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 16, + "ctxt": 0 + }, + "value": "foo.js", + "raw": "\"foo.js\"" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 20, + "end": 68, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 20, + "end": 67, + "ctxt": 0 + }, + "callee": { + "type": "Import", + "span": { + "start": 20, + "end": 26, + "ctxt": 0 + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 27, + "end": 37, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 39, + "end": 65, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 41, + "end": 45, + "ctxt": 0 + }, + "value": "with", + "optional": false + }, + "value": { + "type": "ObjectExpression", + "span": { + "start": 47, + "end": 63, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 49, + "end": 53, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 55, + "end": 61, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ] + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma/input.js new file mode 100644 index 000000000000..10bc32278776 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma/input.js @@ -0,0 +1,2 @@ +import foo from "foo" with { type: "json", } +export { default as foo } from "foo" with { type: "json", } diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma/input.js.json new file mode 100644 index 000000000000..ed75c95085e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/trailing-comma/input.js.json @@ -0,0 +1,166 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 105, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 45, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 22, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 28, + "end": 45, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 30, + "end": 34, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 36, + "end": 42, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 46, + "end": 105, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 55, + "end": 69, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 55, + "end": 62, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 66, + "end": 69, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 77, + "end": 82, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 88, + "end": 105, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 90, + "end": 94, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 96, + "end": 102, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-empty-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-empty-attribute/input.js new file mode 100644 index 000000000000..8bde57a92d52 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-empty-attribute/input.js @@ -0,0 +1,4 @@ +import foo, { bar } from "foo" with {}; +import * as ns from "foo" with {}; +export { quux } from "foo" with {}; +export * as ns2 from "foo" with {}; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-empty-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-empty-attribute/input.js.json new file mode 100644 index 000000000000..35cd77cd1213 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-empty-attribute/input.js.json @@ -0,0 +1,225 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 147, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 40, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + }, + { + "type": "ImportSpecifier", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 15, + "end": 18, + "ctxt": 0 + }, + "value": "bar", + "optional": false + }, + "imported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 26, + "end": 31, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 37, + "end": 39, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ImportDeclaration", + "span": { + "start": 41, + "end": 75, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "span": { + "start": 48, + "end": 55, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 53, + "end": 55, + "ctxt": 0 + }, + "value": "ns", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 61, + "end": 66, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 72, + "end": 74, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 76, + "end": 111, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 85, + "end": 89, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 85, + "end": 89, + "ctxt": 0 + }, + "value": "quux", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 97, + "end": 102, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 108, + "end": 110, + "ctxt": 0 + }, + "properties": [] + } + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 112, + "end": 147, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "span": { + "start": 119, + "end": 127, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 124, + "end": 127, + "ctxt": 0 + }, + "value": "ns2", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 133, + "end": 138, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 144, + "end": 146, + "ctxt": 0 + }, + "properties": [] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-class/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-class/input.js new file mode 100644 index 000000000000..223d0a8b395b --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-class/input.js @@ -0,0 +1 @@ +export class Foo {} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-class/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-class/input.js.json new file mode 100644 index 000000000000..d7e53ed74170 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-class/input.js.json @@ -0,0 +1,45 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 20, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 20, + "ctxt": 0 + }, + "declaration": { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "span": { + "start": 8, + "end": 20, + "ctxt": 0 + }, + "decorators": [], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-function/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-function/input.js new file mode 100644 index 000000000000..f99d4277774f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-function/input.js @@ -0,0 +1 @@ +export function foo() {} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-function/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-function/input.js.json new file mode 100644 index 000000000000..f7da5fd89c1e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-function/input.js.json @@ -0,0 +1,53 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 25, + "ctxt": 0 + }, + "declaration": { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 17, + "end": 20, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "declare": false, + "params": [], + "decorators": [], + "span": { + "start": 8, + "end": 25, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 23, + "end": 25, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-variable/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-variable/input.js new file mode 100644 index 000000000000..b30bd489f951 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-variable/input.js @@ -0,0 +1 @@ +export const foo = ""; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-variable/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-variable/input.js.json new file mode 100644 index 000000000000..72319783c4d1 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-variable/input.js.json @@ -0,0 +1,61 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 1, + "end": 23, + "ctxt": 0 + }, + "declaration": { + "type": "VariableDeclaration", + "span": { + "start": 8, + "end": 23, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 14, + "end": 22, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 14, + "end": 17, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "StringLiteral", + "span": { + "start": 20, + "end": 22, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "definite": false + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-without-from/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-without-from/input.js new file mode 100644 index 000000000000..b8017e6930e7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-without-from/input.js @@ -0,0 +1,3 @@ +const foo = ""; + +export { foo }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-without-from/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-without-from/input.js.json new file mode 100644 index 000000000000..eeb553cc541f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-export-without-from/input.js.json @@ -0,0 +1,86 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 1, + "end": 16, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 7, + "end": 15, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 7, + "end": 10, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "StringLiteral", + "span": { + "start": 13, + "end": 15, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "definite": false + } + ] + }, + { + "type": "ExportNamedDeclaration", + "span": { + "start": 18, + "end": 33, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 27, + "end": 30, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": null, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-string-attribute-key/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-string-attribute-key/input.js new file mode 100644 index 000000000000..74070b3d002e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-string-attribute-key/input.js @@ -0,0 +1 @@ +import "foo" with { "type": "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-string-attribute-key/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-string-attribute-key/input.js.json new file mode 100644 index 000000000000..1144c1ec4a1f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-string-attribute-key/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 38, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 38, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 19, + "end": 37, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "StringLiteral", + "span": { + "start": 21, + "end": 27, + "ctxt": 0 + }, + "value": "type", + "raw": "\"type\"" + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 29, + "end": 35, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-as-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-as-with-attributes/input.js new file mode 100644 index 000000000000..4e9fbefb8919 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-as-with-attributes/input.js @@ -0,0 +1 @@ +export * as foo from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-as-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-as-with-attributes/input.js.json new file mode 100644 index 000000000000..31ff2700f508 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-as-with-attributes/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 55, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 55, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "span": { + "start": 8, + "end": 16, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 13, + "end": 16, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 22, + "end": 32, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 38, + "end": 54, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 40, + "end": 44, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 46, + "end": 52, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-with-attributes/input.js new file mode 100644 index 000000000000..70566cfaf1f3 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-with-attributes/input.js @@ -0,0 +1 @@ +export * from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-with-attributes/input.js.json new file mode 100644 index 000000000000..de088e63f124 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-star-with-attributes/input.js.json @@ -0,0 +1,63 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 48, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportAllDeclaration", + "span": { + "start": 1, + "end": 48, + "ctxt": 0 + }, + "source": { + "type": "StringLiteral", + "span": { + "start": 15, + "end": 25, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 31, + "end": 47, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 33, + "end": 37, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 39, + "end": 45, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..e8a58d263541 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +export { default as x } from "foo" with +{ type: "json" } diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json new file mode 100644 index 000000000000..8e059e69e3b3 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-and-attributes-multiple-lines/input.js.json @@ -0,0 +1,94 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 57, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 57, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 22, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 21, + "end": 22, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 30, + "end": 35, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 41, + "end": 57, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 49, + "end": 55, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes-and-value/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes-and-value/input.js new file mode 100644 index 000000000000..458d863897b5 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +export { "default" as x } from "foo" with { type: "json" } +[0] diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes-and-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes-and-value/input.js.json new file mode 100644 index 000000000000..5e0193073017 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes-and-value/input.js.json @@ -0,0 +1,125 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 63, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 59, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 24, + "ctxt": 0 + }, + "orig": { + "type": "StringLiteral", + "span": { + "start": 10, + "end": 19, + "ctxt": 0 + }, + "value": "default", + "raw": "\"default\"" + }, + "exported": { + "type": "Identifier", + "span": { + "start": 23, + "end": 24, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 32, + "end": 37, + "ctxt": 0 + }, + "value": "foo", + "raw": "\"foo\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 43, + "end": 59, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 45, + "end": 49, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 60, + "end": 63, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 60, + "end": 63, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 61, + "end": 62, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes/input.js new file mode 100644 index 000000000000..8d791f4fe480 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes/input.js @@ -0,0 +1 @@ +export { default as foo } from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes/input.js.json new file mode 100644 index 000000000000..9a904f8fa354 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-attributes/input.js.json @@ -0,0 +1,94 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 65, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 65, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 24, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": { + "type": "Identifier", + "span": { + "start": 21, + "end": 24, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 32, + "end": 42, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 48, + "end": 64, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 50, + "end": 54, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 56, + "end": 62, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/input.js new file mode 100644 index 000000000000..7a70c7f04630 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/input.js.json new file mode 100644 index 000000000000..3db03e505e89 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/input.js.json @@ -0,0 +1,130 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 86, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 86, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 41, + "end": 85, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 49, + "end": 55, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 57, + "end": 61, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 63, + "end": 67, + "ctxt": 0 + }, + "value": true + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 69, + "end": 80, + "ctxt": 0 + }, + "value": "startAtLine", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 82, + "end": 83, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/options.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/options.json new file mode 100644 index 000000000000..3b039e9a62e8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:62)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-no-type-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-no-type-attribute/input.js new file mode 100644 index 000000000000..4553d256b1cb --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-no-type-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" with { lazy: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-no-type-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-no-type-attribute/input.js.json new file mode 100644 index 000000000000..aebfcf2f2050 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-no-type-attribute/input.js.json @@ -0,0 +1,85 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 58, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 58, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 41, + "end": 57, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 49, + "end": 55, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-object-method-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-object-method-attribute/input.js new file mode 100644 index 000000000000..0e8993714a3f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-object-method-attribute/input.js @@ -0,0 +1 @@ +export { default } from "foo.json" with { type: "json", hasOwnProperty: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-object-method-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-object-method-attribute/input.js.json new file mode 100644 index 000000000000..9bde76e2db26 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-with-object-method-attribute/input.js.json @@ -0,0 +1,108 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 82, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 82, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 17, + "ctxt": 0 + }, + "value": "default", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 35, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 41, + "end": 81, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 43, + "end": 47, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 49, + "end": 55, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 57, + "end": 71, + "ctxt": 0 + }, + "value": "hasOwnProperty", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 73, + "end": 79, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-without-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-without-attributes/input.js new file mode 100644 index 000000000000..9408920b3f74 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-without-attributes/input.js @@ -0,0 +1 @@ +export { foo } from "foo.json"; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-without-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-without-attributes/input.js.json new file mode 100644 index 000000000000..1fab6f46fa47 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-export-without-attributes/input.js.json @@ -0,0 +1,53 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 32, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportNamedDeclaration", + "span": { + "start": 1, + "end": 32, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "span": { + "start": 10, + "end": 13, + "ctxt": 0 + }, + "orig": { + "type": "Identifier", + "span": { + "start": 10, + "end": 13, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "exported": null, + "isTypeOnly": false + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 21, + "end": 31, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-and-value/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-and-value/input.js new file mode 100644 index 000000000000..b9907829ef29 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-and-value/input.js @@ -0,0 +1,2 @@ +import "x" with { type: "json" } +[0] diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-and-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-and-value/input.js.json new file mode 100644 index 000000000000..11ca16be006d --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-and-value/input.js.json @@ -0,0 +1,95 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 37, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 17, + "end": 33, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 19, + "end": 23, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 31, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 34, + "end": 37, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 34, + "end": 37, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 35, + "end": 36, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js new file mode 100644 index 000000000000..e78e2c90f72d --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js @@ -0,0 +1,2 @@ +import "x" with +{ type: "json" } diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js.json new file mode 100644 index 000000000000..dc2332b10b3f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes-multiple-lines/input.js.json @@ -0,0 +1,64 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 33, + "ctxt": 0 + }, + "specifiers": [], + "source": { + "type": "StringLiteral", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "x", + "raw": "\"x\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 17, + "end": 33, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 19, + "end": 23, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 25, + "end": 31, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes/input.js new file mode 100644 index 000000000000..83c51c971889 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes/input.js.json new file mode 100644 index 000000000000..6d1ec7a3ddb7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-attributes/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/input.js new file mode 100644 index 000000000000..3f350904e07f --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json", lazy: true, startAtLine: 1 }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/input.js.json new file mode 100644 index 000000000000..b8f5c7f70ffd --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/input.js.json @@ -0,0 +1,128 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 78, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 78, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 77, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 49, + "end": 53, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 55, + "end": 59, + "ctxt": 0 + }, + "value": true + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 61, + "end": 72, + "ctxt": 0 + }, + "value": "startAtLine", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 74, + "end": 75, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/options.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/options.json new file mode 100644 index 000000000000..9326901e4d93 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-invalid-value/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Only string literals are allowed as module attribute values. (1:54)" +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-no-type-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-no-type-attribute/input.js new file mode 100644 index 000000000000..1858e49c2022 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-no-type-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { lazy: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-no-type-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-no-type-attribute/input.js.json new file mode 100644 index 000000000000..9c200d6135d2 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-no-type-attribute/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "lazy", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-object-method-attribute/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-object-method-attribute/input.js new file mode 100644 index 000000000000..2ec8345c8e15 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-object-method-attribute/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json", hasOwnProperty: "true" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-object-method-attribute/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-object-method-attribute/input.js.json new file mode 100644 index 000000000000..1a2283544bc9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-with-object-method-attribute/input.js.json @@ -0,0 +1,106 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 74, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 74, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 73, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 49, + "end": 63, + "ctxt": 0 + }, + "value": "hasOwnProperty", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 65, + "end": 71, + "ctxt": 0 + }, + "value": "true", + "raw": "\"true\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-without-attributes/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-without-attributes/input.js new file mode 100644 index 000000000000..92901ed56b38 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-without-attributes/input.js @@ -0,0 +1 @@ +import foo from "foo.json"; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-without-attributes/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-without-attributes/input.js.json new file mode 100644 index 000000000000..ceee136de005 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/valid-syntax-without-attributes/input.js.json @@ -0,0 +1,51 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 28, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 28, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/input.js b/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/input.js new file mode 100644 index 000000000000..83c51c971889 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/input.js @@ -0,0 +1 @@ +import foo from "foo.json" with { type: "json" }; diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/input.js.json b/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/input.js.json new file mode 100644 index 000000000000..6d1ec7a3ddb7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/input.js.json @@ -0,0 +1,83 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "body": [ + { + "type": "ImportDeclaration", + "span": { + "start": 1, + "end": 50, + "ctxt": 0 + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "local": { + "type": "Identifier", + "span": { + "start": 8, + "end": 11, + "ctxt": 0 + }, + "value": "foo", + "optional": false + } + } + ], + "source": { + "type": "StringLiteral", + "span": { + "start": 17, + "end": 27, + "ctxt": 0 + }, + "value": "foo.json", + "raw": "\"foo.json\"" + }, + "typeOnly": false, + "with": { + "type": "ObjectExpression", + "span": { + "start": 33, + "end": 49, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 35, + "end": 39, + "ctxt": 0 + }, + "value": "type", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "value": "json", + "raw": "\"json\"" + } + } + ] + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/options.json b/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/options.json new file mode 100644 index 000000000000..a1899f538d7e --- /dev/null +++ b/crates/swc_ecma_parser/tests/js/import-attributes/without-plugin/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: \"importAttributes\". (1:32)" +} diff --git a/crates/swc_ecma_parser/tests/jsx/basic/custom/unary-paren/input.js.json b/crates/swc_ecma_parser/tests/jsx/basic/custom/unary-paren/input.js.json index ff8cefb6c76d..e5695e39c5c5 100644 --- a/crates/swc_ecma_parser/tests/jsx/basic/custom/unary-paren/input.js.json +++ b/crates/swc_ecma_parser/tests/jsx/basic/custom/unary-paren/input.js.json @@ -44,7 +44,7 @@ "raw": "'react'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "FunctionDeclaration", diff --git a/crates/swc_ecma_parser/tests/jsx/basic/custom/unary/input.js.json b/crates/swc_ecma_parser/tests/jsx/basic/custom/unary/input.js.json index 37b42ea76295..a77f09db10b7 100644 --- a/crates/swc_ecma_parser/tests/jsx/basic/custom/unary/input.js.json +++ b/crates/swc_ecma_parser/tests/jsx/basic/custom/unary/input.js.json @@ -44,7 +44,7 @@ "raw": "'react'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "FunctionDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/allowImportingTsExtensions.json b/crates/swc_ecma_parser/tests/tsc/allowImportingTsExtensions.json index ae25b197c6d5..4e8b6e264ee2 100644 --- a/crates/swc_ecma_parser/tests/tsc/allowImportingTsExtensions.json +++ b/crates/swc_ecma_parser/tests/tsc/allowImportingTsExtensions.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -28,7 +28,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -40,7 +40,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -61,7 +61,7 @@ "raw": "\"./ts.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -82,7 +82,7 @@ "raw": "\"./ts.ts\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -103,7 +103,7 @@ "raw": "\"./ts.d.ts\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -124,7 +124,7 @@ "raw": "\"./tsx.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -145,7 +145,7 @@ "raw": "\"./tsx.jsx\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -166,7 +166,7 @@ "raw": "\"./tsx.ts\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -187,7 +187,7 @@ "raw": "\"./tsx.tsx\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -208,7 +208,7 @@ "raw": "\"./tsx.d.ts\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -229,7 +229,7 @@ "raw": "\"./dts.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -250,7 +250,7 @@ "raw": "\"./dts.ts\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -271,7 +271,7 @@ "raw": "\"./dts.d.ts\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -292,7 +292,7 @@ "raw": "\"./thisfiledoesnotexist.ts\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.json b/crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.json index 5364fb866d1d..528e4cc13d81 100644 --- a/crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.json +++ b/crates/swc_ecma_parser/tests/tsc/allowImportingTypesDtsExtension.json @@ -125,7 +125,7 @@ "raw": "\"./types.d.ts\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -167,7 +167,7 @@ "raw": "\"./types.d.ts\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/ambient.json b/crates/swc_ecma_parser/tests/tsc/ambient.json index 3004487c6819..108c1b299ddf 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambient.json +++ b/crates/swc_ecma_parser/tests/tsc/ambient.json @@ -126,7 +126,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns.json b/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns.json index b3ec6fdbc8a9..7c4fcb8d0a95 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns.json @@ -454,7 +454,7 @@ "raw": "\"foobarbaz\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -538,7 +538,7 @@ "raw": "\"foosball\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -620,7 +620,7 @@ "raw": "\"./file!text\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging1.json b/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging1.json index e6e594839788..690f1d92d8cd 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging1.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging1.json @@ -145,7 +145,7 @@ "raw": "\"a.foo\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", @@ -286,7 +286,7 @@ "raw": "\"b.foo\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging2.json b/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging2.json index 116607056a33..89e5abbb0a0a 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging2.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging2.json @@ -165,7 +165,7 @@ "raw": "\"a.foo\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", @@ -326,7 +326,7 @@ "raw": "\"b.foo\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging3.json b/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging3.json index 05cd80f3a438..109ddbc20c18 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging3.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientDeclarationsPatterns_merging3.json @@ -266,7 +266,7 @@ "raw": "\"b.foo\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/ambientShorthand.json b/crates/swc_ecma_parser/tests/tsc/ambientShorthand.json index 55050b576873..bf17e29a8aae 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientShorthand.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientShorthand.json @@ -106,7 +106,7 @@ "raw": "\"jquery\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -146,7 +146,7 @@ "raw": "\"fs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/ambientShorthand_duplicate.json b/crates/swc_ecma_parser/tests/tsc/ambientShorthand_duplicate.json index d6d1941442da..5e22256cdf8e 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientShorthand_duplicate.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientShorthand_duplicate.json @@ -86,7 +86,7 @@ "raw": "\"foo\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/ambientShorthand_merging.json b/crates/swc_ecma_parser/tests/tsc/ambientShorthand_merging.json index dd87ab647b23..873cfe880a53 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientShorthand_merging.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientShorthand_merging.json @@ -172,7 +172,7 @@ "raw": "\"foo\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/ambientShorthand_reExport.json b/crates/swc_ecma_parser/tests/tsc/ambientShorthand_reExport.json index 965740fdc5d6..e4521810b5d2 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientShorthand_reExport.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientShorthand_reExport.json @@ -67,7 +67,7 @@ "raw": "\"jquery\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -87,7 +87,7 @@ "raw": "\"jquery\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -129,7 +129,7 @@ "raw": "\"./reExportX\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -169,7 +169,7 @@ "raw": "\"./reExportAll\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/arraySpreadImportHelpers.json b/crates/swc_ecma_parser/tests/tsc/arraySpreadImportHelpers.json index b028a4b91ce7..2acc7fccc812 100644 --- a/crates/swc_ecma_parser/tests/tsc/arraySpreadImportHelpers.json +++ b/crates/swc_ecma_parser/tests/tsc/arraySpreadImportHelpers.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/asOperator4.json b/crates/swc_ecma_parser/tests/tsc/asOperator4.json index 30c1d9af3309..7614b96c5ba5 100644 --- a/crates/swc_ecma_parser/tests/tsc/asOperator4.json +++ b/crates/swc_ecma_parser/tests/tsc/asOperator4.json @@ -88,7 +88,7 @@ "raw": "'./foo'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/assignmentToVoidZero2.json b/crates/swc_ecma_parser/tests/tsc/assignmentToVoidZero2.json index c779ae366d18..8c393283404f 100644 --- a/crates/swc_ecma_parser/tests/tsc/assignmentToVoidZero2.json +++ b/crates/swc_ecma_parser/tests/tsc/assignmentToVoidZero2.json @@ -693,7 +693,7 @@ "raw": "'./assignmentToVoidZero2'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es2017.json b/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es2017.json index 81b592d7e135..a1f32d38d119 100644 --- a/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es2017.json +++ b/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es2017.json @@ -46,7 +46,7 @@ "raw": "\"missing\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es5.json b/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es5.json index be6c2ad6228e..5729296fd029 100644 --- a/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es5.json +++ b/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es5.json @@ -46,7 +46,7 @@ "raw": "\"missing\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es6.json b/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es6.json index 2699aa45fdd0..8e9ea8a50028 100644 --- a/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es6.json +++ b/crates/swc_ecma_parser/tests/tsc/asyncAwaitIsolatedModules_es6.json @@ -46,7 +46,7 @@ "raw": "\"missing\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/asyncImportedPromise_es5.json b/crates/swc_ecma_parser/tests/tsc/asyncImportedPromise_es5.json index baa78c4bb8d5..e328640e697f 100644 --- a/crates/swc_ecma_parser/tests/tsc/asyncImportedPromise_es5.json +++ b/crates/swc_ecma_parser/tests/tsc/asyncImportedPromise_es5.json @@ -149,7 +149,7 @@ "raw": "\"./task\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/asyncImportedPromise_es6.json b/crates/swc_ecma_parser/tests/tsc/asyncImportedPromise_es6.json index 92998b621e4b..8ad8a92a1c8f 100644 --- a/crates/swc_ecma_parser/tests/tsc/asyncImportedPromise_es6.json +++ b/crates/swc_ecma_parser/tests/tsc/asyncImportedPromise_es6.json @@ -149,7 +149,7 @@ "raw": "\"./task\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/bundlerSyntaxRestrictions.json b/crates/swc_ecma_parser/tests/tsc/bundlerSyntaxRestrictions.json index 988e16c73542..54e4385a880f 100644 --- a/crates/swc_ecma_parser/tests/tsc/bundlerSyntaxRestrictions.json +++ b/crates/swc_ecma_parser/tests/tsc/bundlerSyntaxRestrictions.json @@ -468,7 +468,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -631,7 +631,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", @@ -698,7 +698,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/chained.json b/crates/swc_ecma_parser/tests/tsc/chained.json index f6c737934e22..890f63a77f06 100644 --- a/crates/swc_ecma_parser/tests/tsc/chained.json +++ b/crates/swc_ecma_parser/tests/tsc/chained.json @@ -118,7 +118,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -216,7 +216,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -267,7 +267,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -309,7 +309,7 @@ "raw": "'./b'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -351,7 +351,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -393,7 +393,7 @@ "raw": "'./c'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/chained2.json b/crates/swc_ecma_parser/tests/tsc/chained2.json index d17bf1a5de69..123c0525350c 100644 --- a/crates/swc_ecma_parser/tests/tsc/chained2.json +++ b/crates/swc_ecma_parser/tests/tsc/chained2.json @@ -118,7 +118,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -158,7 +158,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -209,7 +209,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -262,7 +262,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -302,7 +302,7 @@ "raw": "'./b'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -344,7 +344,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -384,7 +384,7 @@ "raw": "'./c'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/checkExportsObjectAssignProperty.json b/crates/swc_ecma_parser/tests/tsc/checkExportsObjectAssignProperty.json index 5dfe3b5a23d7..e0caa664c1de 100644 --- a/crates/swc_ecma_parser/tests/tsc/checkExportsObjectAssignProperty.json +++ b/crates/swc_ecma_parser/tests/tsc/checkExportsObjectAssignProperty.json @@ -1903,7 +1903,7 @@ "raw": "\"./\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/checkExportsObjectAssignPrototypeProperty.json b/crates/swc_ecma_parser/tests/tsc/checkExportsObjectAssignPrototypeProperty.json index f975321a465e..6aa7cb043b13 100644 --- a/crates/swc_ecma_parser/tests/tsc/checkExportsObjectAssignPrototypeProperty.json +++ b/crates/swc_ecma_parser/tests/tsc/checkExportsObjectAssignPrototypeProperty.json @@ -1230,7 +1230,7 @@ "raw": "\"./\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/circular1.json b/crates/swc_ecma_parser/tests/tsc/circular1.json index 3482a7b3ee1e..a51246aa0ae4 100644 --- a/crates/swc_ecma_parser/tests/tsc/circular1.json +++ b/crates/swc_ecma_parser/tests/tsc/circular1.json @@ -46,7 +46,7 @@ "raw": "'./b'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -88,7 +88,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/circular2.json b/crates/swc_ecma_parser/tests/tsc/circular2.json index b1a9842e902f..85ee10fa5a54 100644 --- a/crates/swc_ecma_parser/tests/tsc/circular2.json +++ b/crates/swc_ecma_parser/tests/tsc/circular2.json @@ -46,7 +46,7 @@ "raw": "'./b'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -135,7 +135,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/circular3.json b/crates/swc_ecma_parser/tests/tsc/circular3.json index bff8e0b64a6b..ff3c8a5dee08 100644 --- a/crates/swc_ecma_parser/tests/tsc/circular3.json +++ b/crates/swc_ecma_parser/tests/tsc/circular3.json @@ -46,7 +46,7 @@ "raw": "'./b'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -88,7 +88,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -130,7 +130,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -172,7 +172,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/circular4.json b/crates/swc_ecma_parser/tests/tsc/circular4.json index 91aa88c9e576..f9ba2cecff80 100644 --- a/crates/swc_ecma_parser/tests/tsc/circular4.json +++ b/crates/swc_ecma_parser/tests/tsc/circular4.json @@ -46,7 +46,7 @@ "raw": "'./b'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -237,7 +237,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/conflictingCommonJSES2015Exports.json b/crates/swc_ecma_parser/tests/tsc/conflictingCommonJSES2015Exports.json index 3f7aaa693973..7285b15682b8 100644 --- a/crates/swc_ecma_parser/tests/tsc/conflictingCommonJSES2015Exports.json +++ b/crates/swc_ecma_parser/tests/tsc/conflictingCommonJSES2015Exports.json @@ -233,7 +233,7 @@ "raw": "'./bug24934'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/constAssertionOnEnum.json b/crates/swc_ecma_parser/tests/tsc/constAssertionOnEnum.json index 53e3cf578357..5eafbac998ac 100644 --- a/crates/swc_ecma_parser/tests/tsc/constAssertionOnEnum.json +++ b/crates/swc_ecma_parser/tests/tsc/constAssertionOnEnum.json @@ -114,7 +114,7 @@ "raw": "'./enum'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsEnumDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/declarationFileForJsonImport.json b/crates/swc_ecma_parser/tests/tsc/declarationFileForJsonImport.json index 2a8d5d5d62f7..ca5f989ef9b9 100644 --- a/crates/swc_ecma_parser/tests/tsc/declarationFileForJsonImport.json +++ b/crates/swc_ecma_parser/tests/tsc/declarationFileForJsonImport.json @@ -44,7 +44,7 @@ "raw": "\"./data.json\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression01.json b/crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression01.json index 2eef9e01248c..1eb177415651 100644 --- a/crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression01.json +++ b/crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression01.json @@ -205,7 +205,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression02.json b/crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression02.json index a74953f20f6e..0647b8e318e0 100644 --- a/crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression02.json +++ b/crates/swc_ecma_parser/tests/tsc/defaultExportInAwaitExpression02.json @@ -205,7 +205,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge01.json b/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge01.json index 6f0e41629119..42f63791a5b7 100644 --- a/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge01.json +++ b/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge01.json @@ -393,7 +393,7 @@ "raw": "\"m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge02.json b/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge02.json index 5e77f2acdd83..878d8d390ace 100644 --- a/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge02.json +++ b/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge02.json @@ -266,7 +266,7 @@ "raw": "\"m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge03.json b/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge03.json index 7d58e9861be9..e1361502ddcd 100644 --- a/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge03.json +++ b/crates/swc_ecma_parser/tests/tsc/defaultExportsCannotMerge03.json @@ -250,7 +250,7 @@ "raw": "\"m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/enumTagImported.json b/crates/swc_ecma_parser/tests/tsc/enumTagImported.json index 69a110aa528b..bf8dd757472a 100644 --- a/crates/swc_ecma_parser/tests/tsc/enumTagImported.json +++ b/crates/swc_ecma_parser/tests/tsc/enumTagImported.json @@ -130,7 +130,7 @@ "raw": "\"./mod1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/enums.json b/crates/swc_ecma_parser/tests/tsc/enums.json index 787c24a1af34..80ba755d7fb4 100644 --- a/crates/swc_ecma_parser/tests/tsc/enums.json +++ b/crates/swc_ecma_parser/tests/tsc/enums.json @@ -175,7 +175,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -208,7 +208,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -270,7 +270,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -558,7 +558,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -600,7 +600,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -642,7 +642,7 @@ "raw": "'./b'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target9.json b/crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target9.json index 8023ab937afe..129b75a6c02c 100644 --- a/crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target9.json +++ b/crates/swc_ecma_parser/tests/tsc/es6modulekindWithES5Target9.json @@ -44,7 +44,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -86,7 +86,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -126,7 +126,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -159,7 +159,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -192,7 +192,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -225,7 +225,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -245,7 +245,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -287,7 +287,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", diff --git a/crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target9.json b/crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target9.json index 8023ab937afe..129b75a6c02c 100644 --- a/crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target9.json +++ b/crates/swc_ecma_parser/tests/tsc/esnextmodulekindWithES5Target9.json @@ -44,7 +44,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -86,7 +86,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -126,7 +126,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -159,7 +159,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -192,7 +192,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -225,7 +225,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -245,7 +245,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -287,7 +287,7 @@ "raw": "\"mod\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", diff --git a/crates/swc_ecma_parser/tests/tsc/expandoOnAlias.json b/crates/swc_ecma_parser/tests/tsc/expandoOnAlias.json index 765e40604a2c..753d95e91465 100644 --- a/crates/swc_ecma_parser/tests/tsc/expandoOnAlias.json +++ b/crates/swc_ecma_parser/tests/tsc/expandoOnAlias.json @@ -173,7 +173,7 @@ "raw": "\"./vue\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.json b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.json index 9fd1304d2dc1..6bb882084eb5 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.json @@ -85,7 +85,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.json b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.json index 5d3619570cac..33db404b6e48 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.json @@ -85,7 +85,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es5-amd.json b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es5-amd.json index 9fd1304d2dc1..6bb882084eb5 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es5-amd.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es5-amd.json @@ -85,7 +85,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es5.json b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es5.json index 183a13089bbe..42d4e80dc359 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es5.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es5.json @@ -85,7 +85,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace1.json b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace1.json index f41657110528..d6024da30c79 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace1.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace1.json @@ -144,7 +144,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -256,7 +256,7 @@ "raw": "'./1'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace2.json b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace2.json index 4ceda6c110b8..5c46b4c038e3 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace2.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace2.json @@ -144,7 +144,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -256,7 +256,7 @@ "raw": "'./1'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace3.json b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace3.json index f1198b672bb7..6d81e07f6f25 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace3.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace3.json @@ -144,7 +144,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -416,7 +416,7 @@ "raw": "'./1'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace4.json b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace4.json index 09b9df205da3..4d5c270d853a 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace4.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace4.json @@ -144,7 +144,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -184,7 +184,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", @@ -242,7 +242,7 @@ "raw": "'./1'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -282,7 +282,7 @@ "raw": "'./11'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_exportAssignment.json b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_exportAssignment.json index d0a57bab2304..f9776985f103 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_exportAssignment.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_exportAssignment.json @@ -61,7 +61,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_missingEmitHelpers.json b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_missingEmitHelpers.json index 9592a6f04363..37bc0536c7f1 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_missingEmitHelpers.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_missingEmitHelpers.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -56,7 +56,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_nonExistent.json b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_nonExistent.json index 62b01797a8a2..cd4c430bc717 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_nonExistent.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAsNamespace_nonExistent.json @@ -44,7 +44,7 @@ "raw": "'./nonexistent'" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportAssignmentOfExportNamespaceWithDefault.json b/crates/swc_ecma_parser/tests/tsc/exportAssignmentOfExportNamespaceWithDefault.json index 54e87439b5c3..85f5582830b6 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportAssignmentOfExportNamespaceWithDefault.json +++ b/crates/swc_ecma_parser/tests/tsc/exportAssignmentOfExportNamespaceWithDefault.json @@ -44,7 +44,7 @@ "raw": "\"a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -284,7 +284,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ] } @@ -378,7 +378,7 @@ "raw": "\"b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsExportAssignment", diff --git a/crates/swc_ecma_parser/tests/tsc/exportBinding.json b/crates/swc_ecma_parser/tests/tsc/exportBinding.json index 37fb16546ca0..574c47ffa447 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportBinding.json +++ b/crates/swc_ecma_parser/tests/tsc/exportBinding.json @@ -37,7 +37,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -79,7 +79,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", @@ -181,7 +181,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -240,7 +240,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -282,7 +282,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", diff --git a/crates/swc_ecma_parser/tests/tsc/exportDeclaration.json b/crates/swc_ecma_parser/tests/tsc/exportDeclaration.json index 7c93ee45913f..0beb81cdaf3f 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportDeclaration.json +++ b/crates/swc_ecma_parser/tests/tsc/exportDeclaration.json @@ -63,7 +63,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -105,7 +105,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier-isolatedModules.json b/crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier-isolatedModules.json index 85c8760c9c68..4e6f118bd2b2 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier-isolatedModules.json +++ b/crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier-isolatedModules.json @@ -83,7 +83,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier.json b/crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier.json index f964cdd9fc63..dc96c562bf98 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier.json +++ b/crates/swc_ecma_parser/tests/tsc/exportDeclaration_moduleSpecifier.json @@ -80,7 +80,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -122,7 +122,7 @@ "raw": "'./b'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportDeclaration_value.json b/crates/swc_ecma_parser/tests/tsc/exportDeclaration_value.json index a599eb584687..c2779fb1a7d1 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportDeclaration_value.json +++ b/crates/swc_ecma_parser/tests/tsc/exportDeclaration_value.json @@ -78,7 +78,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -169,7 +169,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace1.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace1.json index d72df8d7aac3..934d73e09489 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace1.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace1.json @@ -80,7 +80,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -100,7 +100,7 @@ "raw": "'./b'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -142,7 +142,7 @@ "raw": "'./c'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace10.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace10.json index 6b2dc258fbd6..705617805316 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace10.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace10.json @@ -78,7 +78,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -120,7 +120,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace2.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace2.json index 56c26379070e..cba32fff1c1d 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace2.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace2.json @@ -78,7 +78,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -120,7 +120,7 @@ "raw": "'./b'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -153,7 +153,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -195,7 +195,7 @@ "raw": "'./c'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace3.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace3.json index c8948f2e57a1..e4443971ec35 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace3.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace3.json @@ -80,7 +80,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -120,7 +120,7 @@ "raw": "'./b'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -162,7 +162,7 @@ "raw": "'./c'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace4.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace4.json index f2dc6d80bf62..d8286de3b3c3 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace4.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace4.json @@ -58,7 +58,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -98,7 +98,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -140,7 +140,7 @@ "raw": "'./b'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -200,7 +200,7 @@ "raw": "'./c'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace5.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace5.json index b591c273f0a7..9449c2dbbd7d 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace5.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace5.json @@ -126,7 +126,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -168,7 +168,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -259,7 +259,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -513,7 +513,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -533,7 +533,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -615,7 +615,7 @@ "raw": "\"./d\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace6.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace6.json index 69243c820e84..1f29e16602cb 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace6.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace6.json @@ -92,7 +92,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -112,7 +112,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -174,7 +174,7 @@ "raw": "\"./c\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace7.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace7.json index 62e69b5efe49..9e25d570b29f 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace7.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace7.json @@ -126,7 +126,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -242,7 +242,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -496,7 +496,7 @@ "raw": "\"./b\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -578,7 +578,7 @@ "raw": "\"./d\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace8.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace8.json index 3752222238d7..4e24efa61848 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace8.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace8.json @@ -160,7 +160,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -180,7 +180,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -262,7 +262,7 @@ "raw": "\"./c\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNamespace9.json b/crates/swc_ecma_parser/tests/tsc/exportNamespace9.json index 0f95a6572713..fc0d20e62a65 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNamespace9.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNamespace9.json @@ -61,7 +61,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -103,7 +103,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -178,7 +178,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -220,7 +220,7 @@ "raw": "\"./c\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -347,7 +347,7 @@ "raw": "\"./e\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -367,7 +367,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -409,7 +409,7 @@ "raw": "\"./f\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces.json b/crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces.json index d8dbf52c3784..4672ff5ece1d 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces.json @@ -385,7 +385,7 @@ "raw": "'./mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces2.json b/crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces2.json index 86b70039ae74..412ff01166bf 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces2.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNestedNamespaces2.json @@ -476,7 +476,7 @@ "raw": "'./mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportNonLocalDeclarations.json b/crates/swc_ecma_parser/tests/tsc/exportNonLocalDeclarations.json index e99154c552de..784cbed95eec 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportNonLocalDeclarations.json +++ b/crates/swc_ecma_parser/tests/tsc/exportNonLocalDeclarations.json @@ -37,7 +37,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -70,7 +70,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportSpecifiers.json b/crates/swc_ecma_parser/tests/tsc/exportSpecifiers.json index cdf71c052f3a..9c415e3645d3 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportSpecifiers.json +++ b/crates/swc_ecma_parser/tests/tsc/exportSpecifiers.json @@ -126,7 +126,7 @@ "raw": "\"./exports.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -375,7 +375,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -408,7 +408,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -441,7 +441,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -483,7 +483,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -525,7 +525,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -567,7 +567,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportSpecifiers_js.json b/crates/swc_ecma_parser/tests/tsc/exportSpecifiers_js.json index 9067c7ed4a94..3dc04cfeecb4 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportSpecifiers_js.json +++ b/crates/swc_ecma_parser/tests/tsc/exportSpecifiers_js.json @@ -79,7 +79,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportSpellingSuggestion.json b/crates/swc_ecma_parser/tests/tsc/exportSpellingSuggestion.json index c33eaf53c7ae..b949b98d8ffa 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportSpellingSuggestion.json +++ b/crates/swc_ecma_parser/tests/tsc/exportSpellingSuggestion.json @@ -223,7 +223,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportStar-amd.json b/crates/swc_ecma_parser/tests/tsc/exportStar-amd.json index 88b61f97b0c0..b3785a971a85 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportStar-amd.json +++ b/crates/swc_ecma_parser/tests/tsc/exportStar-amd.json @@ -363,7 +363,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -383,7 +383,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -403,7 +403,7 @@ "raw": "\"./t2\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -423,7 +423,7 @@ "raw": "\"./t3\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -543,7 +543,7 @@ "raw": "\"./t4\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportStar.json b/crates/swc_ecma_parser/tests/tsc/exportStar.json index 20086d50730d..9588ca18ad44 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportStar.json +++ b/crates/swc_ecma_parser/tests/tsc/exportStar.json @@ -363,7 +363,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -383,7 +383,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -403,7 +403,7 @@ "raw": "\"./t2\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -423,7 +423,7 @@ "raw": "\"./t3\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -543,7 +543,7 @@ "raw": "\"./t4\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/exportTypeMergedWithExportStarAsNamespace.json b/crates/swc_ecma_parser/tests/tsc/exportTypeMergedWithExportStarAsNamespace.json index 436b761c6859..234d54f7a06a 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportTypeMergedWithExportStarAsNamespace.json +++ b/crates/swc_ecma_parser/tests/tsc/exportTypeMergedWithExportStarAsNamespace.json @@ -46,7 +46,7 @@ "raw": "\"./prelude\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -709,7 +709,7 @@ "raw": "\"./Something\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -749,7 +749,7 @@ "raw": "\"./Something\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportedEnumTypeAndValue.json b/crates/swc_ecma_parser/tests/tsc/exportedEnumTypeAndValue.json index bf27d95ecbba..c4c0ad511ab5 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportedEnumTypeAndValue.json +++ b/crates/swc_ecma_parser/tests/tsc/exportedEnumTypeAndValue.json @@ -150,7 +150,7 @@ "raw": "\"./def\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports1-amd.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports1-amd.json index 114b44b42264..20f9287e0923 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports1-amd.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports1-amd.json @@ -718,7 +718,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -940,7 +940,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1162,7 +1162,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1375,7 +1375,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports1-es6.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports1-es6.json index 58ff1a5a4be7..c8373e71d78c 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports1-es6.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports1-es6.json @@ -718,7 +718,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -940,7 +940,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1162,7 +1162,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1375,7 +1375,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports1.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports1.json index d3f90ace61a8..18f0bb153caf 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports1.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports1.json @@ -718,7 +718,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -940,7 +940,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1162,7 +1162,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1375,7 +1375,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports2-amd.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports2-amd.json index fb0db4720260..53b0f4ebfafd 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports2-amd.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports2-amd.json @@ -184,7 +184,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -246,7 +246,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -317,7 +317,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports2-es6.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports2-es6.json index 038a3d542ef5..eca4c5c9a427 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports2-es6.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports2-es6.json @@ -184,7 +184,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -246,7 +246,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -317,7 +317,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports2.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports2.json index 7d9da33271cf..3fabe1d5554f 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports2.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports2.json @@ -184,7 +184,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -246,7 +246,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -317,7 +317,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-amd.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-amd.json index dd934d907fee..6f866280243c 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-amd.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-amd.json @@ -880,7 +880,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1192,7 +1192,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1504,7 +1504,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1717,7 +1717,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-es6.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-es6.json index f833d021f0b3..e63749c22d72 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-es6.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3-es6.json @@ -880,7 +880,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1192,7 +1192,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1504,7 +1504,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1717,7 +1717,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3.json index ffa166469f48..40c8d26a330b 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports3.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports3.json @@ -880,7 +880,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1192,7 +1192,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1504,7 +1504,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1717,7 +1717,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports4-amd.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports4-amd.json index ccba8b003a40..e07d68697d56 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports4-amd.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports4-amd.json @@ -136,7 +136,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -194,7 +194,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -281,7 +281,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -357,7 +357,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -480,7 +480,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -537,7 +537,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", @@ -651,7 +651,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -709,7 +709,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -796,7 +796,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -872,7 +872,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -995,7 +995,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -1204,7 +1204,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports4-es6.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports4-es6.json index e7b8f5e51ceb..4db50e3d6f8f 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports4-es6.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports4-es6.json @@ -136,7 +136,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -194,7 +194,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -281,7 +281,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -357,7 +357,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -480,7 +480,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -537,7 +537,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", @@ -651,7 +651,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -709,7 +709,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -796,7 +796,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -872,7 +872,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -995,7 +995,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -1204,7 +1204,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImports4.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImports4.json index e7b8f5e51ceb..4db50e3d6f8f 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImports4.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImports4.json @@ -136,7 +136,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -194,7 +194,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -281,7 +281,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -357,7 +357,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -480,7 +480,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -537,7 +537,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", @@ -651,7 +651,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -709,7 +709,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -796,7 +796,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -872,7 +872,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -995,7 +995,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -1204,7 +1204,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithContextualKeywordNames02.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithContextualKeywordNames02.json index 718f727b0ebb..620ca2d0aafa 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithContextualKeywordNames02.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithContextualKeywordNames02.json @@ -108,7 +108,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -148,7 +148,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -319,7 +319,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -361,7 +361,7 @@ "raw": "\"./t1\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores2.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores2.json index 9aa0e835c6cf..cd70754d391a 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores2.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores2.json @@ -175,7 +175,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores3.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores3.json index 676e8211eb60..cf583016d4e1 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores3.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores3.json @@ -200,7 +200,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores4.json b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores4.json index 2e7d346c0e9b..6c0fe14546be 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores4.json +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores4.json @@ -916,7 +916,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/extendsTagEmit.json b/crates/swc_ecma_parser/tests/tsc/extendsTagEmit.json index 5636a3103070..5bf3f3896a45 100644 --- a/crates/swc_ecma_parser/tests/tsc/extendsTagEmit.json +++ b/crates/swc_ecma_parser/tests/tsc/extendsTagEmit.json @@ -80,7 +80,7 @@ "raw": "'./super'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/extensionLoadingPriority.json b/crates/swc_ecma_parser/tests/tsc/extensionLoadingPriority.json index 212942269a45..2707fc127822 100644 --- a/crates/swc_ecma_parser/tests/tsc/extensionLoadingPriority.json +++ b/crates/swc_ecma_parser/tests/tsc/extensionLoadingPriority.json @@ -116,7 +116,7 @@ "raw": "\"./a.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -156,7 +156,7 @@ "raw": "\"./dir\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/filterNamespace_import.json b/crates/swc_ecma_parser/tests/tsc/filterNamespace_import.json index d09559c76f90..9d52e0f87d1a 100644 --- a/crates/swc_ecma_parser/tests/tsc/filterNamespace_import.json +++ b/crates/swc_ecma_parser/tests/tsc/filterNamespace_import.json @@ -331,7 +331,7 @@ "raw": "'./ns'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/generic.json b/crates/swc_ecma_parser/tests/tsc/generic.json index 2f2f1a503c34..04484ac9ea08 100644 --- a/crates/swc_ecma_parser/tests/tsc/generic.json +++ b/crates/swc_ecma_parser/tests/tsc/generic.json @@ -168,7 +168,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -210,7 +210,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -252,7 +252,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/globalAugmentationModuleResolution.json b/crates/swc_ecma_parser/tests/tsc/globalAugmentationModuleResolution.json index b033f72ff8cf..c8738b090515 100644 --- a/crates/swc_ecma_parser/tests/tsc/globalAugmentationModuleResolution.json +++ b/crates/swc_ecma_parser/tests/tsc/globalAugmentationModuleResolution.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/globalThisGlobalExportAsGlobal.json b/crates/swc_ecma_parser/tests/tsc/globalThisGlobalExportAsGlobal.json index c43e20d15e3e..4279224feb5a 100644 --- a/crates/swc_ecma_parser/tests/tsc/globalThisGlobalExportAsGlobal.json +++ b/crates/swc_ecma_parser/tests/tsc/globalThisGlobalExportAsGlobal.json @@ -73,7 +73,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ] } diff --git a/crates/swc_ecma_parser/tests/tsc/implementsClause.json b/crates/swc_ecma_parser/tests/tsc/implementsClause.json index 453cc3905584..272903175187 100644 --- a/crates/swc_ecma_parser/tests/tsc/implementsClause.json +++ b/crates/swc_ecma_parser/tests/tsc/implementsClause.json @@ -82,7 +82,7 @@ "raw": "'./types'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -115,7 +115,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -155,7 +155,7 @@ "raw": "'./types'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -195,7 +195,7 @@ "raw": "'./ns'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/importAliasModuleExports.json b/crates/swc_ecma_parser/tests/tsc/importAliasModuleExports.json index c2006682fd5d..ecd2f83776dd 100644 --- a/crates/swc_ecma_parser/tests/tsc/importAliasModuleExports.json +++ b/crates/swc_ecma_parser/tests/tsc/importAliasModuleExports.json @@ -191,7 +191,7 @@ "raw": "'./mod1'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/importAssertion2.json b/crates/swc_ecma_parser/tests/tsc/importAssertion2.json index 97877b7bdfb7..f88ae0620d90 100644 --- a/crates/swc_ecma_parser/tests/tsc/importAssertion2.json +++ b/crates/swc_ecma_parser/tests/tsc/importAssertion2.json @@ -125,7 +125,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 187, @@ -219,7 +219,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 238, @@ -271,7 +271,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 282, @@ -343,7 +343,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 332, @@ -437,7 +437,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 403, @@ -525,7 +525,7 @@ "raw": "'./0'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 450, diff --git a/crates/swc_ecma_parser/tests/tsc/importAssertion3.json b/crates/swc_ecma_parser/tests/tsc/importAssertion3.json index 901ffc696621..422693cbf068 100644 --- a/crates/swc_ecma_parser/tests/tsc/importAssertion3.json +++ b/crates/swc_ecma_parser/tests/tsc/importAssertion3.json @@ -63,7 +63,7 @@ "raw": "'./0'" }, "typeOnly": true, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 165, @@ -137,7 +137,7 @@ "raw": "'./0'" }, "typeOnly": true, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 218, @@ -211,7 +211,7 @@ "raw": "'./0'" }, "typeOnly": true, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 292, @@ -283,7 +283,7 @@ "raw": "'./0'" }, "typeOnly": true, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 348, diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionCheckReturntype1.json b/crates/swc_ecma_parser/tests/tsc/importCallExpressionCheckReturntype1.json index 26ca89753f6c..38c2993ae666 100644 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionCheckReturntype1.json +++ b/crates/swc_ecma_parser/tests/tsc/importCallExpressionCheckReturntype1.json @@ -112,7 +112,7 @@ "raw": "\"./defaultPath\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -152,7 +152,7 @@ "raw": "\"./anotherModule\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionDeclarationEmit3.json b/crates/swc_ecma_parser/tests/tsc/importCallExpressionDeclarationEmit3.json index 031c40a255ce..eee5ba6db58f 100644 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionDeclarationEmit3.json +++ b/crates/swc_ecma_parser/tests/tsc/importCallExpressionDeclarationEmit3.json @@ -147,7 +147,7 @@ "raw": "\"./0\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionReturnPromiseOfAny.json b/crates/swc_ecma_parser/tests/tsc/importCallExpressionReturnPromiseOfAny.json index 93ba0ab21b24..8cbefb326a31 100644 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionReturnPromiseOfAny.json +++ b/crates/swc_ecma_parser/tests/tsc/importCallExpressionReturnPromiseOfAny.json @@ -78,7 +78,7 @@ "raw": "\"./defaultPath\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "FunctionDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/importClause_default.json b/crates/swc_ecma_parser/tests/tsc/importClause_default.json index c2712e37953f..35f902e64959 100644 --- a/crates/swc_ecma_parser/tests/tsc/importClause_default.json +++ b/crates/swc_ecma_parser/tests/tsc/importClause_default.json @@ -123,7 +123,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/importElisionConstEnumMerge1.json b/crates/swc_ecma_parser/tests/tsc/importElisionConstEnumMerge1.json index 5ce9538806fd..8012db1704d0 100644 --- a/crates/swc_ecma_parser/tests/tsc/importElisionConstEnumMerge1.json +++ b/crates/swc_ecma_parser/tests/tsc/importElisionConstEnumMerge1.json @@ -104,7 +104,7 @@ "raw": "\"./enum\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", @@ -204,7 +204,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -246,7 +246,7 @@ "raw": "\"./merge\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/importEmptyFromModuleNotExisted.json b/crates/swc_ecma_parser/tests/tsc/importEmptyFromModuleNotExisted.json index 8cf01e8ec92f..a918d9c0aa52 100644 --- a/crates/swc_ecma_parser/tests/tsc/importEmptyFromModuleNotExisted.json +++ b/crates/swc_ecma_parser/tests/tsc/importEmptyFromModuleNotExisted.json @@ -25,7 +25,7 @@ "raw": "'module-not-existed'" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/importEquals2.json b/crates/swc_ecma_parser/tests/tsc/importEquals2.json index 9e74cb332a3e..fbf7f09aaac7 100644 --- a/crates/swc_ecma_parser/tests/tsc/importEquals2.json +++ b/crates/swc_ecma_parser/tests/tsc/importEquals2.json @@ -63,7 +63,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -103,7 +103,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsExportAssignment", diff --git a/crates/swc_ecma_parser/tests/tsc/importFromDot.json b/crates/swc_ecma_parser/tests/tsc/importFromDot.json index 5575b8a87688..3627ebbedf13 100644 --- a/crates/swc_ecma_parser/tests/tsc/importFromDot.json +++ b/crates/swc_ecma_parser/tests/tsc/importFromDot.json @@ -166,7 +166,7 @@ "raw": "\".\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/importSpecifiers_js.json b/crates/swc_ecma_parser/tests/tsc/importSpecifiers_js.json index e56b8e15f0a8..d3476feac227 100644 --- a/crates/swc_ecma_parser/tests/tsc/importSpecifiers_js.json +++ b/crates/swc_ecma_parser/tests/tsc/importSpecifiers_js.json @@ -84,7 +84,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeAmdBundleRewrite.json b/crates/swc_ecma_parser/tests/tsc/importTypeAmdBundleRewrite.json index ce7e0594add1..6ad3fd4d4a2a 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeAmdBundleRewrite.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeAmdBundleRewrite.json @@ -227,7 +227,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -388,7 +388,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeGenericTypes.json b/crates/swc_ecma_parser/tests/tsc/importTypeGenericTypes.json index ba45faadb699..175965ad7fef 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeGenericTypes.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeGenericTypes.json @@ -1000,7 +1000,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeLocal.json b/crates/swc_ecma_parser/tests/tsc/importTypeLocal.json index ae5db9321f83..73fdb5d3236a 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeLocal.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeLocal.json @@ -663,7 +663,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/importTypeLocalMissing.json b/crates/swc_ecma_parser/tests/tsc/importTypeLocalMissing.json index 891da4c392b4..aca5a1d64c69 100644 --- a/crates/swc_ecma_parser/tests/tsc/importTypeLocalMissing.json +++ b/crates/swc_ecma_parser/tests/tsc/importTypeLocalMissing.json @@ -663,7 +663,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/importingExportingTypes.json b/crates/swc_ecma_parser/tests/tsc/importingExportingTypes.json index 9bc0acf8ff20..01fd01c28e7c 100644 --- a/crates/swc_ecma_parser/tests/tsc/importingExportingTypes.json +++ b/crates/swc_ecma_parser/tests/tsc/importingExportingTypes.json @@ -424,7 +424,7 @@ "raw": "\"fs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -457,7 +457,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -499,7 +499,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -532,7 +532,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/importsImplicitlyReadonly.json b/crates/swc_ecma_parser/tests/tsc/importsImplicitlyReadonly.json index c5692466f0c3..308836b063c4 100644 --- a/crates/swc_ecma_parser/tests/tsc/importsImplicitlyReadonly.json +++ b/crates/swc_ecma_parser/tests/tsc/importsImplicitlyReadonly.json @@ -129,7 +129,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -191,7 +191,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -231,7 +231,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/importsNotUsedAsValues_error.json b/crates/swc_ecma_parser/tests/tsc/importsNotUsedAsValues_error.json index 3b27730beaaa..d77dbb55fc6d 100644 --- a/crates/swc_ecma_parser/tests/tsc/importsNotUsedAsValues_error.json +++ b/crates/swc_ecma_parser/tests/tsc/importsNotUsedAsValues_error.json @@ -229,7 +229,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -478,7 +478,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -742,7 +742,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -978,7 +978,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1020,7 +1020,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1071,7 +1071,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -1407,7 +1407,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/inferringClassStaticMembersFromAssignments.json b/crates/swc_ecma_parser/tests/tsc/inferringClassStaticMembersFromAssignments.json index e8cc18f75a8c..720540910998 100644 --- a/crates/swc_ecma_parser/tests/tsc/inferringClassStaticMembersFromAssignments.json +++ b/crates/swc_ecma_parser/tests/tsc/inferringClassStaticMembersFromAssignments.json @@ -844,7 +844,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/intersectionsAndEmptyObjects.json b/crates/swc_ecma_parser/tests/tsc/intersectionsAndEmptyObjects.json index 2bb291cfd766..059c3d494e96 100644 --- a/crates/swc_ecma_parser/tests/tsc/intersectionsAndEmptyObjects.json +++ b/crates/swc_ecma_parser/tests/tsc/intersectionsAndEmptyObjects.json @@ -4280,7 +4280,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassAccessor.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassAccessor.json index a3eca3fdcab1..f4924300d913 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassAccessor.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassAccessor.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", @@ -442,7 +442,7 @@ "raw": "\"./base.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassStatic2.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassStatic2.json index 096bfa9f912e..f01704569414 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassStatic2.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClassStatic2.json @@ -209,7 +209,7 @@ "raw": "\"./Foo.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClasses.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClasses.json index 19bc90e57101..66c354823d2b 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClasses.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsClasses.json @@ -1471,7 +1471,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -1539,7 +1539,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -1615,7 +1615,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1657,7 +1657,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsDefault.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsDefault.json index fc2f5d56e9e0..bf1478c3fcde 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsDefault.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsDefault.json @@ -174,7 +174,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", @@ -352,7 +352,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -392,7 +392,7 @@ "raw": "\"./index3\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsDefaultsErr.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsDefaultsErr.json index 80b3d623f350..dcedf96ee641 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsDefaultsErr.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsDefaultsErr.json @@ -250,7 +250,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsEnums.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsEnums.json index d74f22934caa..ff26cc80bcee 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsEnums.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsEnums.json @@ -136,7 +136,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsEnumDeclaration", @@ -199,7 +199,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -270,7 +270,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -312,7 +312,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsExportForms.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsExportForms.json index 007d513ab5bd..3561ae95f35a 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsExportForms.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsExportForms.json @@ -100,7 +100,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -120,7 +120,7 @@ "raw": "\"./func\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportAllDeclaration", @@ -140,7 +140,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -182,7 +182,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -215,7 +215,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -255,7 +255,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", @@ -313,7 +313,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -346,7 +346,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -386,7 +386,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -428,7 +428,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -979,7 +979,7 @@ "raw": "\"./cjs4\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1000,7 +1000,7 @@ "raw": "\"./cjs3\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1021,7 +1021,7 @@ "raw": "\"./cjs2\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1042,7 +1042,7 @@ "raw": "\"./cjs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1063,7 +1063,7 @@ "raw": "\"./bol\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1084,7 +1084,7 @@ "raw": "\"./ban\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1105,7 +1105,7 @@ "raw": "\"./bat\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1126,7 +1126,7 @@ "raw": "\"./baz\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1147,7 +1147,7 @@ "raw": "\"./bar\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1168,7 +1168,7 @@ "raw": "\"./bar2\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsExportSpecifierNonlocal.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsExportSpecifierNonlocal.json index 79ebae05096f..b01c23b8e1f0 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsExportSpecifierNonlocal.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsExportSpecifierNonlocal.json @@ -143,7 +143,7 @@ "raw": "\"./source\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctionLikeClasses.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctionLikeClasses.json index d7b8757ab97f..59d25204b187 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctionLikeClasses.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctionLikeClasses.json @@ -354,7 +354,7 @@ "raw": "\"./source\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctionLikeClasses2.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctionLikeClasses2.json index 51ec21ce8b9d..7d5620a79f92 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctionLikeClasses2.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctionLikeClasses2.json @@ -2080,7 +2080,7 @@ "raw": "\"./source\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctions.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctions.json index 105391a77f1c..11de61abca93 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctions.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsFunctions.json @@ -791,7 +791,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "FunctionDeclaration", @@ -992,7 +992,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -1076,7 +1076,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1118,7 +1118,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsImportAliasExposedWithinNamespace.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsImportAliasExposedWithinNamespace.json index 72fab9846b2e..eba4da7d8ac4 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsImportAliasExposedWithinNamespace.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsImportAliasExposedWithinNamespace.json @@ -78,7 +78,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -120,7 +120,7 @@ "raw": "'./file.js'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -389,7 +389,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsImportNamespacedType.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsImportNamespacedType.json index 8d61e764a2c9..f86b6b2f8c2e 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsImportNamespacedType.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsImportNamespacedType.json @@ -46,7 +46,7 @@ "raw": "'./mod1'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsInterfaces.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsInterfaces.json index 12d6f3664d01..12c01e194161 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsInterfaces.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsInterfaces.json @@ -1463,7 +1463,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsInterfaceDeclaration", @@ -1535,7 +1535,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -1615,7 +1615,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1657,7 +1657,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsMultipleExportFromMerge.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsMultipleExportFromMerge.json index 91fd82c1f165..69db97c91a2b 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsMultipleExportFromMerge.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsMultipleExportFromMerge.json @@ -236,7 +236,7 @@ "raw": "\"./items\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -278,7 +278,7 @@ "raw": "\"./items\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -340,7 +340,7 @@ "raw": "\"./items\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -402,7 +402,7 @@ "raw": "\"./items\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -453,7 +453,7 @@ "raw": "\"./two\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -504,7 +504,7 @@ "raw": "\"./two\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -546,7 +546,7 @@ "raw": "\"./two\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -597,7 +597,7 @@ "raw": "\"./items\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsReexportAliases.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsReexportAliases.json index 809faec69207..62e09c3502ea 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsReexportAliases.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsReexportAliases.json @@ -88,7 +88,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -199,7 +199,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsReexportAliasesEsModuleInterop.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsReexportAliasesEsModuleInterop.json index e5f600e37a43..638fe0861c60 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsReexportAliasesEsModuleInterop.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsReexportAliasesEsModuleInterop.json @@ -136,7 +136,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -247,7 +247,7 @@ "raw": "\"./cls\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsTypeAliases.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsTypeAliases.json index d148c08a245a..6fca806c3681 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsTypeAliases.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsTypeAliases.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "FunctionDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsTypeReferences4.json b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsTypeReferences4.json index c484d1b479ac..20fcf0d5f467 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsDeclarationsTypeReferences4.json +++ b/crates/swc_ecma_parser/tests/tsc/jsDeclarationsTypeReferences4.json @@ -355,7 +355,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ] } diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocAugments_qualifiedName.json b/crates/swc_ecma_parser/tests/tsc/jsdocAugments_qualifiedName.json index 932b2bfdc959..ce37529a33d8 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocAugments_qualifiedName.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocAugments_qualifiedName.json @@ -78,7 +78,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag1.json b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag1.json index 40be3bfa0229..c7e8fc032744 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag1.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag1.json @@ -84,7 +84,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag2.json b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag2.json index cad59c3464af..20f83f5c597e 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag2.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag2.json @@ -80,7 +80,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag3.json b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag3.json index 56055da20478..c5e4b957872d 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag3.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag3.json @@ -84,7 +84,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag4.json b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag4.json index 03b69ee79d5f..dd58f83ff1b9 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag4.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag4.json @@ -82,7 +82,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/leaveOptionalParameterAsWritten.json b/crates/swc_ecma_parser/tests/tsc/leaveOptionalParameterAsWritten.json index 50eb684bb853..bfd2e704305b 100644 --- a/crates/swc_ecma_parser/tests/tsc/leaveOptionalParameterAsWritten.json +++ b/crates/swc_ecma_parser/tests/tsc/leaveOptionalParameterAsWritten.json @@ -82,7 +82,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.json b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.json index c1687d9a0a82..71257cde2d4e 100644 --- a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.json +++ b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.json @@ -83,7 +83,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.json b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.json index e53a3784e53a..530508e646a6 100644 --- a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.json +++ b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.json @@ -83,7 +83,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/mergedWithLocalValue.json b/crates/swc_ecma_parser/tests/tsc/mergedWithLocalValue.json index bed590813c49..7505cc2795af 100644 --- a/crates/swc_ecma_parser/tests/tsc/mergedWithLocalValue.json +++ b/crates/swc_ecma_parser/tests/tsc/mergedWithLocalValue.json @@ -92,7 +92,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/moduleExportNestedNamespaces.json b/crates/swc_ecma_parser/tests/tsc/moduleExportNestedNamespaces.json index 7b3e685ccb7e..6457c8558eeb 100644 --- a/crates/swc_ecma_parser/tests/tsc/moduleExportNestedNamespaces.json +++ b/crates/swc_ecma_parser/tests/tsc/moduleExportNestedNamespaces.json @@ -448,7 +448,7 @@ "raw": "'./mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithExtensions.json b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithExtensions.json index 21c7ca2d6ce2..505737c835ec 100644 --- a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithExtensions.json +++ b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithExtensions.json @@ -62,7 +62,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -102,7 +102,7 @@ "raw": "'./a.js'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -209,7 +209,7 @@ "raw": "\"./jquery\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -249,7 +249,7 @@ "raw": "\"./jquery.js\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension1.json b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension1.json index 918c3c72f94b..71393367ca2a 100644 --- a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension1.json +++ b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension1.json @@ -107,7 +107,7 @@ "raw": "\"./foo\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -149,7 +149,7 @@ "raw": "\"./baz\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension3.json b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension3.json index e98175fc9b48..e25221c3761b 100644 --- a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension3.json +++ b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension3.json @@ -107,7 +107,7 @@ "raw": "\"./foo\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension4.json b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension4.json index c1d2e0e6c582..359a318b5b1a 100644 --- a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension4.json +++ b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension4.json @@ -107,7 +107,7 @@ "raw": "\"./foo\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension6.json b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension6.json index a8c23bc061c2..79f0e0dfee3d 100644 --- a/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension6.json +++ b/crates/swc_ecma_parser/tests/tsc/moduleResolutionWithoutExtension6.json @@ -46,7 +46,7 @@ "raw": "\"./foo\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/multipleDefaultExports01.json b/crates/swc_ecma_parser/tests/tsc/multipleDefaultExports01.json index 49435b3e0976..bcbfbead71c8 100644 --- a/crates/swc_ecma_parser/tests/tsc/multipleDefaultExports01.json +++ b/crates/swc_ecma_parser/tests/tsc/multipleDefaultExports01.json @@ -178,7 +178,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/multipleDefaultExports02.json b/crates/swc_ecma_parser/tests/tsc/multipleDefaultExports02.json index dd0c6c8aa962..7a52bbed2470 100644 --- a/crates/swc_ecma_parser/tests/tsc/multipleDefaultExports02.json +++ b/crates/swc_ecma_parser/tests/tsc/multipleDefaultExports02.json @@ -126,7 +126,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/namespaceImportTypeQuery.json b/crates/swc_ecma_parser/tests/tsc/namespaceImportTypeQuery.json index ae5c1761bb01..d0a168516a58 100644 --- a/crates/swc_ecma_parser/tests/tsc/namespaceImportTypeQuery.json +++ b/crates/swc_ecma_parser/tests/tsc/namespaceImportTypeQuery.json @@ -63,7 +63,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -145,7 +145,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/namespaceMemberAccess.json b/crates/swc_ecma_parser/tests/tsc/namespaceMemberAccess.json index bf9f66928671..e65222f95d27 100644 --- a/crates/swc_ecma_parser/tests/tsc/namespaceMemberAccess.json +++ b/crates/swc_ecma_parser/tests/tsc/namespaceMemberAccess.json @@ -109,7 +109,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -149,7 +149,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/nestedNamespace.json b/crates/swc_ecma_parser/tests/tsc/nestedNamespace.json index a69e9494ea6e..2f530a13433b 100644 --- a/crates/swc_ecma_parser/tests/tsc/nestedNamespace.json +++ b/crates/swc_ecma_parser/tests/tsc/nestedNamespace.json @@ -116,7 +116,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "TsInterfaceDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/noAssertForUnparseableTypedefs.json b/crates/swc_ecma_parser/tests/tsc/noAssertForUnparseableTypedefs.json index 1fef85497a06..bcd239a8f0a9 100644 --- a/crates/swc_ecma_parser/tests/tsc/noAssertForUnparseableTypedefs.json +++ b/crates/swc_ecma_parser/tests/tsc/noAssertForUnparseableTypedefs.json @@ -46,7 +46,7 @@ "raw": "'nope'" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/nodeModulesAllowJsCjsFromJs.json b/crates/swc_ecma_parser/tests/tsc/nodeModulesAllowJsCjsFromJs.json index d3b0731cd415..0193fed5d96e 100644 --- a/crates/swc_ecma_parser/tests/tsc/nodeModulesAllowJsCjsFromJs.json +++ b/crates/swc_ecma_parser/tests/tsc/nodeModulesAllowJsCjsFromJs.json @@ -99,7 +99,7 @@ "raw": "\"./foo.cjs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/nodeModulesAtTypesPriority.json b/crates/swc_ecma_parser/tests/tsc/nodeModulesAtTypesPriority.json index c60e34146528..4316bfdf632a 100644 --- a/crates/swc_ecma_parser/tests/tsc/nodeModulesAtTypesPriority.json +++ b/crates/swc_ecma_parser/tests/tsc/nodeModulesAtTypesPriority.json @@ -319,7 +319,7 @@ "raw": "\"react\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -361,7 +361,7 @@ "raw": "\"redux\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM1_emptyPackageJson.json b/crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM1_emptyPackageJson.json index d61b65bc8272..cdbff599d8fe 100644 --- a/crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM1_emptyPackageJson.json +++ b/crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM1_emptyPackageJson.json @@ -25,7 +25,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -46,7 +46,7 @@ "raw": "\"./module.mjs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -67,7 +67,7 @@ "raw": "\"./module.mjs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -88,7 +88,7 @@ "raw": "\"./module.mjs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -109,7 +109,7 @@ "raw": "\"./module.mjs\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM4_noPackageJson.json b/crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM4_noPackageJson.json index de725fc4876b..30e2e0c31c56 100644 --- a/crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM4_noPackageJson.json +++ b/crates/swc_ecma_parser/tests/tsc/nodeModulesCJSResolvingToESM4_noPackageJson.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -37,7 +37,7 @@ "raw": "\"./module.mjs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -58,7 +58,7 @@ "raw": "\"./module.mjs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -79,7 +79,7 @@ "raw": "\"./module.mjs\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -100,7 +100,7 @@ "raw": "\"./module.mjs\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesAmd.json b/crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesAmd.json index e0c13c963cfe..45616bdfe0ce 100644 --- a/crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesAmd.json +++ b/crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesAmd.json @@ -44,7 +44,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", @@ -145,7 +145,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesSystem.json b/crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesSystem.json index e6ef645cd562..251fd92c78ad 100644 --- a/crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesSystem.json +++ b/crates/swc_ecma_parser/tests/tsc/outFilerootDirModuleNamesSystem.json @@ -44,7 +44,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", @@ -145,7 +145,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/plainJSGrammarErrors2.json b/crates/swc_ecma_parser/tests/tsc/plainJSGrammarErrors2.json index 2c7170234fe2..1ee3a1b95518 100644 --- a/crates/swc_ecma_parser/tests/tsc/plainJSGrammarErrors2.json +++ b/crates/swc_ecma_parser/tests/tsc/plainJSGrammarErrors2.json @@ -73,7 +73,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/preserveValueImports.json b/crates/swc_ecma_parser/tests/tsc/preserveValueImports.json index 322d69c7eff2..ccdeea47f06b 100644 --- a/crates/swc_ecma_parser/tests/tsc/preserveValueImports.json +++ b/crates/swc_ecma_parser/tests/tsc/preserveValueImports.json @@ -259,7 +259,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -299,7 +299,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsExportAssignment", @@ -450,7 +450,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -512,7 +512,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/preserveValueImports_errors.json b/crates/swc_ecma_parser/tests/tsc/preserveValueImports_errors.json index d4053d792a98..67f8b27af561 100644 --- a/crates/swc_ecma_parser/tests/tsc/preserveValueImports_errors.json +++ b/crates/swc_ecma_parser/tests/tsc/preserveValueImports_errors.json @@ -83,7 +83,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -179,7 +179,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -219,7 +219,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -261,7 +261,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -301,7 +301,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -343,7 +343,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -383,7 +383,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -425,7 +425,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -465,7 +465,7 @@ "raw": "\"./b\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -507,7 +507,7 @@ "raw": "\"./b\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -558,7 +558,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -609,7 +609,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -660,7 +660,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -711,7 +711,7 @@ "raw": "\"./b\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -773,7 +773,7 @@ "raw": "\"./d\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -835,7 +835,7 @@ "raw": "\"./d\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -877,7 +877,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -919,7 +919,7 @@ "raw": "\"./b\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -981,7 +981,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1023,7 +1023,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -1065,7 +1065,7 @@ "raw": "\"./b\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -1127,7 +1127,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/preserveValueImports_importsNotUsedAsValues.json b/crates/swc_ecma_parser/tests/tsc/preserveValueImports_importsNotUsedAsValues.json index 57814a00804f..9d9117adde1a 100644 --- a/crates/swc_ecma_parser/tests/tsc/preserveValueImports_importsNotUsedAsValues.json +++ b/crates/swc_ecma_parser/tests/tsc/preserveValueImports_importsNotUsedAsValues.json @@ -197,7 +197,7 @@ "raw": "\"./mod.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -279,7 +279,7 @@ "raw": "\"./mod.js\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/preserveValueImports_mixedImports.json b/crates/swc_ecma_parser/tests/tsc/preserveValueImports_mixedImports.json index 28b376634117..eb2ad59d0ac6 100644 --- a/crates/swc_ecma_parser/tests/tsc/preserveValueImports_mixedImports.json +++ b/crates/swc_ecma_parser/tests/tsc/preserveValueImports_mixedImports.json @@ -146,7 +146,7 @@ "raw": "\"./exports.js\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -208,7 +208,7 @@ "raw": "\"./exports.js\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/preserveValueImports_module.json b/crates/swc_ecma_parser/tests/tsc/preserveValueImports_module.json index 4aa48d1570fb..b37b1d587406 100644 --- a/crates/swc_ecma_parser/tests/tsc/preserveValueImports_module.json +++ b/crates/swc_ecma_parser/tests/tsc/preserveValueImports_module.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.json b/crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.json index d04fd960aa25..8916fb45b7b6 100644 --- a/crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.json +++ b/crates/swc_ecma_parser/tests/tsc/privateNamesUnique-2.json @@ -343,7 +343,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -394,7 +394,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnImportedSymbol.json b/crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnImportedSymbol.json index 9afb56450080..223c386e3278 100644 --- a/crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnImportedSymbol.json +++ b/crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnImportedSymbol.json @@ -95,7 +95,7 @@ "raw": "'./mod1'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnUnresolvedImportedSymbol.json b/crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnUnresolvedImportedSymbol.json index bd6421528a7c..a22eddd2adb3 100644 --- a/crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnUnresolvedImportedSymbol.json +++ b/crates/swc_ecma_parser/tests/tsc/propertyAssignmentOnUnresolvedImportedSymbol.json @@ -44,7 +44,7 @@ "raw": "'arglebaz'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "BlockStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/reExportDefaultExport.json b/crates/swc_ecma_parser/tests/tsc/reExportDefaultExport.json index c5848530b6a4..1b67f519932d 100644 --- a/crates/swc_ecma_parser/tests/tsc/reExportDefaultExport.json +++ b/crates/swc_ecma_parser/tests/tsc/reExportDefaultExport.json @@ -78,7 +78,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -118,7 +118,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -160,7 +160,7 @@ "raw": "\"./m1\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/reExportJsFromTs.json b/crates/swc_ecma_parser/tests/tsc/reExportJsFromTs.json index bb80d517666d..13fdcae184fb 100644 --- a/crates/swc_ecma_parser/tests/tsc/reExportJsFromTs.json +++ b/crates/swc_ecma_parser/tests/tsc/reExportJsFromTs.json @@ -122,7 +122,7 @@ "raw": "\"../lib/constants\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -155,7 +155,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/renamed.json b/crates/swc_ecma_parser/tests/tsc/renamed.json index e458f6db7279..9a3c2e8e6751 100644 --- a/crates/swc_ecma_parser/tests/tsc/renamed.json +++ b/crates/swc_ecma_parser/tests/tsc/renamed.json @@ -118,7 +118,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -169,7 +169,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -220,7 +220,7 @@ "raw": "'./b'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/requireOfESWithPropertyAccess.json b/crates/swc_ecma_parser/tests/tsc/requireOfESWithPropertyAccess.json index ec2ec99b18de..326dcdb8cf06 100644 --- a/crates/swc_ecma_parser/tests/tsc/requireOfESWithPropertyAccess.json +++ b/crates/swc_ecma_parser/tests/tsc/requireOfESWithPropertyAccess.json @@ -293,7 +293,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/scopedPackagesClassic.json b/crates/swc_ecma_parser/tests/tsc/scopedPackagesClassic.json index 40b60073a3d9..1a25d999f794 100644 --- a/crates/swc_ecma_parser/tests/tsc/scopedPackagesClassic.json +++ b/crates/swc_ecma_parser/tests/tsc/scopedPackagesClassic.json @@ -96,7 +96,7 @@ "raw": "\"@see/saw\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.json b/crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.json index 593a8f92f435..f123b8d33d5b 100644 --- a/crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.json +++ b/crates/swc_ecma_parser/tests/tsc/superInStaticMembers1.json @@ -216,7 +216,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -2905,7 +2905,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -3138,7 +3138,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -3414,7 +3414,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -3672,7 +3672,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -3903,7 +3903,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -4177,7 +4177,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -4433,7 +4433,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -4652,7 +4652,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -4869,7 +4869,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -5096,7 +5096,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -5321,7 +5321,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -5543,7 +5543,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -5763,7 +5763,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -5977,7 +5977,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -6189,7 +6189,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -6403,7 +6403,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -6615,7 +6615,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -6736,7 +6736,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -6848,7 +6848,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -6969,7 +6969,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -7079,7 +7079,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -7202,7 +7202,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -7314,7 +7314,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -7437,7 +7437,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -7547,7 +7547,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -7679,7 +7679,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -7791,7 +7791,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -7923,7 +7923,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -8033,7 +8033,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -8165,7 +8165,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -8277,7 +8277,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -8409,7 +8409,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -8519,7 +8519,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -8651,7 +8651,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -8763,7 +8763,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -8895,7 +8895,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9005,7 +9005,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9128,7 +9128,7 @@ "raw": "\"./external\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9240,7 +9240,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9363,7 +9363,7 @@ "raw": "\"./external\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9473,7 +9473,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9594,7 +9594,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9706,7 +9706,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9827,7 +9827,7 @@ "raw": "\"./external\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -9937,7 +9937,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -10058,7 +10058,7 @@ "raw": "\"./external\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -10170,7 +10170,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -10291,7 +10291,7 @@ "raw": "\"./external\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -10401,7 +10401,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -10623,7 +10623,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -10843,7 +10843,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -11074,7 +11074,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -11303,7 +11303,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -11563,7 +11563,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -11821,7 +11821,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -12055,7 +12055,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -12287,7 +12287,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -12540,7 +12540,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -12791,7 +12791,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -13033,7 +13033,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -13273,7 +13273,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", @@ -13516,7 +13516,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/topLevelAwait.3.json b/crates/swc_ecma_parser/tests/tsc/topLevelAwait.3.json index 5ad38da9e1ce..6f42013621ab 100644 --- a/crates/swc_ecma_parser/tests/tsc/topLevelAwait.3.json +++ b/crates/swc_ecma_parser/tests/tsc/topLevelAwait.3.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/typeAndNamespaceExportMerge.json b/crates/swc_ecma_parser/tests/tsc/typeAndNamespaceExportMerge.json index 68df623d1a9b..a7f6833d3a9c 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeAndNamespaceExportMerge.json +++ b/crates/swc_ecma_parser/tests/tsc/typeAndNamespaceExportMerge.json @@ -218,7 +218,7 @@ "raw": "\"./constants\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -260,7 +260,7 @@ "raw": "\"./drink\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/typeFromPropertyAssignment5.json b/crates/swc_ecma_parser/tests/tsc/typeFromPropertyAssignment5.json index e604792a731d..9fd0893dc941 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeFromPropertyAssignment5.json +++ b/crates/swc_ecma_parser/tests/tsc/typeFromPropertyAssignment5.json @@ -191,7 +191,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge1.json b/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge1.json index 13e1aabb349b..7f79808b02ee 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge1.json +++ b/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge1.json @@ -67,7 +67,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -109,7 +109,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", @@ -184,7 +184,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -226,7 +226,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge2.json b/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge2.json index 8451ca7bc4ca..9f1baaf0f200 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge2.json +++ b/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge2.json @@ -78,7 +78,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -120,7 +120,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsTypeAliasDeclaration", @@ -182,7 +182,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -224,7 +224,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", @@ -286,7 +286,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -328,7 +328,7 @@ "raw": "\"./c\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge3.json b/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge3.json index 1c6fc24a3814..2bf714f54011 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge3.json +++ b/crates/swc_ecma_parser/tests/tsc/typeOnlyMerge3.json @@ -71,7 +71,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -113,7 +113,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", @@ -226,7 +226,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -268,7 +268,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/typeQuery.json b/crates/swc_ecma_parser/tests/tsc/typeQuery.json index eab8f1a236c2..158afe667c50 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeQuery.json +++ b/crates/swc_ecma_parser/tests/tsc/typeQuery.json @@ -80,7 +80,7 @@ "raw": "'./a'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/typeofImportTypeOnlyExport.json b/crates/swc_ecma_parser/tests/tsc/typeofImportTypeOnlyExport.json index 61ef7995c3cb..d54d421ccb7d 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeofImportTypeOnlyExport.json +++ b/crates/swc_ecma_parser/tests/tsc/typeofImportTypeOnlyExport.json @@ -46,7 +46,7 @@ "raw": "'./lit.js'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -165,7 +165,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/typingsLookupAmd.json b/crates/swc_ecma_parser/tests/tsc/typingsLookupAmd.json index 758cdadbd03d..68bd0f840102 100644 --- a/crates/swc_ecma_parser/tests/tsc/typingsLookupAmd.json +++ b/crates/swc_ecma_parser/tests/tsc/typingsLookupAmd.json @@ -80,7 +80,7 @@ "raw": "\"a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -165,7 +165,7 @@ "raw": "\"b\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/untypedModuleImport_allowJs.json b/crates/swc_ecma_parser/tests/tsc/untypedModuleImport_allowJs.json index cb1afe4ad5cf..49b08789713b 100644 --- a/crates/swc_ecma_parser/tests/tsc/untypedModuleImport_allowJs.json +++ b/crates/swc_ecma_parser/tests/tsc/untypedModuleImport_allowJs.json @@ -151,7 +151,7 @@ "raw": "\"foo\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/tsc/valuesMergingAcrossModules.json b/crates/swc_ecma_parser/tests/tsc/valuesMergingAcrossModules.json index c2fd0fcb7990..6a626db030d7 100644 --- a/crates/swc_ecma_parser/tests/tsc/valuesMergingAcrossModules.json +++ b/crates/swc_ecma_parser/tests/tsc/valuesMergingAcrossModules.json @@ -71,7 +71,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -113,7 +113,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsTypeAliasDeclaration", @@ -184,7 +184,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -226,7 +226,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsModuleDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxCompat.json b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxCompat.json index 4ca2e62f2ed8..f0b8686ef735 100644 --- a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxCompat.json +++ b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxCompat.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxInternalImportEquals.json b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxInternalImportEquals.json index 7a0335582370..5c84b7ee1b4a 100644 --- a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxInternalImportEquals.json +++ b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxInternalImportEquals.json @@ -16,7 +16,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", diff --git a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxNoElisionESM.json b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxNoElisionESM.json index 7dcbc106055d..c037fae5aec5 100644 --- a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxNoElisionESM.json +++ b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxNoElisionESM.json @@ -217,7 +217,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -297,7 +297,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -348,7 +348,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -381,7 +381,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -432,7 +432,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -483,7 +483,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -534,7 +534,7 @@ "raw": "\"./a\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -576,7 +576,7 @@ "raw": "\"./a\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -618,7 +618,7 @@ "raw": "\"./b\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", @@ -757,7 +757,7 @@ "raw": "\"./main5\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", diff --git a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsCJS.json b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsCJS.json index cb487f81eb44..0492b8fecd77 100644 --- a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsCJS.json +++ b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsCJS.json @@ -251,7 +251,7 @@ "raw": "\"./decl\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -291,7 +291,7 @@ "raw": "\"./decl\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -333,7 +333,7 @@ "raw": "\"./decl\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -384,7 +384,7 @@ "raw": "\"./decl\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExpressionStatement", @@ -485,7 +485,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -606,7 +606,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDeclaration", @@ -1161,7 +1161,7 @@ "raw": "\"./decl\"" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportDefaultExpression", diff --git a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsESM.json b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsESM.json index d6707bf4126e..be78cd65a00e 100644 --- a/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsESM.json +++ b/crates/swc_ecma_parser/tests/tsc/verbatimModuleSyntaxRestrictionsESM.json @@ -208,7 +208,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "TsImportEqualsDeclaration", @@ -324,7 +324,7 @@ "raw": "\"./decl\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -364,7 +364,7 @@ "raw": "\"./types\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/typescript/custom/issue-196-02/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/issue-196-02/input.ts.json index 199676061442..f381a526e581 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/issue-196-02/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/issue-196-02/input.ts.json @@ -149,7 +149,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/custom/issue-535/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/issue-535/input.ts.json index 8c99c0a349ef..f497293c0446 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/issue-535/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/issue-535/input.ts.json @@ -24,7 +24,7 @@ "raw": "\"test\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -45,7 +45,7 @@ "raw": "\"test\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -85,7 +85,7 @@ "raw": "\"test\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/custom/tsx-unary/input.tsx.json b/crates/swc_ecma_parser/tests/typescript/custom/tsx-unary/input.tsx.json index 37b42ea76295..a77f09db10b7 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/tsx-unary/input.tsx.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/tsx-unary/input.tsx.json @@ -44,7 +44,7 @@ "raw": "'react'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "FunctionDeclaration", diff --git a/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/aliased/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/aliased/input.ts.json index 40bc04ecef6c..433327585230 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/aliased/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/aliased/input.ts.json @@ -46,7 +46,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/specific/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/specific/input.ts.json index a130b48762c8..d43dd0ade244 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/specific/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/specific/input.ts.json @@ -37,7 +37,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/type-only-specifier/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/type-only-specifier/input.ts.json index 5ce1fdbb72ea..2319e4fcdb50 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/type-only-specifier/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/type-only/export/type-only-specifier/input.ts.json @@ -37,7 +37,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -70,7 +70,7 @@ ], "source": null, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -103,7 +103,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -136,7 +136,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -178,7 +178,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -220,7 +220,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -262,7 +262,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -304,7 +304,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -346,7 +346,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -388,7 +388,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -430,7 +430,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -472,7 +472,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -505,7 +505,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -547,7 +547,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportNamedDeclaration", @@ -589,7 +589,7 @@ ], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/aliased/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/aliased/input.ts.json index 4cad00dccf3e..67196a586765 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/aliased/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/aliased/input.ts.json @@ -55,7 +55,7 @@ "raw": "'foo'" }, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/default/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/default/input.ts.json index b14f634c9fd9..2ce29459659d 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/default/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/default/input.ts.json @@ -44,7 +44,7 @@ "raw": "'foo'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -84,7 +84,7 @@ "raw": "'./a'" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/specific/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/specific/input.ts.json index 85e3bc5a5951..58a02b84d1e9 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/specific/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/specific/input.ts.json @@ -46,7 +46,7 @@ "raw": "'foo'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -67,7 +67,7 @@ "raw": "'foo'" }, "typeOnly": true, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/type-only-specifier/input.ts.json b/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/type-only-specifier/input.ts.json index dbfee5962d53..d2d16732d280 100644 --- a/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/type-only-specifier/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/custom/type-only/import/type-only-specifier/input.ts.json @@ -46,7 +46,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -88,7 +88,7 @@ "raw": "'mod'" }, "typeOnly": true, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -130,7 +130,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -172,7 +172,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -223,7 +223,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -274,7 +274,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -325,7 +325,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -376,7 +376,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -427,7 +427,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -478,7 +478,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -529,7 +529,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -580,7 +580,7 @@ "raw": "'mod'" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/export/namespace-from/input.ts.json b/crates/swc_ecma_parser/tests/typescript/export/namespace-from/input.ts.json index 59c91fe9f817..382e3cd9ab8d 100644 --- a/crates/swc_ecma_parser/tests/typescript/export/namespace-from/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/export/namespace-from/input.ts.json @@ -44,7 +44,7 @@ "raw": "\"package\"" }, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test1/input.ts.json b/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test1/input.ts.json index 09e0932b8a12..4493c6e55aa5 100644 --- a/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test1/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test1/input.ts.json @@ -46,7 +46,7 @@ "raw": "'./foo.js'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 39, diff --git a/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test2/input.tsx.json b/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test2/input.tsx.json index f7a4e6ae69ce..b18f7ff47cf9 100644 --- a/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test2/input.tsx.json +++ b/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test2/input.tsx.json @@ -46,7 +46,7 @@ "raw": "'./foo.js.js'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 42, diff --git a/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test3/input.ts.json b/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test3/input.ts.json index 5975df6e9e35..ecb72ecf8ffb 100644 --- a/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test3/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/import-assertions/export/test3/input.ts.json @@ -24,7 +24,7 @@ "raw": "'./foo.js'" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 33, diff --git a/crates/swc_ecma_parser/tests/typescript/import-assertions/stmt/test1/input.ts.json b/crates/swc_ecma_parser/tests/typescript/import-assertions/stmt/test1/input.ts.json index cafe5fcd0816..e0d86a7ce159 100644 --- a/crates/swc_ecma_parser/tests/typescript/import-assertions/stmt/test1/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/import-assertions/stmt/test1/input.ts.json @@ -44,7 +44,7 @@ "raw": "\"./foo.json\"" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 38, diff --git a/crates/swc_ecma_parser/tests/typescript/import-assertions/stmt/test2/input.ts.json b/crates/swc_ecma_parser/tests/typescript/import-assertions/stmt/test2/input.ts.json index 4920e1194ccb..2f59413e21b4 100644 --- a/crates/swc_ecma_parser/tests/typescript/import-assertions/stmt/test2/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/import-assertions/stmt/test2/input.ts.json @@ -25,7 +25,7 @@ "raw": "\"./foo.json\"" }, "typeOnly": false, - "asserts": { + "with": { "type": "ObjectExpression", "span": { "start": 28, diff --git a/crates/swc_ecma_parser/tests/typescript/import/not-top-level/input.ts.json b/crates/swc_ecma_parser/tests/typescript/import/not-top-level/input.ts.json index 8ad74344a412..94a5f3fecfe6 100644 --- a/crates/swc_ecma_parser/tests/typescript/import/not-top-level/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/import/not-top-level/input.ts.json @@ -71,7 +71,7 @@ "raw": "\"a\"" }, "typeOnly": false, - "asserts": null + "with": null } ] } diff --git a/crates/swc_ecma_parser/tests/typescript/issue-1441/input.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-1441/input.ts.json index 80234420f901..38cbfc1bf7a0 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-1441/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-1441/input.ts.json @@ -52,7 +52,7 @@ "specifiers": [], "source": null, "typeOnly": false, - "asserts": null + "with": null } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/typescript/issue-1512/case1/input.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-1512/case1/input.ts.json index 781646db74ba..708dbb3da04a 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-1512/case1/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-1512/case1/input.ts.json @@ -44,7 +44,7 @@ "raw": "'./index'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/typescript/issue-2417/input.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-2417/input.ts.json index cb583f0da62a..fe0e6e5e73be 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-2417/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-2417/input.ts.json @@ -44,7 +44,7 @@ "raw": "'mongoose'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -126,7 +126,7 @@ "raw": "'@typegoose/typegoose'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -168,7 +168,7 @@ "raw": "'@typegoose/typegoose/lib/defaultClasses'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/typescript/issue-3241/1/input.tsx.json b/crates/swc_ecma_parser/tests/typescript/issue-3241/1/input.tsx.json index d293a8475c13..d2a0b30de206 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-3241/1/input.tsx.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-3241/1/input.tsx.json @@ -44,7 +44,7 @@ "raw": "\"react\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExportDeclaration", diff --git a/crates/swc_ecma_parser/tests/typescript/issue-3337/input.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-3337/input.ts.json index ae70c9c28553..21a2649a8f6b 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-3337/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-3337/input.ts.json @@ -44,7 +44,7 @@ "raw": "'joiful'" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ClassDeclaration", diff --git a/crates/swc_ecma_parser/tests/typescript/issue-4296/1/input.tsx.json b/crates/swc_ecma_parser/tests/typescript/issue-4296/1/input.tsx.json index 3776dea9a681..be207c40637d 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-4296/1/input.tsx.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-4296/1/input.tsx.json @@ -44,7 +44,7 @@ "raw": "\"react\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsInterfaceDeclaration", diff --git a/crates/swc_ecma_parser/tests/typescript/issue-6430/index.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-6430/index.ts.json index 59472fec6697..20359e9b60da 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-6430/index.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-6430/index.ts.json @@ -44,7 +44,7 @@ "raw": "\"../../../../swc_ecma_transforms_base/tests/ts-resolver/1/input\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "TsTypeAliasDeclaration", diff --git a/crates/swc_ecma_parser/tests/typescript/issue-913/input.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-913/input.ts.json index 7835599310f9..1bdc351533b2 100644 --- a/crates/swc_ecma_parser/tests/typescript/issue-913/input.ts.json +++ b/crates/swc_ecma_parser/tests/typescript/issue-913/input.ts.json @@ -46,7 +46,7 @@ "raw": "\"../../deps.ts\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -86,7 +86,7 @@ "raw": "\"../../members.ts\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ImportDeclaration", @@ -128,7 +128,7 @@ "raw": "\"../../../mod.ts\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/typescript/mts/1.mts.json b/crates/swc_ecma_parser/tests/typescript/mts/1.mts.json index 0308fe47ac22..2e9c8caa2ba3 100644 --- a/crates/swc_ecma_parser/tests/typescript/mts/1.mts.json +++ b/crates/swc_ecma_parser/tests/typescript/mts/1.mts.json @@ -44,7 +44,7 @@ "raw": "\"node:path\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "ExpressionStatement", diff --git a/crates/swc_ecma_parser/tests/typescript/next/0001/input.tsx.json b/crates/swc_ecma_parser/tests/typescript/next/0001/input.tsx.json index 337ad5c6af7a..185c30ef1181 100644 --- a/crates/swc_ecma_parser/tests/typescript/next/0001/input.tsx.json +++ b/crates/swc_ecma_parser/tests/typescript/next/0001/input.tsx.json @@ -44,7 +44,7 @@ "raw": "\"react\"" }, "typeOnly": false, - "asserts": null + "with": null }, { "type": "VariableDeclaration", diff --git a/crates/swc_ecma_preset_env/src/lib.rs b/crates/swc_ecma_preset_env/src/lib.rs index 4b14862b72fe..d87fed4b4d46 100644 --- a/crates/swc_ecma_preset_env/src/lib.rs +++ b/crates/swc_ecma_preset_env/src/lib.rs @@ -452,7 +452,7 @@ impl VisitMut for Polyfills { } .into(), type_only: false, - asserts: None, + with: None, })) }), ); @@ -470,7 +470,7 @@ impl VisitMut for Polyfills { } .into(), type_only: false, - asserts: None, + with: None, })) }), ); diff --git a/crates/swc_ecma_quote_macros/src/ast/module_decl.rs b/crates/swc_ecma_quote_macros/src/ast/module_decl.rs index 56503a53c0b2..17b2ebcfa1e8 100644 --- a/crates/swc_ecma_quote_macros/src/ast/module_decl.rs +++ b/crates/swc_ecma_quote_macros/src/ast/module_decl.rs @@ -15,12 +15,12 @@ impl_enum!( ] ); -impl_struct!(ImportDecl, [span, specifiers, src, type_only, asserts]); +impl_struct!(ImportDecl, [span, specifiers, src, type_only, with]); impl_struct!(ExportDecl, [span, decl]); impl_struct!(ExportDefaultDecl, [span, decl]); impl_struct!(ExportDefaultExpr, [span, expr]); -impl_struct!(ExportAll, [span, src, asserts]); -impl_struct!(NamedExport, [span, specifiers, src, type_only, asserts]); +impl_struct!(ExportAll, [span, src, with]); +impl_struct!(NamedExport, [span, specifiers, src, type_only, with]); impl_enum!(ImportSpecifier, [Named, Default, Namespace]); diff --git a/crates/swc_ecma_transforms_base/src/helpers/mod.rs b/crates/swc_ecma_transforms_base/src/helpers/mod.rs index 29e8f5160f4e..c29b1fe4f4d6 100644 --- a/crates/swc_ecma_transforms_base/src/helpers/mod.rs +++ b/crates/swc_ecma_transforms_base/src/helpers/mod.rs @@ -86,7 +86,7 @@ macro_rules! add_import_to { span: DUMMY_SP, specifiers: vec![s], src: Box::new(src), - asserts: Default::default(), + with: Default::default(), type_only: Default::default(), }))) } diff --git a/crates/swc_ecma_transforms_base/src/rename/ops.rs b/crates/swc_ecma_transforms_base/src/rename/ops.rs index 6ab3af91ec1a..c2e35bf962dd 100644 --- a/crates/swc_ecma_transforms_base/src/rename/ops.rs +++ b/crates/swc_ecma_transforms_base/src/rename/ops.rs @@ -223,7 +223,7 @@ impl<'a> VisitMut for Operator<'a> { })], src: None, type_only: false, - asserts: None, + with: None, }, ))); }; @@ -343,7 +343,7 @@ impl<'a> VisitMut for Operator<'a> { specifiers: renamed, src: None, type_only: false, - asserts: None, + with: None, }, ))); } diff --git a/crates/swc_ecma_transforms_compat/src/es2015/classes/mod.rs b/crates/swc_ecma_transforms_compat/src/es2015/classes/mod.rs index dc27b327ce67..e9660266cc4f 100644 --- a/crates/swc_ecma_transforms_compat/src/es2015/classes/mod.rs +++ b/crates/swc_ecma_transforms_compat/src/es2015/classes/mod.rs @@ -154,7 +154,7 @@ where .into()], src: None, type_only: false, - asserts: None, + with: None, }, )) { Ok(t) => t, diff --git a/crates/swc_ecma_transforms_compat/src/es2018/object_rest.rs b/crates/swc_ecma_transforms_compat/src/es2018/object_rest.rs index 269d987bd636..39e6fc125364 100644 --- a/crates/swc_ecma_transforms_compat/src/es2018/object_rest.rs +++ b/crates/swc_ecma_transforms_compat/src/es2018/object_rest.rs @@ -291,7 +291,7 @@ impl VisitMut for ObjectRest { specifiers, src: None, type_only: false, - asserts: None, + with: None, }; var_decl.visit_mut_with(self); diff --git a/crates/swc_ecma_transforms_compat/src/es2020/export_namespace_from.rs b/crates/swc_ecma_transforms_compat/src/es2020/export_namespace_from.rs index 3ca62e97c359..98ea8e3f570a 100644 --- a/crates/swc_ecma_transforms_compat/src/es2020/export_namespace_from.rs +++ b/crates/swc_ecma_transforms_compat/src/es2020/export_namespace_from.rs @@ -40,7 +40,7 @@ impl VisitMut for ExportNamespaceFrom { specifiers, src: Some(src), type_only: false, - asserts, + with, })) if specifiers.iter().any(|s| s.is_namespace()) => { let mut origin_specifiers = vec![]; @@ -79,7 +79,7 @@ impl VisitMut for ExportNamespaceFrom { specifiers: import_specifiers, src: src.clone(), type_only: false, - asserts: asserts.clone(), + with: with.clone(), }))); stmts.push(ModuleItem::ModuleDecl(ModuleDecl::ExportNamed( @@ -88,7 +88,7 @@ impl VisitMut for ExportNamespaceFrom { specifiers: export_specifiers, src: None, type_only: false, - asserts: None, + with: None, }, ))); @@ -99,7 +99,7 @@ impl VisitMut for ExportNamespaceFrom { specifiers: origin_specifiers, src: Some(src), type_only: false, - asserts, + with, }, ))); } diff --git a/crates/swc_ecma_transforms_compat/src/es2022/class_properties/mod.rs b/crates/swc_ecma_transforms_compat/src/es2022/class_properties/mod.rs index 5ba50de0c4ac..c83ebc23160a 100644 --- a/crates/swc_ecma_transforms_compat/src/es2022/class_properties/mod.rs +++ b/crates/swc_ecma_transforms_compat/src/es2022/class_properties/mod.rs @@ -365,7 +365,7 @@ impl ClassProperties { .into()], src: None, type_only: false, - asserts: None, + with: None, }, )) { Ok(t) => t, diff --git a/crates/swc_ecma_transforms_compat/src/es3/reserved_word.rs b/crates/swc_ecma_transforms_compat/src/es3/reserved_word.rs index 7df077e4b3c0..c1f8dbd6796e 100644 --- a/crates/swc_ecma_transforms_compat/src/es3/reserved_word.rs +++ b/crates/swc_ecma_transforms_compat/src/es3/reserved_word.rs @@ -72,7 +72,7 @@ impl VisitMut for ReservedWord { specifiers: extra_exports, src: None, type_only: false, - asserts: None, + with: None, } .into(), ); diff --git a/crates/swc_ecma_transforms_proposal/src/decorator_2022_03.rs b/crates/swc_ecma_transforms_proposal/src/decorator_2022_03.rs index b08bb7522c64..9545436f92eb 100644 --- a/crates/swc_ecma_transforms_proposal/src/decorator_2022_03.rs +++ b/crates/swc_ecma_transforms_proposal/src/decorator_2022_03.rs @@ -1505,7 +1505,7 @@ impl VisitMut for Decorator202203 { specifiers: self.extra_exports.take(), src: None, type_only: false, - asserts: None, + with: None, }, ))); } diff --git a/crates/swc_ecma_transforms_proposal/src/decorators/legacy/mod.rs b/crates/swc_ecma_transforms_proposal/src/decorators/legacy/mod.rs index 1f19f83fa476..cabada213eed 100644 --- a/crates/swc_ecma_transforms_proposal/src/decorators/legacy/mod.rs +++ b/crates/swc_ecma_transforms_proposal/src/decorators/legacy/mod.rs @@ -526,7 +526,7 @@ impl VisitMut for TscDecorator { specifiers: self.exports.take(), src: None, type_only: Default::default(), - asserts: Default::default(), + with: Default::default(), }, ))); } diff --git a/crates/swc_ecma_transforms_proposal/src/decorators/mod.rs b/crates/swc_ecma_transforms_proposal/src/decorators/mod.rs index 692c4d7021c6..026effac8340 100644 --- a/crates/swc_ecma_transforms_proposal/src/decorators/mod.rs +++ b/crates/swc_ecma_transforms_proposal/src/decorators/mod.rs @@ -212,7 +212,7 @@ impl Fold for Decorators { .into()], src: None, type_only: false, - asserts: None, + with: None, }, ))); }}; diff --git a/crates/swc_ecma_transforms_proposal/src/explicit_resource_management.rs b/crates/swc_ecma_transforms_proposal/src/explicit_resource_management.rs index 344975aaeb03..e8600538989e 100644 --- a/crates/swc_ecma_transforms_proposal/src/explicit_resource_management.rs +++ b/crates/swc_ecma_transforms_proposal/src/explicit_resource_management.rs @@ -113,7 +113,7 @@ impl ExplicitResourceManagement { })], src: None, type_only: Default::default(), - asserts: None, + with: None, })) .unwrap(), ); @@ -152,7 +152,7 @@ impl ExplicitResourceManagement { })], src: None, type_only: Default::default(), - asserts: None, + with: None, })) .unwrap(), ); diff --git a/crates/swc_ecma_transforms_proposal/src/export_default_from.rs b/crates/swc_ecma_transforms_proposal/src/export_default_from.rs index a310918f3fd7..6718a6d9ac6a 100644 --- a/crates/swc_ecma_transforms_proposal/src/export_default_from.rs +++ b/crates/swc_ecma_transforms_proposal/src/export_default_from.rs @@ -39,7 +39,7 @@ impl VisitMut for ExportDefaultFrom { specifiers, src: Some(src), type_only: false, - asserts, + with, })) if specifiers.iter().any(|s| s.is_default()) => { let mut origin_specifiers = vec![]; @@ -79,7 +79,7 @@ impl VisitMut for ExportDefaultFrom { specifiers: export_specifiers, src: Some(src.clone()), type_only: false, - asserts: None, + with: None, }, ))); @@ -90,7 +90,7 @@ impl VisitMut for ExportDefaultFrom { specifiers: origin_specifiers, src: Some(src), type_only: false, - asserts, + with, }, ))); } diff --git a/crates/swc_ecma_transforms_proposal/src/import_assertions.rs b/crates/swc_ecma_transforms_proposal/src/import_assertions.rs index 78aecc05757f..ef6f5de1bc48 100644 --- a/crates/swc_ecma_transforms_proposal/src/import_assertions.rs +++ b/crates/swc_ecma_transforms_proposal/src/import_assertions.rs @@ -10,14 +10,14 @@ impl VisitMut for ImportAssertions { noop_visit_mut_type!(); fn visit_mut_import_decl(&mut self, n: &mut ImportDecl) { - n.asserts = None; + n.with = None; } fn visit_mut_export_all(&mut self, n: &mut ExportAll) { - n.asserts = None; + n.with = None; } fn visit_mut_named_export(&mut self, n: &mut NamedExport) { - n.asserts = None; + n.with = None; } } diff --git a/crates/swc_ecma_transforms_proposal/tests/explicit_resource_management.rs b/crates/swc_ecma_transforms_proposal/tests/explicit_resource_management.rs index e546b724f424..df568a72095d 100644 --- a/crates/swc_ecma_transforms_proposal/tests/explicit_resource_management.rs +++ b/crates/swc_ecma_transforms_proposal/tests/explicit_resource_management.rs @@ -12,7 +12,7 @@ fn exec(input: PathBuf) { exec_tr( "explicit-resource-management", Syntax::Es(EsConfig { - using_decl: true, + explicit_resource_management: true, ..Default::default() }), |_| { @@ -42,7 +42,7 @@ fn run_fixture(input: PathBuf) { test_fixture( Syntax::Es(EsConfig { - using_decl: true, + explicit_resource_management: true, ..Default::default() }), &|_t| { diff --git a/crates/swc_ecma_transforms_proposal/tests/import_assertions.rs b/crates/swc_ecma_transforms_proposal/tests/import_assertions.rs index e4165c0b356e..b4b79c980ddf 100644 --- a/crates/swc_ecma_transforms_proposal/tests/import_assertions.rs +++ b/crates/swc_ecma_transforms_proposal/tests/import_assertions.rs @@ -9,7 +9,7 @@ fn tr() -> impl Fold { fn syntax() -> Syntax { Syntax::Es(EsConfig { - import_assertions: true, + import_attributes: true, ..Default::default() }) } diff --git a/crates/swc_ecma_transforms_react/src/jsx/mod.rs b/crates/swc_ecma_transforms_react/src/jsx/mod.rs index 2fd57a788a47..66842c9c97e3 100644 --- a/crates/swc_ecma_transforms_react/src/jsx/mod.rs +++ b/crates/swc_ecma_transforms_react/src/jsx/mod.rs @@ -1059,7 +1059,7 @@ where } .into(), type_only: Default::default(), - asserts: Default::default(), + with: Default::default(), })), ) }); diff --git a/crates/swc_ecma_transforms_typescript/src/import_export_assign.rs b/crates/swc_ecma_transforms_typescript/src/import_export_assign.rs index 25f8b58c8bae..5e9a3acc205a 100644 --- a/crates/swc_ecma_transforms_typescript/src/import_export_assign.rs +++ b/crates/swc_ecma_transforms_typescript/src/import_export_assign.rs @@ -56,7 +56,7 @@ impl VisitMut for ImportExportAssign { .into()], src: Box::new(quote_str!("module")), type_only: false, - asserts: None, + with: None, }) .into(), ); @@ -160,7 +160,7 @@ impl VisitMut for ImportExportAssign { .into()], src: None, type_only: false, - asserts: None, + with: None, } .into(), )) diff --git a/crates/swc_ecma_transforms_typescript/src/strip.rs b/crates/swc_ecma_transforms_typescript/src/strip.rs index 6c7419892f0f..97bbf218ccd7 100644 --- a/crates/swc_ecma_transforms_typescript/src/strip.rs +++ b/crates/swc_ecma_transforms_typescript/src/strip.rs @@ -2205,7 +2205,7 @@ where specifiers: vec![], src: None, type_only: false, - asserts: None, + with: None, }, ))) } diff --git a/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs b/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs index fe22e0b1e680..0497aff5bbb8 100644 --- a/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs +++ b/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs @@ -239,7 +239,7 @@ fn identity(entry: PathBuf) { decorators: true, decorators_before_export: true, export_default_from: true, - import_assertions: true, + import_attributes: true, allow_super_outside_method: true, ..Default::default() }), diff --git a/crates/swc_ecma_visit/src/lib.rs b/crates/swc_ecma_visit/src/lib.rs index 346d91364ed4..788cd818c4ce 100644 --- a/crates/swc_ecma_visit/src/lib.rs +++ b/crates/swc_ecma_visit/src/lib.rs @@ -1095,20 +1095,20 @@ define!({ pub specifiers: Vec, pub src: Box, pub type_only: bool, - pub asserts: Option>, + pub with: Option>, } pub struct ExportAll { pub span: Span, pub src: Box, pub type_only: bool, - pub asserts: Option>, + pub with: Option>, } pub struct NamedExport { pub span: Span, pub specifiers: Vec, pub src: Option>, pub type_only: bool, - pub asserts: Option>, + pub with: Option>, } pub struct ExportDefaultDecl { pub span: Span, diff --git a/crates/swc_estree_ast/src/module.rs b/crates/swc_estree_ast/src/module.rs index 70fd9ba1ff2e..54e75758e717 100644 --- a/crates/swc_estree_ast/src/module.rs +++ b/crates/swc_estree_ast/src/module.rs @@ -143,7 +143,7 @@ pub struct ExportAllDeclaration { pub base: BaseNode, pub source: StringLiteral, #[serde(default)] - pub assertions: Option>, + pub with: Option>, #[serde(default)] pub export_kind: Option, } @@ -192,7 +192,7 @@ pub struct ExportNamedDeclaration { #[serde(default)] pub source: Option, #[serde(default)] - pub assertions: Option>, + pub with: Option>, #[serde(default)] pub export_kind: Option, } @@ -270,7 +270,7 @@ pub struct ImportDeclaration { pub specifiers: Vec, pub source: StringLiteral, #[serde(default)] - pub assertions: Option>, + pub with: Option>, #[serde(default)] pub import_kind: Option, } diff --git a/crates/swc_estree_compat/src/babelify/module_decl.rs b/crates/swc_estree_compat/src/babelify/module_decl.rs index 4d49dc8c375f..91fea257b35d 100644 --- a/crates/swc_estree_compat/src/babelify/module_decl.rs +++ b/crates/swc_estree_compat/src/babelify/module_decl.rs @@ -90,13 +90,13 @@ impl Babelify for ExportDecl { declaration: Some(Box::alloc().init(self.decl.babelify(ctx))), specifiers: Default::default(), source: Default::default(), - assertions: Default::default(), + with: Default::default(), export_kind: Default::default(), } } } -fn convert_import_asserts( +fn convert_import_attrs( asserts: Option>, ctx: &Context, ) -> Option> { @@ -161,7 +161,7 @@ impl Babelify for ImportDecl { base: ctx.base(self.span), specifiers: self.specifiers.babelify(ctx), source: self.src.babelify(ctx), - assertions: convert_import_asserts(self.asserts, ctx), + with: convert_import_attrs(self.with, ctx), import_kind: if self.type_only { Some(ImportKind::Type) } else { @@ -178,7 +178,7 @@ impl Babelify for ExportAll { ExportAllDeclaration { base: ctx.base(self.span), source: self.src.babelify(ctx), - assertions: convert_import_asserts(self.asserts, ctx), + with: convert_import_attrs(self.with, ctx), export_kind: if self.type_only { Some(ExportKind::Type) } else { @@ -197,7 +197,7 @@ impl Babelify for NamedExport { declaration: Default::default(), specifiers: self.specifiers.babelify(ctx), source: self.src.map(|s| s.babelify(ctx)), - assertions: convert_import_asserts(self.asserts, ctx), + with: convert_import_attrs(self.with, ctx), export_kind: if self.type_only { Some(ExportKind::Type) } else { diff --git a/crates/swc_estree_compat/src/swcify/stmt.rs b/crates/swc_estree_compat/src/swcify/stmt.rs index 80bae36d8ed6..4b806296ec6e 100644 --- a/crates/swc_estree_compat/src/swcify/stmt.rs +++ b/crates/swc_estree_compat/src/swcify/stmt.rs @@ -436,8 +436,8 @@ impl Swcify for ExportAllDeclaration { span: ctx.span(&self.base), src: self.source.swcify(ctx).into(), type_only: self.export_kind == Some(ExportKind::Type), - asserts: self - .assertions + with: self + .with .swcify(ctx) .map(|props| { props @@ -528,8 +528,8 @@ impl Swcify for ExportNamedDeclaration { specifiers: self.specifiers.swcify(ctx), src: self.source.swcify(ctx).map(Box::new), type_only: false, - asserts: self - .assertions + with: self + .with .swcify(ctx) .map(|props| { props @@ -625,8 +625,8 @@ impl Swcify for ImportDeclaration { specifiers: self.specifiers.swcify(ctx), src: self.source.swcify(ctx).into(), type_only: false, - asserts: self - .assertions + with: self + .with .swcify(ctx) .map(|props| { props @@ -779,7 +779,7 @@ impl Swcify for DeclareExportAllDeclaration { span: ctx.span(&self.base), src: self.source.swcify(ctx).into(), type_only: self.export_kind == Some(ExportKind::Type), - asserts: Default::default(), + with: Default::default(), } } }