From 5a6f0e644ebd515c9de69f8efa0e2b5c79944a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 1 Nov 2024 15:34:08 +0900 Subject: [PATCH] feat(es): Add `es2023` and `es2024` to `EsVersion` (#9700) --- .changeset/three-clocks-punch.md | 5 + crates/swc_ecma_ast/src/lib.rs | 4 + crates/swc_ecma_visit/src/generated.rs | 425 ------------------------- packages/types/index.ts | 2 + packages/types/package.json | 2 +- tools/generate-code/src/main.rs | 9 +- 6 files changed, 19 insertions(+), 428 deletions(-) create mode 100644 .changeset/three-clocks-punch.md diff --git a/.changeset/three-clocks-punch.md b/.changeset/three-clocks-punch.md new file mode 100644 index 000000000000..55ca1901b1bd --- /dev/null +++ b/.changeset/three-clocks-punch.md @@ -0,0 +1,5 @@ +--- +swc_ecma_ast: major +--- + +feat(es): Add `es2023` and `es2024` to `EsVersion` diff --git a/crates/swc_ecma_ast/src/lib.rs b/crates/swc_ecma_ast/src/lib.rs index 942cf099b914..d6aa2501b73f 100644 --- a/crates/swc_ecma_ast/src/lib.rs +++ b/crates/swc_ecma_ast/src/lib.rs @@ -358,6 +358,8 @@ pub enum EsVersion { Es2020, Es2021, Es2022, + Es2023, + Es2024, EsNext, } @@ -381,6 +383,8 @@ impl<'de> Deserialize<'de> for EsVersion { "es2020" => Ok(EsVersion::Es2020), "es2021" => Ok(EsVersion::Es2021), "es2022" => Ok(EsVersion::Es2022), + "es2023" => Ok(EsVersion::Es2023), + "es2024" => Ok(EsVersion::Es2024), "esnext" => Ok(EsVersion::EsNext), _ => Err(D::Error::custom(format!("Unknown ES version: {}", s))), } diff --git a/crates/swc_ecma_visit/src/generated.rs b/crates/swc_ecma_visit/src/generated.rs index d65a92315ca3..d50925961e3c 100644 --- a/crates/swc_ecma_visit/src/generated.rs +++ b/crates/swc_ecma_visit/src/generated.rs @@ -308,13 +308,6 @@ pub trait Visit { fn visit_empty_stmt(&mut self, node: &EmptyStmt) { >::visit_children_with(node, self) } - #[doc = "Visit a node of type `EsVersion`.\n\nBy default, this method calls \ - [`EsVersion::visit_children_with`]. If you want to recurse, you need to call it \ - manually."] - #[inline] - fn visit_es_version(&mut self, node: &EsVersion) { - >::visit_children_with(node, self) - } #[doc = "Visit a node of type `ExportAll`.\n\nBy default, this method calls \ [`ExportAll::visit_children_with`]. If you want to recurse, you need to call it \ manually."] @@ -2245,11 +2238,6 @@ where ::visit_empty_stmt(&mut **self, node) } - #[inline] - fn visit_es_version(&mut self, node: &EsVersion) { - ::visit_es_version(&mut **self, node) - } - #[inline] fn visit_export_all(&mut self, node: &ExportAll) { ::visit_export_all(&mut **self, node) @@ -3712,11 +3700,6 @@ where ::visit_empty_stmt(&mut **self, node) } - #[inline] - fn visit_es_version(&mut self, node: &EsVersion) { - ::visit_es_version(&mut **self, node) - } - #[inline] fn visit_export_all(&mut self, node: &ExportAll) { ::visit_export_all(&mut **self, node) @@ -5312,14 +5295,6 @@ where } } - #[inline] - fn visit_es_version(&mut self, node: &EsVersion) { - match self { - swc_visit::Either::Left(visitor) => Visit::visit_es_version(visitor, node), - swc_visit::Either::Right(visitor) => Visit::visit_es_version(visitor, node), - } - } - #[inline] fn visit_export_all(&mut self, node: &ExportAll) { match self { @@ -7703,14 +7678,6 @@ where } } - #[inline] - fn visit_es_version(&mut self, node: &EsVersion) { - if self.enabled { - ::visit_es_version(&mut self.visitor, node) - } else { - } - } - #[inline] fn visit_export_all(&mut self, node: &ExportAll) { if self.enabled { @@ -10725,28 +10692,6 @@ impl VisitWith for EmptyStmt { } } } -impl VisitWith for EsVersion { - #[doc = "Calls [Visit`::visit_es_version`] with `self`."] - fn visit_with(&self, visitor: &mut V) { - ::visit_es_version(visitor, self) - } - - fn visit_children_with(&self, visitor: &mut V) { - match self { - EsVersion::Es3 => {} - EsVersion::Es5 => {} - EsVersion::Es2015 => {} - EsVersion::Es2016 => {} - EsVersion::Es2017 => {} - EsVersion::Es2018 => {} - EsVersion::Es2019 => {} - EsVersion::Es2020 => {} - EsVersion::Es2021 => {} - EsVersion::Es2022 => {} - EsVersion::EsNext => {} - } - } -} impl VisitWith for ExportAll { #[doc = "Calls [Visit`::visit_export_all`] with `self`."] fn visit_with(&self, visitor: &mut V) { @@ -16778,17 +16723,6 @@ pub trait VisitAstPath { ) { >::visit_children_with_ast_path(node, self, __ast_path) } - #[doc = "Visit a node of type `EsVersion`.\n\nBy default, this method calls \ - [`EsVersion::visit_children_with_ast_path`]. If you want to recurse, you need to call \ - it manually."] - #[inline] - fn visit_es_version<'ast: 'r, 'r>( - &mut self, - node: &'ast EsVersion, - __ast_path: &mut AstNodePath<'r>, - ) { - >::visit_children_with_ast_path(node, self, __ast_path) - } #[doc = "Visit a node of type `ExportAll`.\n\nBy default, this method calls \ [`ExportAll::visit_children_with_ast_path`]. If you want to recurse, you need to call \ it manually."] @@ -20132,15 +20066,6 @@ where ::visit_empty_stmt(&mut **self, node, __ast_path) } - #[inline] - fn visit_es_version<'ast: 'r, 'r>( - &mut self, - node: &'ast EsVersion, - __ast_path: &mut AstNodePath<'r>, - ) { - ::visit_es_version(&mut **self, node, __ast_path) - } - #[inline] fn visit_export_all<'ast: 'r, 'r>( &mut self, @@ -22670,15 +22595,6 @@ where ::visit_empty_stmt(&mut **self, node, __ast_path) } - #[inline] - fn visit_es_version<'ast: 'r, 'r>( - &mut self, - node: &'ast EsVersion, - __ast_path: &mut AstNodePath<'r>, - ) { - ::visit_es_version(&mut **self, node, __ast_path) - } - #[inline] fn visit_export_all<'ast: 'r, 'r>( &mut self, @@ -25511,22 +25427,6 @@ where } } - #[inline] - fn visit_es_version<'ast: 'r, 'r>( - &mut self, - node: &'ast EsVersion, - __ast_path: &mut AstNodePath<'r>, - ) { - match self { - swc_visit::Either::Left(visitor) => { - VisitAstPath::visit_es_version(visitor, node, __ast_path) - } - swc_visit::Either::Right(visitor) => { - VisitAstPath::visit_es_version(visitor, node, __ast_path) - } - } - } - #[inline] fn visit_export_all<'ast: 'r, 'r>( &mut self, @@ -29885,18 +29785,6 @@ where } } - #[inline] - fn visit_es_version<'ast: 'r, 'r>( - &mut self, - node: &'ast EsVersion, - __ast_path: &mut AstNodePath<'r>, - ) { - if self.enabled { - ::visit_es_version(&mut self.visitor, node, __ast_path) - } else { - } - } - #[inline] fn visit_export_all<'ast: 'r, 'r>( &mut self, @@ -35261,38 +35149,6 @@ impl VisitWithAstPath for EmptyStmt { } #[cfg(any(docsrs, feature = "path"))] #[cfg_attr(docsrs, doc(cfg(feature = "path")))] -impl VisitWithAstPath for EsVersion { - #[doc = "Calls [VisitAstPath`::visit_es_version`] with `self`."] - fn visit_with_ast_path<'ast: 'r, 'r>( - &'ast self, - visitor: &mut V, - __ast_path: &mut AstNodePath<'r>, - ) { - ::visit_es_version(visitor, self, __ast_path) - } - - fn visit_children_with_ast_path<'ast: 'r, 'r>( - &'ast self, - visitor: &mut V, - __ast_path: &mut AstNodePath<'r>, - ) { - match self { - EsVersion::Es3 => {} - EsVersion::Es5 => {} - EsVersion::Es2015 => {} - EsVersion::Es2016 => {} - EsVersion::Es2017 => {} - EsVersion::Es2018 => {} - EsVersion::Es2019 => {} - EsVersion::Es2020 => {} - EsVersion::Es2021 => {} - EsVersion::Es2022 => {} - EsVersion::EsNext => {} - } - } -} -#[cfg(any(docsrs, feature = "path"))] -#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl VisitWithAstPath for ExportAll { #[doc = "Calls [VisitAstPath`::visit_export_all`] with `self`."] fn visit_with_ast_path<'ast: 'r, 'r>( @@ -48709,13 +48565,6 @@ pub trait VisitMut { fn visit_mut_empty_stmt(&mut self, node: &mut EmptyStmt) { >::visit_mut_children_with(node, self) } - #[doc = "Visit a node of type `EsVersion`.\n\nBy default, this method calls \ - [`EsVersion::visit_mut_children_with`]. If you want to recurse, you need to call it \ - manually."] - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion) { - >::visit_mut_children_with(node, self) - } #[doc = "Visit a node of type `ExportAll`.\n\nBy default, this method calls \ [`ExportAll::visit_mut_children_with`]. If you want to recurse, you need to call it \ manually."] @@ -50672,11 +50521,6 @@ where ::visit_mut_empty_stmt(&mut **self, node) } - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion) { - ::visit_mut_es_version(&mut **self, node) - } - #[inline] fn visit_mut_export_all(&mut self, node: &mut ExportAll) { ::visit_mut_export_all(&mut **self, node) @@ -52139,11 +51983,6 @@ where ::visit_mut_empty_stmt(&mut **self, node) } - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion) { - ::visit_mut_es_version(&mut **self, node) - } - #[inline] fn visit_mut_export_all(&mut self, node: &mut ExportAll) { ::visit_mut_export_all(&mut **self, node) @@ -53751,14 +53590,6 @@ where } } - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion) { - match self { - swc_visit::Either::Left(visitor) => VisitMut::visit_mut_es_version(visitor, node), - swc_visit::Either::Right(visitor) => VisitMut::visit_mut_es_version(visitor, node), - } - } - #[inline] fn visit_mut_export_all(&mut self, node: &mut ExportAll) { match self { @@ -56434,14 +56265,6 @@ where } } - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion) { - if self.enabled { - ::visit_mut_es_version(&mut self.visitor, node) - } else { - } - } - #[inline] fn visit_mut_export_all(&mut self, node: &mut ExportAll) { if self.enabled { @@ -59479,28 +59302,6 @@ impl VisitMutWith for EmptyStmt { } } } -impl VisitMutWith for EsVersion { - #[doc = "Calls [VisitMut`::visit_mut_es_version`] with `self`."] - fn visit_mut_with(&mut self, visitor: &mut V) { - ::visit_mut_es_version(visitor, self) - } - - fn visit_mut_children_with(&mut self, visitor: &mut V) { - match self { - EsVersion::Es3 => {} - EsVersion::Es5 => {} - EsVersion::Es2015 => {} - EsVersion::Es2016 => {} - EsVersion::Es2017 => {} - EsVersion::Es2018 => {} - EsVersion::Es2019 => {} - EsVersion::Es2020 => {} - EsVersion::Es2021 => {} - EsVersion::Es2022 => {} - EsVersion::EsNext => {} - } - } -} impl VisitMutWith for ExportAll { #[doc = "Calls [VisitMut`::visit_mut_export_all`] with `self`."] fn visit_mut_with(&mut self, visitor: &mut V) { @@ -65465,15 +65266,6 @@ pub trait VisitMutAstPath { node, self, __ast_path, ) } - #[doc = "Visit a node of type `EsVersion`.\n\nBy default, this method calls \ - [`EsVersion::visit_mut_children_with_ast_path`]. If you want to recurse, you need to \ - call it manually."] - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion, __ast_path: &mut AstKindPath) { - >::visit_mut_children_with_ast_path( - node, self, __ast_path, - ) - } #[doc = "Visit a node of type `ExportAll`.\n\nBy default, this method calls \ [`ExportAll::visit_mut_children_with_ast_path`]. If you want to recurse, you need to \ call it manually."] @@ -68379,11 +68171,6 @@ where ::visit_mut_empty_stmt(&mut **self, node, __ast_path) } - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion, __ast_path: &mut AstKindPath) { - ::visit_mut_es_version(&mut **self, node, __ast_path) - } - #[inline] fn visit_mut_export_all(&mut self, node: &mut ExportAll, __ast_path: &mut AstKindPath) { ::visit_mut_export_all(&mut **self, node, __ast_path) @@ -70321,11 +70108,6 @@ where ::visit_mut_empty_stmt(&mut **self, node, __ast_path) } - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion, __ast_path: &mut AstKindPath) { - ::visit_mut_es_version(&mut **self, node, __ast_path) - } - #[inline] fn visit_mut_export_all(&mut self, node: &mut ExportAll, __ast_path: &mut AstKindPath) { ::visit_mut_export_all(&mut **self, node, __ast_path) @@ -72572,18 +72354,6 @@ where } } - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion, __ast_path: &mut AstKindPath) { - match self { - swc_visit::Either::Left(visitor) => { - VisitMutAstPath::visit_mut_es_version(visitor, node, __ast_path) - } - swc_visit::Either::Right(visitor) => { - VisitMutAstPath::visit_mut_es_version(visitor, node, __ast_path) - } - } - } - #[inline] fn visit_mut_export_all(&mut self, node: &mut ExportAll, __ast_path: &mut AstKindPath) { match self { @@ -76386,14 +76156,6 @@ where } } - #[inline] - fn visit_mut_es_version(&mut self, node: &mut EsVersion, __ast_path: &mut AstKindPath) { - if self.enabled { - ::visit_mut_es_version(&mut self.visitor, node, __ast_path) - } else { - } - } - #[inline] fn visit_mut_export_all(&mut self, node: &mut ExportAll, __ast_path: &mut AstKindPath) { if self.enabled { @@ -81023,30 +80785,6 @@ impl VisitMutWithAstPath for EmptyStmt { } #[cfg(any(docsrs, feature = "path"))] #[cfg_attr(docsrs, doc(cfg(feature = "path")))] -impl VisitMutWithAstPath for EsVersion { - #[doc = "Calls [VisitMutAstPath`::visit_mut_es_version`] with `self`."] - fn visit_mut_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - ::visit_mut_es_version(visitor, self, __ast_path) - } - - fn visit_mut_children_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { - match self { - EsVersion::Es3 => {} - EsVersion::Es5 => {} - EsVersion::Es2015 => {} - EsVersion::Es2016 => {} - EsVersion::Es2017 => {} - EsVersion::Es2018 => {} - EsVersion::Es2019 => {} - EsVersion::Es2020 => {} - EsVersion::Es2021 => {} - EsVersion::Es2022 => {} - EsVersion::EsNext => {} - } - } -} -#[cfg(any(docsrs, feature = "path"))] -#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl VisitMutWithAstPath for ExportAll { #[doc = "Calls [VisitMutAstPath`::visit_mut_export_all`] with `self`."] fn visit_mut_with_ast_path(&mut self, visitor: &mut V, __ast_path: &mut AstKindPath) { @@ -91641,13 +91379,6 @@ pub trait Fold { fn fold_empty_stmt(&mut self, node: EmptyStmt) -> EmptyStmt { >::fold_children_with(node, self) } - #[doc = "Visit a node of type `EsVersion`.\n\nBy default, this method calls \ - [`EsVersion::fold_children_with`]. If you want to recurse, you need to call it \ - manually."] - #[inline] - fn fold_es_version(&mut self, node: EsVersion) -> EsVersion { - >::fold_children_with(node, self) - } #[doc = "Visit a node of type `ExportAll`.\n\nBy default, this method calls \ [`ExportAll::fold_children_with`]. If you want to recurse, you need to call it \ manually."] @@ -93618,11 +93349,6 @@ where ::fold_empty_stmt(&mut **self, node) } - #[inline] - fn fold_es_version(&mut self, node: EsVersion) -> EsVersion { - ::fold_es_version(&mut **self, node) - } - #[inline] fn fold_export_all(&mut self, node: ExportAll) -> ExportAll { ::fold_export_all(&mut **self, node) @@ -95139,11 +94865,6 @@ where ::fold_empty_stmt(&mut **self, node) } - #[inline] - fn fold_es_version(&mut self, node: EsVersion) -> EsVersion { - ::fold_es_version(&mut **self, node) - } - #[inline] fn fold_export_all(&mut self, node: ExportAll) -> ExportAll { ::fold_export_all(&mut **self, node) @@ -96793,14 +96514,6 @@ where } } - #[inline] - fn fold_es_version(&mut self, node: EsVersion) -> EsVersion { - match self { - swc_visit::Either::Left(visitor) => Fold::fold_es_version(visitor, node), - swc_visit::Either::Right(visitor) => Fold::fold_es_version(visitor, node), - } - } - #[inline] fn fold_export_all(&mut self, node: ExportAll) -> ExportAll { match self { @@ -99256,15 +98969,6 @@ where } } - #[inline] - fn fold_es_version(&mut self, node: EsVersion) -> EsVersion { - if self.enabled { - ::fold_es_version(&mut self.visitor, node) - } else { - node - } - } - #[inline] fn fold_export_all(&mut self, node: ExportAll) -> ExportAll { if self.enabled { @@ -102558,28 +102262,6 @@ impl FoldWith for EmptyStmt { } } } -impl FoldWith for EsVersion { - #[doc = "Calls [Fold`::fold_es_version`] with `self`."] - fn fold_with(self, visitor: &mut V) -> Self { - ::fold_es_version(visitor, self) - } - - fn fold_children_with(self, visitor: &mut V) -> Self { - match self { - EsVersion::Es3 => EsVersion::Es3, - EsVersion::Es5 => EsVersion::Es5, - EsVersion::Es2015 => EsVersion::Es2015, - EsVersion::Es2016 => EsVersion::Es2016, - EsVersion::Es2017 => EsVersion::Es2017, - EsVersion::Es2018 => EsVersion::Es2018, - EsVersion::Es2019 => EsVersion::Es2019, - EsVersion::Es2020 => EsVersion::Es2020, - EsVersion::Es2021 => EsVersion::Es2021, - EsVersion::Es2022 => EsVersion::Es2022, - EsVersion::EsNext => EsVersion::EsNext, - } - } -} impl FoldWith for ExportAll { #[doc = "Calls [Fold`::fold_export_all`] with `self`."] fn fold_with(self, visitor: &mut V) -> Self { @@ -108432,13 +108114,6 @@ pub trait FoldAstPath { fn fold_empty_stmt(&mut self, node: EmptyStmt, __ast_path: &mut AstKindPath) -> EmptyStmt { >::fold_children_with_ast_path(node, self, __ast_path) } - #[doc = "Visit a node of type `EsVersion`.\n\nBy default, this method calls \ - [`EsVersion::fold_children_with_ast_path`]. If you want to recurse, you need to call \ - it manually."] - #[inline] - fn fold_es_version(&mut self, node: EsVersion, __ast_path: &mut AstKindPath) -> EsVersion { - >::fold_children_with_ast_path(node, self, __ast_path) - } #[doc = "Visit a node of type `ExportAll`.\n\nBy default, this method calls \ [`ExportAll::fold_children_with_ast_path`]. If you want to recurse, you need to call \ it manually."] @@ -111354,11 +111029,6 @@ where ::fold_empty_stmt(&mut **self, node, __ast_path) } - #[inline] - fn fold_es_version(&mut self, node: EsVersion, __ast_path: &mut AstKindPath) -> EsVersion { - ::fold_es_version(&mut **self, node, __ast_path) - } - #[inline] fn fold_export_all(&mut self, node: ExportAll, __ast_path: &mut AstKindPath) -> ExportAll { ::fold_export_all(&mut **self, node, __ast_path) @@ -113528,11 +113198,6 @@ where ::fold_empty_stmt(&mut **self, node, __ast_path) } - #[inline] - fn fold_es_version(&mut self, node: EsVersion, __ast_path: &mut AstKindPath) -> EsVersion { - ::fold_es_version(&mut **self, node, __ast_path) - } - #[inline] fn fold_export_all(&mut self, node: ExportAll, __ast_path: &mut AstKindPath) -> ExportAll { ::fold_export_all(&mut **self, node, __ast_path) @@ -115993,18 +115658,6 @@ where } } - #[inline] - fn fold_es_version(&mut self, node: EsVersion, __ast_path: &mut AstKindPath) -> EsVersion { - match self { - swc_visit::Either::Left(visitor) => { - FoldAstPath::fold_es_version(visitor, node, __ast_path) - } - swc_visit::Either::Right(visitor) => { - FoldAstPath::fold_es_version(visitor, node, __ast_path) - } - } - } - #[inline] fn fold_export_all(&mut self, node: ExportAll, __ast_path: &mut AstKindPath) -> ExportAll { match self { @@ -119999,15 +119652,6 @@ where } } - #[inline] - fn fold_es_version(&mut self, node: EsVersion, __ast_path: &mut AstKindPath) -> EsVersion { - if self.enabled { - ::fold_es_version(&mut self.visitor, node, __ast_path) - } else { - node - } - } - #[inline] fn fold_export_all(&mut self, node: ExportAll, __ast_path: &mut AstKindPath) -> ExportAll { if self.enabled { @@ -124984,30 +124628,6 @@ impl FoldWithAstPath for EmptyStmt { } #[cfg(any(docsrs, feature = "path"))] #[cfg_attr(docsrs, doc(cfg(feature = "path")))] -impl FoldWithAstPath for EsVersion { - #[doc = "Calls [FoldAstPath`::fold_es_version`] with `self`."] - fn fold_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - ::fold_es_version(visitor, self, __ast_path) - } - - fn fold_children_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { - match self { - EsVersion::Es3 => EsVersion::Es3, - EsVersion::Es5 => EsVersion::Es5, - EsVersion::Es2015 => EsVersion::Es2015, - EsVersion::Es2016 => EsVersion::Es2016, - EsVersion::Es2017 => EsVersion::Es2017, - EsVersion::Es2018 => EsVersion::Es2018, - EsVersion::Es2019 => EsVersion::Es2019, - EsVersion::Es2020 => EsVersion::Es2020, - EsVersion::Es2021 => EsVersion::Es2021, - EsVersion::Es2022 => EsVersion::Es2022, - EsVersion::EsNext => EsVersion::EsNext, - } - } -} -#[cfg(any(docsrs, feature = "path"))] -#[cfg_attr(docsrs, doc(cfg(feature = "path")))] impl FoldWithAstPath for ExportAll { #[doc = "Calls [FoldAstPath`::fold_export_all`] with `self`."] fn fold_with_ast_path(self, visitor: &mut V, __ast_path: &mut AstKindPath) -> Self { @@ -136855,37 +136475,6 @@ pub mod fields { #[doc = "Represents [`EmptyStmt::span`]"] Span, } - impl EsVersionField { - #[inline(always)] - pub(crate) fn set_index(&mut self, _: usize) { - swc_visit::wrong_ast_path(); - } - } - #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub enum EsVersionField { - #[doc = "Represents [`EsVersion::Es3`]"] - Es3, - #[doc = "Represents [`EsVersion::Es5`]"] - Es5, - #[doc = "Represents [`EsVersion::Es2015`]"] - Es2015, - #[doc = "Represents [`EsVersion::Es2016`]"] - Es2016, - #[doc = "Represents [`EsVersion::Es2017`]"] - Es2017, - #[doc = "Represents [`EsVersion::Es2018`]"] - Es2018, - #[doc = "Represents [`EsVersion::Es2019`]"] - Es2019, - #[doc = "Represents [`EsVersion::Es2020`]"] - Es2020, - #[doc = "Represents [`EsVersion::Es2021`]"] - Es2021, - #[doc = "Represents [`EsVersion::Es2022`]"] - Es2022, - #[doc = "Represents [`EsVersion::EsNext`]"] - EsNext, - } impl ExportAllField { pub(crate) fn set_index(&mut self, index: usize) { match self { @@ -140420,7 +140009,6 @@ pub mod fields { DefaultDecl(DefaultDeclField), DoWhileStmt(DoWhileStmtField), EmptyStmt(EmptyStmtField), - EsVersion(EsVersionField), ExportAll(ExportAllField), ExportDecl(ExportDeclField), ExportDefaultDecl(ExportDefaultDeclField), @@ -140661,7 +140249,6 @@ pub mod fields { Self::DefaultDecl(v) => v.set_index(index), Self::DoWhileStmt(v) => v.set_index(index), Self::EmptyStmt(v) => v.set_index(index), - Self::EsVersion(v) => v.set_index(index), Self::ExportAll(v) => v.set_index(index), Self::ExportDecl(v) => v.set_index(index), Self::ExportDefaultDecl(v) => v.set_index(index), @@ -140902,7 +140489,6 @@ pub mod fields { DefaultDecl(&'ast DefaultDecl, DefaultDeclField), DoWhileStmt(&'ast DoWhileStmt, DoWhileStmtField), EmptyStmt(&'ast EmptyStmt, EmptyStmtField), - EsVersion(&'ast EsVersion, EsVersionField), ExportAll(&'ast ExportAll, ExportAllField), ExportDecl(&'ast ExportDecl, ExportDeclField), ExportDefaultDecl(&'ast ExportDefaultDecl, ExportDefaultDeclField), @@ -141161,7 +140747,6 @@ pub mod fields { Self::DefaultDecl(_, __field_kind) => __field_kind.set_index(index), Self::DoWhileStmt(_, __field_kind) => __field_kind.set_index(index), Self::EmptyStmt(_, __field_kind) => __field_kind.set_index(index), - Self::EsVersion(_, __field_kind) => __field_kind.set_index(index), Self::ExportAll(_, __field_kind) => __field_kind.set_index(index), Self::ExportDecl(_, __field_kind) => __field_kind.set_index(index), Self::ExportDefaultDecl(_, __field_kind) => __field_kind.set_index(index), @@ -141411,7 +140996,6 @@ pub mod fields { Self::DefaultDecl(_, __field_kind) => AstParentKind::DefaultDecl(*__field_kind), Self::DoWhileStmt(_, __field_kind) => AstParentKind::DoWhileStmt(*__field_kind), Self::EmptyStmt(_, __field_kind) => AstParentKind::EmptyStmt(*__field_kind), - Self::EsVersion(_, __field_kind) => AstParentKind::EsVersion(*__field_kind), Self::ExportAll(_, __field_kind) => AstParentKind::ExportAll(*__field_kind), Self::ExportDecl(_, __field_kind) => AstParentKind::ExportDecl(*__field_kind), Self::ExportDefaultDecl(_, __field_kind) => { @@ -141943,11 +141527,6 @@ impl<'ast> From<&'ast EmptyStmt> for NodeRef<'ast> { NodeRef::EmptyStmt(node) } } -impl<'ast> From<&'ast EsVersion> for NodeRef<'ast> { - fn from(node: &'ast EsVersion) -> Self { - NodeRef::EsVersion(node) - } -} impl<'ast> From<&'ast ExportAll> for NodeRef<'ast> { fn from(node: &'ast ExportAll) -> Self { NodeRef::ExportAll(node) @@ -142965,7 +142544,6 @@ pub enum NodeRef<'ast> { DefaultDecl(&'ast DefaultDecl), DoWhileStmt(&'ast DoWhileStmt), EmptyStmt(&'ast EmptyStmt), - EsVersion(&'ast EsVersion), ExportAll(&'ast ExportAll), ExportDecl(&'ast ExportDecl), ExportDefaultDecl(&'ast ExportDefaultDecl), @@ -143595,9 +143173,6 @@ impl<'ast> NodeRef<'ast> { let iterator = ::std::iter::empty::>(); Box::new(iterator) } - NodeRef::EsVersion(node) => match node { - _ => Box::new(::std::iter::empty::>()), - }, NodeRef::ExportAll(node) => { let iterator = ::std::iter::empty::>() .chain({ diff --git a/packages/types/index.ts b/packages/types/index.ts index 1809d867fb77..40a0a40b8478 100644 --- a/packages/types/index.ts +++ b/packages/types/index.ts @@ -714,6 +714,8 @@ export type JscTarget = | "es2020" | "es2021" | "es2022" + | "es2023" + | "es2024" | "esnext"; export type ParserConfig = TsParserConfig | EsParserConfig; diff --git a/packages/types/package.json b/packages/types/package.json index ed83079fea61..3c80665d6ff8 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,7 +1,7 @@ { "name": "@swc/types", "packageManager": "yarn@4.0.2", - "version": "0.1.13", + "version": "0.1.14", "description": "Typings for the swc project.", "sideEffects": false, "scripts": { diff --git a/tools/generate-code/src/main.rs b/tools/generate-code/src/main.rs index f2592babade6..2289359e1631 100644 --- a/tools/generate-code/src/main.rs +++ b/tools/generate-code/src/main.rs @@ -69,7 +69,7 @@ fn run_visitor_codegen(input_dir: &Path, output: &Path, excludes: &[String]) -> let ident = match type_def { Item::Struct(data) => &data.ident, Item::Enum(data) => &data.ident, - _ => return true, + _ => return false, }; !excludes.contains(&ident.to_string()) @@ -115,7 +115,12 @@ fn test_ecmascript() { run_visitor_codegen( Path::new("../../crates/swc_ecma_ast"), Path::new("../../crates/swc_ecma_visit/src/generated.rs"), - &["Align64".into(), "EncodeBigInt".into()], + &[ + "Align64".into(), + "EncodeBigInt".into(), + "EsVersion".into(), + "FnPass".into(), + ], ) .unwrap(); }