From 49fa04a8fdc321893580df6b5f6ed6dc50a2a3f5 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Wed, 9 Oct 2024 11:05:54 -0700 Subject: [PATCH 01/28] Flatten Spans on regex AST nodes --- crates/oxc_regular_expression/src/ast.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/oxc_regular_expression/src/ast.rs b/crates/oxc_regular_expression/src/ast.rs index f843ed2b9fa96..5a2dcfee29cfe 100644 --- a/crates/oxc_regular_expression/src/ast.rs +++ b/crates/oxc_regular_expression/src/ast.rs @@ -15,6 +15,7 @@ use tsify::Tsify; #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct Pattern<'a> { + #[serde(flatten)] pub span: Span, pub body: Disjunction<'a>, } @@ -25,6 +26,7 @@ pub struct Pattern<'a> { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct Disjunction<'a> { + #[serde(flatten)] pub span: Span, pub body: Vec<'a, Alternative<'a>>, } @@ -35,6 +37,7 @@ pub struct Disjunction<'a> { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct Alternative<'a> { + #[serde(flatten)] pub span: Span, pub body: Vec<'a, Term<'a>>, } @@ -111,6 +114,7 @@ pub enum BoundaryAssertionKind { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct LookAroundAssertion<'a> { + #[serde(flatten)] pub span: Span, pub kind: LookAroundAssertionKind, pub body: Disjunction<'a>, @@ -134,6 +138,7 @@ pub enum LookAroundAssertionKind { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct Quantifier<'a> { + #[serde(flatten)] pub span: Span, pub min: u64, /// `None` means no upper bound. @@ -149,6 +154,7 @@ pub struct Quantifier<'a> { #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct Character { /// This will be invalid position when `UnicodeMode` is disabled and `value` is a surrogate pair. + #[serde(flatten)] pub span: Span, pub kind: CharacterKind, /// Unicode code point or UTF-16 code unit. @@ -180,6 +186,7 @@ pub enum CharacterKind { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct CharacterClassEscape { + #[serde(flatten)] pub span: Span, pub kind: CharacterClassEscapeKind, } @@ -204,6 +211,7 @@ pub enum CharacterClassEscapeKind { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct UnicodePropertyEscape<'a> { + #[serde(flatten)] pub span: Span, pub negative: bool, /// `true` if `UnicodeSetsMode` and `name` matches unicode property of strings. @@ -218,6 +226,7 @@ pub struct UnicodePropertyEscape<'a> { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct Dot { + #[serde(flatten)] pub span: Span, } @@ -228,6 +237,7 @@ pub struct Dot { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct CharacterClass<'a> { + #[serde(flatten)] pub span: Span, pub negative: bool, /// `true` if: @@ -286,6 +296,7 @@ impl<'a> GetSpan for CharacterClassContents<'a> { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct CharacterClassRange { + #[serde(flatten)] pub span: Span, pub min: Character, pub max: Character, @@ -297,6 +308,7 @@ pub struct CharacterClassRange { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct ClassStringDisjunction<'a> { + #[serde(flatten)] pub span: Span, /// `true` if body is empty or contains [`ClassString`] which `strings` is `true`. pub strings: bool, @@ -309,6 +321,7 @@ pub struct ClassStringDisjunction<'a> { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct ClassString<'a> { + #[serde(flatten)] pub span: Span, /// `true` if body is empty or contain 2 more characters. pub strings: bool, @@ -322,6 +335,7 @@ pub struct ClassString<'a> { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct CapturingGroup<'a> { + #[serde(flatten)] pub span: Span, /// Group name to be referenced by [`NamedReference`]. pub name: Option>, @@ -335,6 +349,7 @@ pub struct CapturingGroup<'a> { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct IgnoreGroup<'a> { + #[serde(flatten)] pub span: Span, pub enabling_modifiers: Option, pub disabling_modifiers: Option, @@ -360,6 +375,7 @@ pub struct ModifierFlags { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct IndexedReference { + #[serde(flatten)] pub span: Span, pub index: u32, } @@ -371,6 +387,7 @@ pub struct IndexedReference { #[generate_derive(CloneIn, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] pub struct NamedReference<'a> { + #[serde(flatten)] pub span: Span, pub name: Atom<'a>, } From 0515e4371d7d6db3c59d8f8a04e6feef9e666642 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Wed, 9 Oct 2024 16:05:45 -0700 Subject: [PATCH 02/28] create estree derive generator --- .github/.generated_ast_watch_list.yml | 1 + crates/oxc_ast/Cargo.toml | 2 +- crates/oxc_ast_macros/src/ast.rs | 2 + crates/oxc_regular_expression/Cargo.toml | 2 +- crates/oxc_regular_expression/src/ast.rs | 104 ++++---- .../src/generated/derive_serialize.rs | 241 ++++++++++++++++++ crates/oxc_regular_expression/src/lib.rs | 2 + tasks/ast_tools/src/derives/estree.rs | 49 ++++ tasks/ast_tools/src/derives/mod.rs | 10 +- tasks/ast_tools/src/main.rs | 6 +- 10 files changed, 363 insertions(+), 56 deletions(-) create mode 100644 crates/oxc_regular_expression/src/generated/derive_serialize.rs create mode 100644 tasks/ast_tools/src/derives/estree.rs diff --git a/.github/.generated_ast_watch_list.yml b/.github/.generated_ast_watch_list.yml index 818c9ee29d83c..7ad188613b3a7 100644 --- a/.github/.generated_ast_watch_list.yml +++ b/.github/.generated_ast_watch_list.yml @@ -22,6 +22,7 @@ src: - 'crates/oxc_ast/src/generated/derive_content_hash.rs' - 'crates/oxc_regular_expression/src/generated/derive_content_hash.rs' - 'crates/oxc_syntax/src/generated/derive_content_hash.rs' + - 'crates/oxc_regular_expression/src/generated/derive_serialize.rs' - 'crates/oxc_ast/src/generated/assert_layouts.rs' - 'crates/oxc_ast/src/generated/ast_kind.rs' - 'crates/oxc_ast/src/generated/ast_builder.rs' diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 8680c7e2a1325..36a1695650d6c 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -28,7 +28,7 @@ oxc_syntax = { workspace = true } bitflags = { workspace = true } num-bigint = { workspace = true } -serde = { workspace = true, features = ["derive"], optional = true } +serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } tsify = { workspace = true, optional = true } diff --git a/crates/oxc_ast_macros/src/ast.rs b/crates/oxc_ast_macros/src/ast.rs index 083233f874390..454e397f11bc5 100644 --- a/crates/oxc_ast_macros/src/ast.rs +++ b/crates/oxc_ast_macros/src/ast.rs @@ -81,6 +81,8 @@ fn abs_trait( (quote!(::oxc_span::cmp::ContentEq), TokenStream::default()) } else if ident == "ContentHash" { (quote!(::oxc_span::hash::ContentHash), TokenStream::default()) + } else if ident == "Serialize" { + (quote!(::serde::Serialize), TokenStream::default()) } else { invalid_derive(ident) } diff --git a/crates/oxc_regular_expression/Cargo.toml b/crates/oxc_regular_expression/Cargo.toml index 1917f3c2d7b16..16f5f0c94bd09 100644 --- a/crates/oxc_regular_expression/Cargo.toml +++ b/crates/oxc_regular_expression/Cargo.toml @@ -27,7 +27,7 @@ oxc_span = { workspace = true } phf = { workspace = true, features = ["macros"] } rustc-hash = { workspace = true } -serde = { workspace = true, features = ["derive"], optional = true } +serde = { workspace = true, optional = true } unicode-id-start = { workspace = true } tsify = { workspace = true, optional = true } diff --git a/crates/oxc_regular_expression/src/ast.rs b/crates/oxc_regular_expression/src/ast.rs index 5a2dcfee29cfe..f42ec56346e96 100644 --- a/crates/oxc_regular_expression/src/ast.rs +++ b/crates/oxc_regular_expression/src/ast.rs @@ -12,8 +12,8 @@ use tsify::Tsify; /// The root of the `PatternParser` result. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Pattern<'a> { #[serde(flatten)] pub span: Span, @@ -23,8 +23,8 @@ pub struct Pattern<'a> { /// Pile of [`Alternative`]s separated by `|`. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Disjunction<'a> { #[serde(flatten)] pub span: Span, @@ -34,8 +34,8 @@ pub struct Disjunction<'a> { /// Single unit of `|` separated alternatives. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Alternative<'a> { #[serde(flatten)] pub span: Span, @@ -45,8 +45,8 @@ pub struct Alternative<'a> { /// Single unit of [`Alternative`], containing various kinds. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum Term<'a> { // Assertion, QuantifiableAssertion BoundaryAssertion(Box<'a, BoundaryAssertion>) = 0, @@ -89,8 +89,8 @@ impl<'a> GetSpan for Term<'a> { /// e.g. `^`, `$`, `\b`, `\B` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct BoundaryAssertion { pub span: Span, pub kind: BoundaryAssertionKind, @@ -98,8 +98,8 @@ pub struct BoundaryAssertion { #[ast] #[derive(Debug, Clone, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum BoundaryAssertionKind { Start = 0, End = 1, @@ -111,8 +111,8 @@ pub enum BoundaryAssertionKind { /// e.g. `(?=...)`, `(?!...)`, `(?<=...)`, `(? { #[serde(flatten)] pub span: Span, @@ -122,8 +122,8 @@ pub struct LookAroundAssertion<'a> { #[ast] #[derive(Debug, Clone, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum LookAroundAssertionKind { Lookahead = 0, NegativeLookahead = 1, @@ -135,8 +135,8 @@ pub enum LookAroundAssertionKind { /// e.g. `a*`, `b+`, `c?`, `d{3}`, `e{4,}`, `f{5,6}` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Quantifier<'a> { #[serde(flatten)] pub span: Span, @@ -150,8 +150,8 @@ pub struct Quantifier<'a> { /// Single character. #[ast] #[derive(Debug, Clone, Copy)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Character { /// This will be invalid position when `UnicodeMode` is disabled and `value` is a surrogate pair. #[serde(flatten)] @@ -163,8 +163,8 @@ pub struct Character { #[ast] #[derive(Debug, Clone, Copy, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum CharacterKind { ControlLetter = 0, HexadecimalEscape = 1, @@ -183,8 +183,8 @@ pub enum CharacterKind { /// e.g. `\d`, `\D`, `\s`, `\S`, `\w`, `\W` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CharacterClassEscape { #[serde(flatten)] pub span: Span, @@ -193,8 +193,8 @@ pub struct CharacterClassEscape { #[ast] #[derive(Debug, Clone, Copy, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum CharacterClassEscapeKind { D = 0, NegativeD = 1, @@ -208,8 +208,8 @@ pub enum CharacterClassEscapeKind { /// e.g. `\p{ASCII}`, `\P{ASCII}`, `\p{sc=Hiragana}`, `\P{sc=Hiragana}` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct UnicodePropertyEscape<'a> { #[serde(flatten)] pub span: Span, @@ -223,8 +223,8 @@ pub struct UnicodePropertyEscape<'a> { /// The `.`. #[ast] #[derive(Debug, Clone, Copy)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Dot { #[serde(flatten)] pub span: Span, @@ -234,8 +234,8 @@ pub struct Dot { /// e.g. `[a-z]`, `[^A-Z]`, `[abc]`, `[a&&b&&c]`, `[[a-z]--x--y]` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CharacterClass<'a> { #[serde(flatten)] pub span: Span, @@ -250,8 +250,8 @@ pub struct CharacterClass<'a> { #[ast] #[derive(Debug, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum CharacterClassContentsKind { Union = 0, /// `UnicodeSetsMode` only. @@ -262,8 +262,8 @@ pub enum CharacterClassContentsKind { #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum CharacterClassContents<'a> { CharacterClassRange(Box<'a, CharacterClassRange>) = 0, CharacterClassEscape(Box<'a, CharacterClassEscape>) = 1, @@ -293,8 +293,8 @@ impl<'a> GetSpan for CharacterClassContents<'a> { /// e.g. `a-z`, `A-Z`, `0-9` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CharacterClassRange { #[serde(flatten)] pub span: Span, @@ -305,8 +305,8 @@ pub struct CharacterClassRange { /// `|` separated string of characters wrapped by `\q{}`. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ClassStringDisjunction<'a> { #[serde(flatten)] pub span: Span, @@ -318,8 +318,8 @@ pub struct ClassStringDisjunction<'a> { /// Single unit of [`ClassStringDisjunction`]. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ClassString<'a> { #[serde(flatten)] pub span: Span, @@ -332,8 +332,8 @@ pub struct ClassString<'a> { /// e.g. `(...)`, `(?...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CapturingGroup<'a> { #[serde(flatten)] pub span: Span, @@ -346,8 +346,8 @@ pub struct CapturingGroup<'a> { /// e.g. `(?:...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct IgnoreGroup<'a> { #[serde(flatten)] pub span: Span, @@ -360,8 +360,8 @@ pub struct IgnoreGroup<'a> { /// e.g. `(?i:...)`, `(?-s:...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ModifierFlags { pub ignore_case: bool, pub sticky: bool, @@ -372,8 +372,8 @@ pub struct ModifierFlags { /// e.g. `\1`, `\2`, `\3` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct IndexedReference { #[serde(flatten)] pub span: Span, @@ -384,8 +384,8 @@ pub struct IndexedReference { /// e.g. `\k` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct NamedReference<'a> { #[serde(flatten)] pub span: Span, diff --git a/crates/oxc_regular_expression/src/generated/derive_serialize.rs b/crates/oxc_regular_expression/src/generated/derive_serialize.rs new file mode 100644 index 0000000000000..d8861e170e430 --- /dev/null +++ b/crates/oxc_regular_expression/src/generated/derive_serialize.rs @@ -0,0 +1,241 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` + +use serde::{Serialize, Serializer}; + +#[allow(clippy::wildcard_imports)] +use crate::ast::*; + +impl<'a> Serialize for Pattern<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Disjunction<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Alternative<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Term<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for BoundaryAssertion { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for BoundaryAssertionKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for LookAroundAssertion<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for LookAroundAssertionKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Quantifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for Character { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for CharacterKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for CharacterClassEscape { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for CharacterClassEscapeKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for UnicodePropertyEscape<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for Dot { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for CharacterClass<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for CharacterClassContentsKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for CharacterClassContents<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for CharacterClassRange { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ClassStringDisjunction<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ClassString<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for CapturingGroup<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for IgnoreGroup<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for ModifierFlags { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for IndexedReference { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for NamedReference<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} diff --git a/crates/oxc_regular_expression/src/lib.rs b/crates/oxc_regular_expression/src/lib.rs index c7c42f290537c..509b3c33c3d14 100644 --- a/crates/oxc_regular_expression/src/lib.rs +++ b/crates/oxc_regular_expression/src/lib.rs @@ -10,6 +10,8 @@ mod generated { mod derive_clone_in; mod derive_content_eq; mod derive_content_hash; + #[cfg(feature = "serialize")] + mod derive_serialize; } pub mod ast; diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs new file mode 100644 index 0000000000000..755cbe9d40a94 --- /dev/null +++ b/tasks/ast_tools/src/derives/estree.rs @@ -0,0 +1,49 @@ +use proc_macro2::TokenStream; +use quote::quote; + +use super::{define_derive, Derive, DeriveOutput}; +use crate::{ + codegen::LateCtx, + schema::{GetGenerics, GetIdent, TypeDef}, +}; + +define_derive! { + pub struct DeriveESTree; +} + +impl Derive for DeriveESTree { + fn trait_name() -> &'static str { + "Serialize" + } + + fn derive(&mut self, def: &TypeDef, _: &LateCtx) -> TokenStream { + let ident = def.ident(); + if def.has_lifetime() { + quote! { + impl<'a> Serialize for #ident<'a> { + fn serialize(&self, serializer: S) -> Result + where S: Serializer, + { + serializer.serialize_none() + } + } + } + } else { + quote! { + impl Serialize for #ident { + fn serialize(&self, serializer: S) -> Result + where S: Serializer, + { + serializer.serialize_none() + } + } + } + } + } + + fn prelude() -> TokenStream { + quote! { + use serde::{Serialize, Serializer}; + } + } +} diff --git a/tasks/ast_tools/src/derives/mod.rs b/tasks/ast_tools/src/derives/mod.rs index f6617b34cc399..8a809ef1802b0 100644 --- a/tasks/ast_tools/src/derives/mod.rs +++ b/tasks/ast_tools/src/derives/mod.rs @@ -7,11 +7,13 @@ use crate::{codegen::LateCtx, schema::TypeDef}; mod clone_in; mod content_eq; mod content_hash; +mod estree; mod get_span; pub use clone_in::DeriveCloneIn; pub use content_eq::DeriveContentEq; pub use content_hash::DeriveContentHash; +pub use estree::DeriveESTree; pub use get_span::{DeriveGetSpan, DeriveGetSpanMut}; pub trait Derive { @@ -106,10 +108,16 @@ macro_rules! define_derive { .fold(Vec::new(), |mut acc, (path, (modules, streams))| { let mut modules = Vec::from_iter(modules); modules.sort(); + let file_name = Self::trait_name().to_case(Case::Snake); + let file_name = match file_name.as_str() { + "es_tree" => "estree", + f => f, + }; + acc.push(( $crate::output( format!("crates/{}", path.split("::").next().unwrap()).as_str(), - format!("derive_{}.rs", Self::trait_name().to_case(Case::Snake)).as_str() + format!("derive_{}.rs", file_name).as_str() ), Self::template( modules, diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index 6e8dcf94ed346..8a5dd4b0eab48 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -17,7 +17,10 @@ mod rust_ast; mod schema; mod util; -use derives::{DeriveCloneIn, DeriveContentEq, DeriveContentHash, DeriveGetSpan, DeriveGetSpanMut}; +use derives::{ + DeriveCloneIn, DeriveContentEq, DeriveContentHash, DeriveESTree, DeriveGetSpan, + DeriveGetSpanMut, +}; use fmt::cargo_fmt; use generators::{ AssertLayouts, AstBuilderGenerator, AstKindGenerator, Generator, GeneratorOutput, @@ -74,6 +77,7 @@ fn main() -> std::result::Result<(), Box> { .derive(DeriveGetSpanMut) .derive(DeriveContentEq) .derive(DeriveContentHash) + .derive(DeriveESTree) .generate(AssertLayouts) .generate(AstKindGenerator) .generate(AstBuilderGenerator) From 149e86ea39809cb368c38be2219d18600788e1d2 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 10 Oct 2024 11:51:23 -0700 Subject: [PATCH 03/28] begin parse #[serde(...)] attributes --- tasks/ast_tools/src/derives/estree.rs | 5 ++ tasks/ast_tools/src/markers.rs | 96 ++++++++++++++++++++++++++- tasks/ast_tools/src/schema/defs.rs | 3 +- tasks/ast_tools/src/schema/mod.rs | 10 ++- 4 files changed, 109 insertions(+), 5 deletions(-) diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index 755cbe9d40a94..beece941b586d 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -18,6 +18,11 @@ impl Derive for DeriveESTree { fn derive(&mut self, def: &TypeDef, _: &LateCtx) -> TokenStream { let ident = def.ident(); + if let TypeDef::Struct(it) = def { + for field in &it.fields { + println!("{:?}: {:?}", field.name, field.markers.derive_attributes.estree); + } + } if def.has_lifetime() { quote! { impl<'a> Serialize for #ident<'a> { diff --git a/tasks/ast_tools/src/markers.rs b/tasks/ast_tools/src/markers.rs index 7d634c8bd8a00..468c22262d6cc 100644 --- a/tasks/ast_tools/src/markers.rs +++ b/tasks/ast_tools/src/markers.rs @@ -7,11 +7,13 @@ use syn::{ parse2, punctuated::Punctuated, spanned::Spanned, - token, Attribute, Expr, Ident, Meta, MetaNameValue, Token, + token, Attribute, Expr, Ident, LitStr, Meta, MetaNameValue, Token, }; use crate::util::NormalizeError; +const ESTREE_ATTR: &str = "serde"; + /// A single visit argument passed via `#[visit(args(...))]` #[derive(Debug, Clone)] pub struct VisitArg { @@ -74,6 +76,7 @@ pub struct ScopeMarkers { #[derive(Debug, Default, Serialize)] pub struct DeriveAttributes { pub clone_in: CloneInAttribute, + pub estree: Vec, } /// A enum representing the value passed in `#[clone_in(...)]` derive helper attribute. @@ -94,6 +97,58 @@ impl From<&Ident> for CloneInAttribute { } } +/// A struct representing the serde attributes (`$[serde(...)]`) that we implement for structs and enums. +#[derive(Debug, Serialize)] +pub enum ESTreeOuterAttribute { + Tag(String), + Rename(String), + RenameAll(String), + Untagged, +} + +impl Parse for ESTreeOuterAttribute { + fn parse(input: ParseStream) -> Result { + let ident = input.call(Ident::parse_any).unwrap().to_string(); + Ok(match ident.as_str() { + "tag" => { + input.parse::()?; + let tag = input.parse::()?.value(); + Self::Tag(tag) + } + "rename" => { + input.parse::()?; + let rename = input.parse::()?.value(); + Self::Rename(rename) + } + "rename_all" => { + input.parse::()?; + let rename = input.parse::()?.value(); + Self::RenameAll(rename) + } + "untagged" => Self::Untagged, + arg => panic!("Unsupported #[{ESTREE_ATTR}(...)] argument: {arg}"), + }) + } +} + +/// A struct representing the serde attributes (`$[serde(...)]`) that we implement for fields. +#[derive(Debug, Serialize)] +pub enum ESTreeFieldAttribute { + Flatten, + Skip, +} + +impl Parse for ESTreeFieldAttribute { + fn parse(input: ParseStream) -> Result { + let ident = input.call(Ident::parse_any).unwrap().to_string(); + Ok(match ident.as_str() { + "flatten" => Self::Flatten, + "skip" => Self::Skip, + arg => panic!("Unsupported #[{ESTREE_ATTR}(...)] argument: {arg}"), + }) + } +} + /// A struct representing the `#[scope(...)]` attribute. #[derive(Debug, Default)] pub struct ScopeAttribute { @@ -228,13 +283,32 @@ where Ok(None) } } + fn try_parse_estree(attr: &Attribute) -> crate::Result>> { + if attr.path().is_ident(ESTREE_ATTR) { + let args = attr + .parse_args_with(Punctuated::::parse_terminated) + .normalize()? + .into_iter() + .collect(); + Ok(Some(args)) + } else { + Ok(None) + } + } let mut clone_in = None; + let mut estree = None; for attr in attrs { if let Some(attr) = try_parse_clone_in(attr)? { assert!(clone_in.replace(attr).is_none(), "Duplicate `#[clone_in(...)]` attribute."); } + if let Some(attr) = try_parse_estree(attr)? { + assert!(estree.replace(attr).is_none(), "Duplicate `#[{ESTREE_ATTR}(...)]` attribute."); + } } - Ok(DeriveAttributes { clone_in: clone_in.unwrap_or_default() }) + Ok(DeriveAttributes { + clone_in: clone_in.unwrap_or_default(), + estree: estree.unwrap_or_default(), + }) } pub fn get_scope_attribute<'a, I>(attrs: I) -> Option> @@ -254,3 +328,21 @@ where result.normalize() }) } + +pub fn get_estree_attribute<'a, I>(attrs: I) -> Option>> +where + I: IntoIterator, +{ + let attr = attrs.into_iter().find(|it| it.path().is_ident(ESTREE_ATTR)); + attr.map(|attr| { + debug_assert!(attr.path().is_ident("scope")); + let result = if matches!(attr.meta, Meta::Path(_)) { + // empty `#[scope]`. + Ok(ScopeAttribute::default()) + } else { + attr.parse_args_with(ScopeAttribute::parse) + }; + + result.normalize() + }) +} diff --git a/tasks/ast_tools/src/schema/defs.rs b/tasks/ast_tools/src/schema/defs.rs index 4625599165477..512713e87b489 100644 --- a/tasks/ast_tools/src/schema/defs.rs +++ b/tasks/ast_tools/src/schema/defs.rs @@ -2,7 +2,7 @@ use serde::Serialize; use super::{with_either, TypeName}; use crate::{ - markers::{DeriveAttributes, ScopeAttribute, ScopeMarkers, VisitMarkers}, + markers::{DeriveAttributes, ESTreeOuterAttribute, ScopeAttribute, ScopeMarkers, VisitMarkers}, util::{ToIdent, TypeAnalysis, TypeWrapper}, TypeId, }; @@ -228,6 +228,7 @@ impl TypeRef { #[derive(Debug)] pub struct OuterMarkers { pub scope: Option, + pub estree: Vec, } #[derive(Debug, Serialize)] diff --git a/tasks/ast_tools/src/schema/mod.rs b/tasks/ast_tools/src/schema/mod.rs index 67e005326f318..5afa37e2b62ae 100644 --- a/tasks/ast_tools/src/schema/mod.rs +++ b/tasks/ast_tools/src/schema/mod.rs @@ -5,7 +5,10 @@ use serde::Serialize; use crate::{ codegen, layout::KnownLayout, - markers::{get_derive_attributes, get_scope_attribute, get_scope_markers, get_visit_markers}, + markers::{ + get_derive_attributes, get_estree_attribute, get_scope_attribute, get_scope_markers, + get_visit_markers, + }, rust_ast as rust, util::{unexpanded_macro_err, TypeExt}, Result, TypeId, @@ -104,7 +107,10 @@ impl<'a> IntoIterator for &'a Schema { } fn parse_outer_markers(attrs: &Vec) -> Result { - Ok(OuterMarkers { scope: get_scope_attribute(attrs).transpose()? }) + Ok(OuterMarkers { + scope: get_scope_attribute(attrs).transpose()?, + estree: get_estree_attribute(attrs).transpose()?, + }) } fn parse_inner_markers(attrs: &Vec) -> Result { From 9e2266b2d08b5ec67b76e1d3d853c3b519648b8c Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 10 Oct 2024 13:26:15 -0700 Subject: [PATCH 04/28] generate_derive on EVERYTHING --- .github/.generated_ast_watch_list.yml | 5 +- Cargo.lock | 8 + Cargo.toml | 1 + crates/oxc_ast/Cargo.toml | 19 +- crates/oxc_ast/src/ast/js.rs | 944 ++++--- crates/oxc_ast/src/ast/jsx.rs | 157 +- crates/oxc_ast/src/ast/literal.rs | 67 +- crates/oxc_ast/src/ast/ts.rs | 704 +++--- crates/oxc_ast/src/generated/derive_estree.rs | 2158 +++++++++++++++++ crates/oxc_ast/src/lib.rs | 2 + crates/oxc_ast_macros/src/ast.rs | 4 +- crates/oxc_ast_macros/src/lib.rs | 2 +- crates/oxc_estree/Cargo.toml | 17 + crates/oxc_estree/src/lib.rs | 1 + crates/oxc_regular_expression/Cargo.toml | 9 +- crates/oxc_regular_expression/src/ast.rs | 113 +- .../{derive_serialize.rs => derive_estree.rs} | 0 crates/oxc_regular_expression/src/lib.rs | 2 +- crates/oxc_span/Cargo.toml | 1 + .../oxc_span/src/generated/derive_estree.rs | 44 + crates/oxc_span/src/source_type/mod.rs | 25 +- crates/oxc_syntax/Cargo.toml | 1 + .../oxc_syntax/src/generated/derive_estree.rs | 53 + crates/oxc_syntax/src/lib.rs | 2 + crates/oxc_syntax/src/operator.rs | 123 +- tasks/ast_tools/src/derives/estree.rs | 33 +- tasks/ast_tools/src/derives/mod.rs | 3 +- tasks/ast_tools/src/markers.rs | 160 +- tasks/ast_tools/src/schema/defs.rs | 4 +- tasks/ast_tools/src/schema/mod.rs | 3 +- 30 files changed, 3529 insertions(+), 1136 deletions(-) create mode 100644 crates/oxc_ast/src/generated/derive_estree.rs create mode 100644 crates/oxc_estree/Cargo.toml create mode 100644 crates/oxc_estree/src/lib.rs rename crates/oxc_regular_expression/src/generated/{derive_serialize.rs => derive_estree.rs} (100%) create mode 100644 crates/oxc_span/src/generated/derive_estree.rs create mode 100644 crates/oxc_syntax/src/generated/derive_estree.rs diff --git a/.github/.generated_ast_watch_list.yml b/.github/.generated_ast_watch_list.yml index 7ad188613b3a7..6b6d63d255f0e 100644 --- a/.github/.generated_ast_watch_list.yml +++ b/.github/.generated_ast_watch_list.yml @@ -22,7 +22,10 @@ src: - 'crates/oxc_ast/src/generated/derive_content_hash.rs' - 'crates/oxc_regular_expression/src/generated/derive_content_hash.rs' - 'crates/oxc_syntax/src/generated/derive_content_hash.rs' - - 'crates/oxc_regular_expression/src/generated/derive_serialize.rs' + - 'crates/oxc_ast/src/generated/derive_estree.rs' + - 'crates/oxc_regular_expression/src/generated/derive_estree.rs' + - 'crates/oxc_span/src/generated/derive_estree.rs' + - 'crates/oxc_syntax/src/generated/derive_estree.rs' - 'crates/oxc_ast/src/generated/assert_layouts.rs' - 'crates/oxc_ast/src/generated/ast_kind.rs' - 'crates/oxc_ast/src/generated/ast_builder.rs' diff --git a/Cargo.lock b/Cargo.lock index c0b74cd1eaf27..79b8d45cb695e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1462,6 +1462,7 @@ dependencies = [ "num-bigint", "oxc_allocator", "oxc_ast_macros", + "oxc_estree", "oxc_regular_expression", "oxc_span", "oxc_syntax", @@ -1599,6 +1600,10 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "oxc_estree" +version = "0.31.0" + [[package]] name = "oxc_index" version = "0.31.0" @@ -1859,6 +1864,7 @@ dependencies = [ "oxc_allocator", "oxc_ast_macros", "oxc_diagnostics", + "oxc_estree", "oxc_span", "phf 0.11.2", "rustc-hash", @@ -1934,6 +1940,7 @@ dependencies = [ "miette", "oxc_allocator", "oxc_ast_macros", + "oxc_estree", "schemars", "serde", "tsify", @@ -1950,6 +1957,7 @@ dependencies = [ "nonmax", "oxc_allocator", "oxc_ast_macros", + "oxc_estree", "oxc_index", "oxc_span", "phf 0.11.2", diff --git a/Cargo.toml b/Cargo.toml index ef2bd3aecdd31..48893b58effb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,6 +84,7 @@ oxc_cfg = { version = "0.31.0", path = "crates/oxc_cfg" } oxc_codegen = { version = "0.31.0", path = "crates/oxc_codegen" } oxc_data_structures = { version = "0.31.0", path = "crates/oxc_data_structures" } oxc_diagnostics = { version = "0.31.0", path = "crates/oxc_diagnostics" } +oxc_estree = { version = "0.31.0", path = "crates/oxc_estree" } oxc_index = { version = "0.31.0", path = "crates/oxc_index" } oxc_isolated_declarations = { version = "0.31.0", path = "crates/oxc_isolated_declarations" } oxc_mangler = { version = "0.31.0", path = "crates/oxc_mangler" } diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 36a1695650d6c..3fcfc8dda24b0 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -21,6 +21,7 @@ doctest = false [dependencies] oxc_allocator = { workspace = true } oxc_ast_macros = { workspace = true } +oxc_estree = { workspace = true } oxc_regular_expression = { workspace = true } oxc_span = { workspace = true } oxc_syntax = { workspace = true } @@ -37,13 +38,13 @@ wasm-bindgen = { workspace = true, optional = true } [features] default = [] serialize = [ - "dep:serde", - "dep:serde_json", - "dep:tsify", - "dep:wasm-bindgen", - "oxc_allocator/serialize", - "oxc_regular_expression/serialize", - "oxc_span/serialize", - "oxc_syntax/serialize", - "oxc_syntax/to_js_string", + "dep:serde", + "dep:serde_json", + "dep:tsify", + "dep:wasm-bindgen", + "oxc_allocator/serialize", + "oxc_regular_expression/serialize", + "oxc_span/serialize", + "oxc_syntax/serialize", + "oxc_syntax/to_js_string", ] diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index e06d43eb38e4a..5c4d06001fc7d 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -9,6 +9,7 @@ use std::cell::Cell; use oxc_allocator::{Box, CloneIn, Vec}; use oxc_ast_macros::ast; +use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, SourceType, Span}; use oxc_syntax::{ operator::{ @@ -19,8 +20,6 @@ use oxc_syntax::{ symbol::SymbolId, }; #[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] use tsify::Tsify; use super::{macros::inherit_variants, *}; @@ -32,17 +31,17 @@ use super::{macros::inherit_variants, *}; strict_if(self.source_type.is_strict() || self.directives.iter().any(Directive::is_use_strict)), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct Program<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub source_type: SourceType, pub hashbang: Option>, pub directives: Vec<'a, Directive<'a>>, pub body: Vec<'a, Statement<'a>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -55,9 +54,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum Expression<'a> { /// See [`BooleanLiteral`] for AST node details. BooleanLiteral(Box<'a, BooleanLiteral>) = 0, @@ -205,11 +204,10 @@ pub use match_expression; /// Fundamental syntactic structure used for naming variables, functions, and properties. It must start with a Unicode letter (including $ and _) and can be followed by Unicode letters, digits, $, or _. #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[serde(tag = "type", rename = "Identifier")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(tag = "type", rename = "Identifier")] pub struct IdentifierName<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, } @@ -221,11 +219,10 @@ pub struct IdentifierName<'a> { /// See: [13.1 Identifiers](https://tc39.es/ecma262/#sec-identifiers) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[serde(tag = "type", rename = "Identifier")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(tag = "type", rename = "Identifier")] pub struct IdentifierReference<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the identifier being referenced. pub name: Atom<'a>, @@ -234,7 +231,7 @@ pub struct IdentifierReference<'a> { /// Identifies what identifier this refers to, and how it is used. This is /// set in the bind step of semantic analysis, and will always be [`None`] /// immediately after parsing. - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub reference_id: Cell>, } @@ -246,11 +243,10 @@ pub struct IdentifierReference<'a> { /// See: [13.1 Identifiers](https://tc39.es/ecma262/#sec-identifiers) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[serde(tag = "type", rename = "Identifier")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(tag = "type", rename = "Identifier")] pub struct BindingIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The identifier name being bound. pub name: Atom<'a>, @@ -260,7 +256,7 @@ pub struct BindingIdentifier<'a> { /// you choose to skip semantic analysis, this will always be [`None`]. /// /// [`semantic analysis`]: - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub symbol_id: Cell>, } @@ -272,11 +268,10 @@ pub struct BindingIdentifier<'a> { /// See: [13.1 Identifiers](https://tc39.es/ecma262/#sec-identifiers) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[serde(tag = "type", rename = "Identifier")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(tag = "type", rename = "Identifier")] pub struct LabelIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, } @@ -286,11 +281,11 @@ pub struct LabelIdentifier<'a> { /// Represents a `this` expression, which is a reference to the current object. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ThisExpression { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -299,17 +294,17 @@ pub struct ThisExpression { /// Represents an array literal, which can include elements, spread elements, or null values. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct ArrayExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, #[tsify(type = "Array")] pub elements: Vec<'a, ArrayExpressionElement<'a>>, /// Array trailing comma /// - #[serde(skip)] + #[estree(skip)] pub trailing_comma: Option, } @@ -321,9 +316,8 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(untagged)] pub enum ArrayExpressionElement<'a> { /// `...[3, 4]` in `const array = [1, 2, ...[3, 4], null];` SpreadElement(Box<'a, SpreadElement<'a>>) = 64, @@ -353,24 +347,24 @@ pub struct Elision { /// Represents an object literal, which can include properties, spread properties, or computed properties and trailing comma. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ObjectExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Properties declared in the object pub properties: Vec<'a, ObjectPropertyKind<'a>>, - #[serde(skip)] + #[estree(skip)] pub trailing_comma: Option, } /// Represents a property in an object literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ObjectPropertyKind<'a> { /// `a: 1` in `const obj = { a: 1 };` ObjectProperty(Box<'a, ObjectProperty<'a>>) = 0, @@ -383,11 +377,11 @@ pub enum ObjectPropertyKind<'a> { /// Represents a property in an object literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ObjectProperty<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: PropertyKind, pub key: PropertyKey<'a>, @@ -406,9 +400,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum PropertyKey<'a> { /// `a` in `const obj = { a: 1 }; obj.a;` StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64, @@ -422,9 +416,9 @@ pub enum PropertyKey<'a> { /// Represents the kind of property in an object literal or class. #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum PropertyKind { /// `a: 1` in `const obj = { a: 1 };` Init = 0, @@ -439,11 +433,11 @@ pub enum PropertyKind { /// Represents a template literal, which can include quasi elements and expression elements. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TemplateLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub quasis: Vec<'a, TemplateElement<'a>>, pub expressions: Vec<'a, Expression<'a>>, @@ -454,11 +448,11 @@ pub struct TemplateLiteral<'a> { /// Represents a tagged template expression, which can include a tag and a quasi. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TaggedTemplateExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub tag: Expression<'a>, pub quasi: TemplateLiteral<'a>, @@ -470,11 +464,11 @@ pub struct TaggedTemplateExpression<'a> { /// Represents a quasi element in a template literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TemplateElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub tail: bool, pub value: TemplateElementValue<'a>, @@ -483,8 +477,8 @@ pub struct TemplateElement<'a> { /// See [template-strings-cooked-vs-raw](https://exploringjs.com/js/book/ch_template-literals.html#template-strings-cooked-vs-raw) #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TemplateElementValue<'a> { /// A raw interpretation where backslashes do not have special meaning. /// For example, \t produces two characters – a backslash and a t. @@ -502,9 +496,9 @@ pub struct TemplateElementValue<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum MemberExpression<'a> { /// `ar[0]` in `const ar = [1, 2]; ar[0];` ComputedMemberExpression(Box<'a, ComputedMemberExpression<'a>>) = 48, @@ -530,11 +524,11 @@ pub use match_member_expression; /// Represents a computed member access expression, which can include an object and an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ComputedMemberExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object: Expression<'a>, pub expression: Expression<'a>, @@ -546,11 +540,11 @@ pub struct ComputedMemberExpression<'a> { /// Represents a static member access expression, which can include an object and a property. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct StaticMemberExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object: Expression<'a>, pub property: IdentifierName<'a>, @@ -562,11 +556,11 @@ pub struct StaticMemberExpression<'a> { /// Represents a private field access expression, which can include an object and a private identifier. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct PrivateFieldExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object: Expression<'a>, pub field: PrivateIdentifier<'a>, @@ -591,11 +585,11 @@ pub struct PrivateFieldExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct CallExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub callee: Expression<'a>, pub type_parameters: Option>>, @@ -617,11 +611,11 @@ pub struct CallExpression<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct NewExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub callee: Expression<'a>, pub arguments: Vec<'a, Argument<'a>>, @@ -633,11 +627,11 @@ pub struct NewExpression<'a> { /// Represents a meta property. The following syntaxes are supported. `import.meta`, `new.target`. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct MetaProperty<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub meta: IdentifierName<'a>, pub property: IdentifierName<'a>, @@ -648,11 +642,11 @@ pub struct MetaProperty<'a> { /// Represents a spread element, which can include an argument. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct SpreadElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The expression being spread. pub argument: Expression<'a>, @@ -666,9 +660,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum Argument<'a> { /// `...[1, 2]` in `const arr = [...[1, 2]];` SpreadElement(Box<'a, SpreadElement<'a>>) = 64, @@ -682,11 +676,11 @@ pub enum Argument<'a> { /// Represents an update expression, which can include an operator and an argument. The following syntaxes are supported. `++a`, `a++`, `--a`, `a--` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct UpdateExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub operator: UpdateOperator, pub prefix: bool, @@ -698,11 +692,11 @@ pub struct UpdateExpression<'a> { /// Represents a unary expression, which can include an operator and an argument. The following syntaxes are supported. `+a`, `-a`, `~a`, `!a`, `delete a`, `void a`, `typeof a` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct UnaryExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub operator: UnaryOperator, pub argument: Expression<'a>, @@ -713,11 +707,11 @@ pub struct UnaryExpression<'a> { /// Represents a binary expression, which can include a left expression, an operator, and a right expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct BinaryExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: Expression<'a>, pub operator: BinaryOperator, @@ -729,11 +723,11 @@ pub struct BinaryExpression<'a> { /// Represents a private in expression, which can include a private identifier, an operator, and a expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct PrivateInExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: PrivateIdentifier<'a>, pub operator: BinaryOperator, // BinaryOperator::In @@ -745,11 +739,11 @@ pub struct PrivateInExpression<'a> { /// Represents a logical expression, which can include a left expression, an operator, and a right expression. The following syntaxes are supported. `||`, `&&` and `??` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct LogicalExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: Expression<'a>, pub operator: LogicalOperator, @@ -761,11 +755,11 @@ pub struct LogicalExpression<'a> { /// Represents a conditional expression, which can include a test, a consequent, and an alternate. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ConditionalExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub test: Expression<'a>, pub consequent: Expression<'a>, @@ -777,11 +771,11 @@ pub struct ConditionalExpression<'a> { /// Represents an assignment expression, which can include an operator, a target, and a expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct AssignmentExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub operator: AssignmentOperator, pub left: AssignmentTarget<'a>, @@ -797,9 +791,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum AssignmentTarget<'a> { // `SimpleAssignmentTarget` variants added here by `inherit_variants!` macro @inherit SimpleAssignmentTarget @@ -816,9 +810,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum SimpleAssignmentTarget<'a> { AssignmentTargetIdentifier(Box<'a, IdentifierReference<'a>>) = 0, TSAsExpression(Box<'a, TSAsExpression<'a>>) = 1, @@ -871,9 +865,9 @@ pub use match_simple_assignment_target; #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum AssignmentTargetPattern<'a> { ArrayAssignmentTarget(Box<'a, ArrayAssignmentTarget<'a>>) = 8, ObjectAssignmentTarget(Box<'a, ObjectAssignmentTarget<'a>>) = 9, @@ -895,15 +889,15 @@ pub use match_assignment_target_pattern; #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[serde(tag = "type")] +#[estree(tag = "type")] pub struct ArrayAssignmentTarget<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, #[tsify(type = "Array")] pub elements: Vec<'a, Option>>, - #[serde(skip)] + #[estree(skip)] pub rest: Option>, - #[serde(skip)] + #[estree(skip)] pub trailing_comma: Option, } @@ -914,13 +908,13 @@ pub struct ArrayAssignmentTarget<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[serde(tag = "type")] +#[estree(tag = "type")] pub struct ObjectAssignmentTarget<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, #[tsify(type = "Array")] pub properties: Vec<'a, AssignmentTargetProperty<'a>>, - #[serde(skip)] + #[estree(skip)] pub rest: Option>, } @@ -929,13 +923,12 @@ pub struct ObjectAssignmentTarget<'a> { /// Represents a rest element in an array assignment target, which can include a target. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[serde(tag = "type", rename = "RestElement")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(tag = "type", rename = "RestElement")] pub struct AssignmentTargetRest<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, - #[serde(rename = "argument")] + #[estree(rename = "argument")] pub target: AssignmentTarget<'a>, } @@ -947,9 +940,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum AssignmentTargetMaybeDefault<'a> { AssignmentTargetWithDefault(Box<'a, AssignmentTargetWithDefault<'a>>) = 16, // `AssignmentTarget` variants added here by `inherit_variants!` macro @@ -959,11 +952,11 @@ pub enum AssignmentTargetMaybeDefault<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct AssignmentTargetWithDefault<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub binding: AssignmentTarget<'a>, pub init: Expression<'a>, @@ -971,9 +964,9 @@ pub struct AssignmentTargetWithDefault<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum AssignmentTargetProperty<'a> { AssignmentTargetPropertyIdentifier(Box<'a, AssignmentTargetPropertyIdentifier<'a>>) = 0, AssignmentTargetPropertyProperty(Box<'a, AssignmentTargetPropertyProperty<'a>>) = 1, @@ -984,11 +977,11 @@ pub enum AssignmentTargetProperty<'a> { /// Represents an assignment target property identifier, which can include a binding and an init expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct AssignmentTargetPropertyIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub binding: IdentifierReference<'a>, pub init: Option>, @@ -999,11 +992,11 @@ pub struct AssignmentTargetPropertyIdentifier<'a> { /// Represents an assignment target property property, which can include a name and a binding. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct AssignmentTargetPropertyProperty<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: PropertyKey<'a>, pub binding: AssignmentTargetMaybeDefault<'a>, @@ -1014,11 +1007,11 @@ pub struct AssignmentTargetPropertyProperty<'a> { /// Represents a sequence expression, which can include expressions. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct SequenceExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expressions: Vec<'a, Expression<'a>>, } @@ -1028,11 +1021,11 @@ pub struct SequenceExpression<'a> { /// Represents a super expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Super { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -1041,11 +1034,11 @@ pub struct Super { /// Represents an await expression, which can include an argument. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct AwaitExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub argument: Expression<'a>, } @@ -1055,11 +1048,11 @@ pub struct AwaitExpression<'a> { /// Represents a chain expression, which can include an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ChainExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: ChainElement<'a>, } @@ -1072,9 +1065,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ChainElement<'a> { CallExpression(Box<'a, CallExpression<'a>>) = 0, // `MemberExpression` variants added here by `inherit_variants!` macro @@ -1087,11 +1080,11 @@ pub enum ChainElement<'a> { /// Represents a parenthesized expression, which can include an expression. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ParenthesizedExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1105,9 +1098,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum Statement<'a> { // Statements BlockStatement(Box<'a, BlockStatement<'a>>) = 0, @@ -1140,11 +1133,11 @@ pub enum Statement<'a> { /// Represents a directive statement, which can include a string literal. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Directive<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Directive with any escapes unescaped pub expression: StringLiteral<'a>, @@ -1157,11 +1150,11 @@ pub struct Directive<'a> { /// Represents a hashbang directive, which can include a value. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Hashbang<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub value: Atom<'a>, } @@ -1172,14 +1165,14 @@ pub struct Hashbang<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct BlockStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, Statement<'a>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1187,9 +1180,9 @@ pub struct BlockStatement<'a> { /// Declarations and the Variable Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum Declaration<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32, #[visit(args(flags = ScopeFlags::Function))] @@ -1224,11 +1217,11 @@ pub use match_declaration; /// Represents a variable declaration, which can include a kind, declarations, and modifiers. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct VariableDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: VariableDeclarationKind, pub declarations: Vec<'a, VariableDeclarator<'a>>, @@ -1237,15 +1230,15 @@ pub struct VariableDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum VariableDeclarationKind { Var = 0, Const = 1, Let = 2, Using = 3, - #[serde(rename = "await using")] + #[estree(rename = "await using")] AwaitUsing = 4, } @@ -1259,13 +1252,13 @@ pub enum VariableDeclarationKind { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct VariableDeclarator<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, - #[serde(skip)] + #[estree(skip)] pub kind: VariableDeclarationKind, pub id: BindingPattern<'a>, pub init: Option>, @@ -1275,22 +1268,22 @@ pub struct VariableDeclarator<'a> { /// Empty Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct EmptyStatement { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } /// Expression Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ExpressionStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1298,11 +1291,11 @@ pub struct ExpressionStatement<'a> { /// If Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct IfStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub test: Expression<'a>, pub consequent: Statement<'a>, @@ -1312,11 +1305,11 @@ pub struct IfStatement<'a> { /// Do-While Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct DoWhileStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Statement<'a>, pub test: Expression<'a>, @@ -1325,11 +1318,11 @@ pub struct DoWhileStatement<'a> { /// While Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct WhileStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub test: Expression<'a>, pub body: Statement<'a>, @@ -1339,17 +1332,17 @@ pub struct WhileStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ForStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub init: Option>, pub test: Option>, pub update: Option>, pub body: Statement<'a>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1362,9 +1355,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ForStatementInit<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 64, // `Expression` variants added here by `inherit_variants!` macro @@ -1376,16 +1369,16 @@ pub enum ForStatementInit<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ForInStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: ForStatementLeft<'a>, pub right: Expression<'a>, pub body: Statement<'a>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1398,9 +1391,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ForStatementLeft<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 16, // `AssignmentTarget` variants added here by `inherit_variants!` macro @@ -1411,17 +1404,17 @@ pub enum ForStatementLeft<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ForOfStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub r#await: bool, pub left: ForStatementLeft<'a>, pub right: Expression<'a>, pub body: Statement<'a>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1429,11 +1422,11 @@ pub struct ForOfStatement<'a> { /// Continue Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ContinueStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub label: Option>, } @@ -1441,11 +1434,11 @@ pub struct ContinueStatement<'a> { /// Break Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct BreakStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub label: Option>, } @@ -1453,11 +1446,11 @@ pub struct BreakStatement<'a> { /// Return Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ReturnStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub argument: Option>, } @@ -1465,11 +1458,11 @@ pub struct ReturnStatement<'a> { /// With Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct WithStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object: Expression<'a>, pub body: Statement<'a>, @@ -1479,27 +1472,27 @@ pub struct WithStatement<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct SwitchStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub discriminant: Expression<'a>, #[scope(enter_before)] pub cases: Vec<'a, SwitchCase<'a>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct SwitchCase<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub test: Option>, pub consequent: Vec<'a, Statement<'a>>, @@ -1508,11 +1501,11 @@ pub struct SwitchCase<'a> { /// Labelled Statement #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct LabeledStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub label: LabelIdentifier<'a>, pub body: Statement<'a>, @@ -1527,11 +1520,11 @@ pub struct LabeledStatement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ThrowStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The expression being thrown, e.g. `err` in `throw err;` pub argument: Expression<'a>, @@ -1554,11 +1547,11 @@ pub struct ThrowStatement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TryStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Statements in the `try` block pub block: Box<'a, BlockStatement<'a>>, @@ -1584,17 +1577,17 @@ pub struct TryStatement<'a> { #[ast(visit)] #[scope(flags(ScopeFlags::CatchClause))] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct CatchClause<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The caught error parameter, e.g. `e` in `catch (e) {}` pub param: Option>, /// The statements run when an error is caught pub body: Box<'a, BlockStatement<'a>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1614,11 +1607,11 @@ pub struct CatchClause<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct CatchParameter<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The bound error pub pattern: BindingPattern<'a>, @@ -1633,11 +1626,11 @@ pub struct CatchParameter<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct DebuggerStatement { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -1645,12 +1638,12 @@ pub struct DebuggerStatement { /// * #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub struct BindingPattern<'a> { // serde(flatten) the attributes because estree has no `BindingPattern` - #[serde(flatten)] + #[estree(flatten)] #[tsify(type = "(BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern)")] #[span] pub kind: BindingPatternKind<'a>, @@ -1660,9 +1653,9 @@ pub struct BindingPattern<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum BindingPatternKind<'a> { /// `const a = 1` BindingIdentifier(Box<'a, BindingIdentifier<'a>>) = 0, @@ -1679,11 +1672,11 @@ pub enum BindingPatternKind<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct AssignmentPattern<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: BindingPattern<'a>, pub right: Expression<'a>, @@ -1694,23 +1687,23 @@ pub struct AssignmentPattern<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[serde(tag = "type")] +#[estree(tag = "type")] pub struct ObjectPattern<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, #[tsify(type = "Array")] pub properties: Vec<'a, BindingProperty<'a>>, - #[serde(skip)] + #[estree(skip)] pub rest: Option>>, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct BindingProperty<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub key: PropertyKey<'a>, pub value: BindingPattern<'a>, @@ -1723,13 +1716,13 @@ pub struct BindingProperty<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[serde(tag = "type")] +#[estree(tag = "type")] pub struct ArrayPattern<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, #[tsify(type = "Array")] pub elements: Vec<'a, Option>>, - #[serde(skip)] + #[estree(skip)] pub rest: Option>>, } @@ -1744,11 +1737,10 @@ pub struct ArrayPattern<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[serde(tag = "type", rename = "RestElement")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(tag = "type", rename = "RestElement")] pub struct BindingRestElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub argument: BindingPattern<'a>, } @@ -1795,12 +1787,12 @@ pub struct BindingRestElement<'a> { strict_if(self.is_strict()), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub struct Function<'a> { pub r#type: FunctionType, - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The function identifier. [`None`] for anonymous function expressions. pub id: Option>, @@ -1850,15 +1842,15 @@ pub struct Function<'a> { /// } /// ``` pub body: Option>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum FunctionType { FunctionDeclaration = 0, FunctionExpression = 1, @@ -1873,24 +1865,24 @@ pub enum FunctionType { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[serde(tag = "type")] +#[estree(tag = "type")] pub struct FormalParameters<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: FormalParameterKind, #[tsify(type = "Array")] pub items: Vec<'a, FormalParameter<'a>>, - #[serde(skip)] + #[estree(skip)] pub rest: Option>>, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct FormalParameter<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub decorators: Vec<'a, Decorator<'a>>, pub pattern: BindingPattern<'a>, @@ -1901,8 +1893,8 @@ pub struct FormalParameter<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum FormalParameterKind { /// FormalParameter = 0, @@ -1917,11 +1909,11 @@ pub enum FormalParameterKind { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct FunctionBody<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub directives: Vec<'a, Directive<'a>>, pub statements: Vec<'a, Statement<'a>>, @@ -1934,11 +1926,11 @@ pub struct FunctionBody<'a> { strict_if(self.body.has_use_strict_directive()), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct ArrowFunctionExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Is the function body an arrow expression? i.e. `() => expr` instead of `() => {}` pub expression: bool, @@ -1948,7 +1940,7 @@ pub struct ArrowFunctionExpression<'a> { pub return_type: Option>>, /// See `expression` for whether this arrow expression returns an expression. pub body: Box<'a, FunctionBody<'a>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1956,11 +1948,11 @@ pub struct ArrowFunctionExpression<'a> { /// Generator Function Definitions #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct YieldExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub delegate: bool, pub argument: Option>, @@ -1970,12 +1962,12 @@ pub struct YieldExpression<'a> { #[ast(visit)] #[scope(flags(ScopeFlags::StrictMode))] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub struct Class<'a> { pub r#type: ClassType, - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Decorators applied to the class. /// @@ -2036,15 +2028,15 @@ pub struct Class<'a> { pub declare: bool, /// Id of the scope created by the [`Class`], including type parameters and /// statements within the [`ClassBody`]. - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum ClassType { /// Class declaration statement /// ```ts @@ -2061,11 +2053,11 @@ pub enum ClassType { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ClassBody<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, ClassElement<'a>>, } @@ -2090,9 +2082,9 @@ pub struct ClassBody<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ClassElement<'a> { StaticBlock(Box<'a, StaticBlock<'a>>) = 0, /// Class Methods @@ -2114,15 +2106,15 @@ pub enum ClassElement<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub struct MethodDefinition<'a> { /// Method definition type /// /// This will always be true when an `abstract` modifier is used on the method. pub r#type: MethodDefinitionType, - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub decorators: Vec<'a, Decorator<'a>>, pub key: PropertyKey<'a>, @@ -2143,8 +2135,8 @@ pub struct MethodDefinition<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum MethodDefinitionType { MethodDefinition = 0, TSAbstractMethodDefinition = 1, @@ -2152,12 +2144,12 @@ pub enum MethodDefinitionType { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub struct PropertyDefinition<'a> { pub r#type: PropertyDefinitionType, - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Decorators applied to the property. /// @@ -2234,8 +2226,8 @@ pub struct PropertyDefinition<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum PropertyDefinitionType { PropertyDefinition = 0, TSAbstractPropertyDefinition = 1, @@ -2243,9 +2235,9 @@ pub enum PropertyDefinitionType { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum MethodDefinitionKind { /// Class constructor Constructor = 0, @@ -2262,11 +2254,11 @@ pub enum MethodDefinitionKind { /// See: [MDN - Private class fields](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields) #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct PrivateIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, } @@ -2287,14 +2279,14 @@ pub struct PrivateIdentifier<'a> { #[ast(visit)] #[scope(flags(ScopeFlags::ClassStaticBlock))] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct StaticBlock<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, Statement<'a>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -2324,9 +2316,9 @@ pub struct StaticBlock<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ModuleDeclaration<'a> { /// `import hello from './world.js';` /// `import * as t from './world.js';` @@ -2361,8 +2353,8 @@ pub use match_module_declaration; #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum AccessorPropertyType { AccessorProperty = 0, TSAbstractAccessorProperty = 1, @@ -2378,12 +2370,12 @@ pub enum AccessorPropertyType { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub struct AccessorProperty<'a> { pub r#type: AccessorPropertyType, - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Decorators applied to the accessor property. /// @@ -2422,11 +2414,11 @@ pub struct AccessorProperty<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ImportExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub source: Expression<'a>, pub arguments: Vec<'a, Expression<'a>>, @@ -2434,11 +2426,11 @@ pub struct ImportExpression<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct ImportDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `None` for `import 'foo'`, `Some([])` for `import {} from 'foo'` pub specifiers: Option>>, @@ -2451,9 +2443,9 @@ pub struct ImportDeclaration<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ImportDeclarationSpecifier<'a> { /// import {imported} from "source" /// import {imported as local} from "source" @@ -2468,11 +2460,11 @@ pub enum ImportDeclarationSpecifier<'a> { // import {imported as local} from "source" #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct ImportSpecifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub imported: ModuleExportName<'a>, /// The name of the imported symbol. @@ -2499,11 +2491,11 @@ pub struct ImportSpecifier<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ImportDefaultSpecifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the imported symbol. pub local: BindingIdentifier<'a>, @@ -2517,22 +2509,22 @@ pub struct ImportDefaultSpecifier<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ImportNamespaceSpecifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub local: BindingIdentifier<'a>, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct WithClause<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub attributes_keyword: IdentifierName<'a>, // `with` or `assert` pub with_entries: Vec<'a, ImportAttribute<'a>>, @@ -2540,11 +2532,11 @@ pub struct WithClause<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ImportAttribute<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub key: ImportAttributeKey<'a>, pub value: StringLiteral<'a>, @@ -2552,9 +2544,9 @@ pub struct ImportAttribute<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ImportAttributeKey<'a> { Identifier(IdentifierName<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -2573,11 +2565,11 @@ pub enum ImportAttributeKey<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct ExportNamedDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub declaration: Option>, pub specifiers: Vec<'a, ExportSpecifier<'a>>, @@ -2599,11 +2591,11 @@ pub struct ExportNamedDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ExportDefaultDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub declaration: ExportDefaultDeclarationKind<'a>, pub exported: ModuleExportName<'a>, // the `default` Keyword @@ -2620,11 +2612,11 @@ pub struct ExportDefaultDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct ExportAllDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// If this declaration is re-named pub exported: Option>, @@ -2647,11 +2639,11 @@ pub struct ExportAllDeclaration<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct ExportSpecifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub local: ModuleExportName<'a>, pub exported: ModuleExportName<'a>, @@ -2666,9 +2658,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ExportDefaultDeclarationKind<'a> { #[visit(args(flags = ScopeFlags::Function))] FunctionDeclaration(Box<'a, Function<'a>>) = 64, @@ -2690,9 +2682,9 @@ pub enum ExportDefaultDeclarationKind<'a> { /// * #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum ModuleExportName<'a> { IdentifierName(IdentifierName<'a>) = 0, /// For `local` in `ExportSpecifier`: `foo` in `export { foo }` diff --git a/crates/oxc_ast/src/ast/jsx.rs b/crates/oxc_ast/src/ast/jsx.rs index ce4f04831e8b2..c70b05d42d253 100644 --- a/crates/oxc_ast/src/ast/jsx.rs +++ b/crates/oxc_ast/src/ast/jsx.rs @@ -9,10 +9,9 @@ use oxc_allocator::{Box, CloneIn, Vec}; use oxc_ast_macros::ast; +use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; #[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] use tsify::Tsify; use super::{inherit_variants, js::*, literal::*, ts::*}; @@ -38,11 +37,11 @@ use super::{inherit_variants, js::*, literal::*, ts::*}; /// See: [JSX Syntax](https://facebook.github.io/jsx/) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct JSXElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Opening tag of the element. pub opening_element: Box<'a, JSXOpeningElement<'a>>, @@ -69,11 +68,11 @@ pub struct JSXElement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct JSXOpeningElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Is this tag self-closing? /// @@ -103,11 +102,11 @@ pub struct JSXOpeningElement<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXClosingElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: JSXElementName<'a>, } @@ -122,11 +121,11 @@ pub struct JSXClosingElement<'a> { /// See: [`React.Fragment`](https://react.dev/reference/react/Fragment) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct JSXFragment<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `<>` pub opening_fragment: JSXOpeningFragment, @@ -139,22 +138,22 @@ pub struct JSXFragment<'a> { /// JSX Opening Fragment (`<>`) #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXOpeningFragment { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } /// JSX Closing Fragment (``) #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXClosingFragment { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -162,7 +161,7 @@ pub struct JSXClosingFragment { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[serde(untagged)] +#[estree(untagged)] pub enum JSXElementName<'a> { /// `
` Identifier(Box<'a, JSXIdentifier<'a>>) = 0, @@ -185,11 +184,11 @@ pub enum JSXElementName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXNamespacedName<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Namespace portion of the name, e.g. `Apple` in `` pub namespace: JSXIdentifier<'a>, @@ -214,11 +213,11 @@ pub struct JSXNamespacedName<'a> { /// [`member expression`]: JSXMemberExpressionObject::MemberExpression #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXMemberExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The object being accessed. This is everything before the last `.`. pub object: JSXMemberExpressionObject<'a>, @@ -229,7 +228,7 @@ pub struct JSXMemberExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[serde(untagged)] +#[estree(untagged)] pub enum JSXMemberExpressionObject<'a> { IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, MemberExpression(Box<'a, JSXMemberExpression<'a>>) = 1, @@ -251,11 +250,11 @@ pub enum JSXMemberExpressionObject<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXExpressionContainer<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The expression inside the container. pub expression: JSXExpression<'a>, @@ -270,9 +269,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum JSXExpression<'a> { EmptyExpression(JSXEmptyExpression) = 64, // `Expression` variants added here by `inherit_variants!` macro @@ -283,11 +282,11 @@ pub enum JSXExpression<'a> { /// An empty JSX expression (`{}`) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXEmptyExpression { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -304,9 +303,9 @@ pub struct JSXEmptyExpression { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum JSXAttributeItem<'a> { /// A `key="value"` attribute Attribute(Box<'a, JSXAttribute<'a>>) = 0, @@ -327,11 +326,11 @@ pub enum JSXAttributeItem<'a> { /// // name ^^^ ^^^^ value #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXAttribute<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the attribute. This is a prop in React-like applications. pub name: JSXAttributeName<'a>, @@ -350,11 +349,11 @@ pub struct JSXAttribute<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXSpreadAttribute<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub argument: Expression<'a>, } @@ -376,9 +375,9 @@ pub struct JSXSpreadAttribute<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum JSXAttributeName<'a> { /// An attribute name without a namespace prefix, e.g. `foo` in `foo="bar"`. Identifier(Box<'a, JSXIdentifier<'a>>) = 0, @@ -406,9 +405,9 @@ pub enum JSXAttributeName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum JSXAttributeValue<'a> { StringLiteral(Box<'a, StringLiteral<'a>>) = 0, ExpressionContainer(Box<'a, JSXExpressionContainer<'a>>) = 1, @@ -423,11 +422,11 @@ pub enum JSXAttributeValue<'a> { /// [`IdentifierName`]: super::IdentifierName #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the identifier. pub name: Atom<'a>, @@ -440,9 +439,9 @@ pub struct JSXIdentifier<'a> { /// Part of a [`JSXElement`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum JSXChild<'a> { /// `Some Text` Text(Box<'a, JSXText<'a>>) = 0, @@ -461,11 +460,11 @@ pub enum JSXChild<'a> { /// Variant of [`JSXChild`] that represents an object spread (`{...expression}`). #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXSpreadChild<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The expression being spread. pub expression: Expression<'a>, @@ -483,11 +482,11 @@ pub struct JSXSpreadChild<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct JSXText<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The text content. pub value: Atom<'a>, diff --git a/crates/oxc_ast/src/ast/literal.rs b/crates/oxc_ast/src/ast/literal.rs index c4fe6200de64f..8f09351752ce7 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -12,12 +12,11 @@ use std::hash::Hash; use bitflags::bitflags; use oxc_allocator::{Box, CloneIn}; use oxc_ast_macros::ast; +use oxc_estree::ESTree; use oxc_regular_expression::ast::Pattern; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; use oxc_syntax::number::{BigintBase, NumberBase}; #[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] use tsify::Tsify; /// Boolean literal @@ -25,11 +24,11 @@ use tsify::Tsify; /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct BooleanLiteral { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub value: bool, } @@ -39,11 +38,11 @@ pub struct BooleanLiteral { /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct NullLiteral { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -52,34 +51,34 @@ pub struct NullLiteral { /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct NumericLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The value of the number, converted into base 10 pub value: f64, /// The number as it appears in the source code pub raw: &'a str, /// The base representation used by the literal in the source code - #[serde(skip)] + #[estree(skip)] pub base: NumberBase, } /// BigInt literal #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct BigIntLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The bigint as it appears in the source code pub raw: Atom<'a>, /// The base representation used by the literal in the source code - #[serde(skip)] + #[estree(skip)] pub base: BigintBase, } @@ -88,11 +87,11 @@ pub struct BigIntLiteral<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct RegExpLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, // valid regex is printed as {} // invalid regex is printed as null, which we can't implement yet @@ -105,8 +104,8 @@ pub struct RegExpLiteral<'a> { /// #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct RegExp<'a> { /// The regex pattern between the slashes pub pattern: RegExpPattern<'a>, @@ -119,8 +118,8 @@ pub struct RegExp<'a> { /// This pattern may or may not be parsed. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum RegExpPattern<'a> { /// Unparsed pattern. Contains string slice of the pattern. /// Pattern was not parsed, so may be valid or invalid. @@ -135,8 +134,8 @@ pub enum RegExpPattern<'a> { #[ast] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct EmptyObject; /// String literal @@ -144,11 +143,11 @@ pub struct EmptyObject; /// #[ast(visit)] #[derive(Debug, Clone)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct StringLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub value: Atom<'a>, } diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 9601204ca0fc0..fa46ad2505104 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -14,11 +14,10 @@ use std::cell::Cell; use oxc_allocator::{Box, CloneIn, Vec}; use oxc_ast_macros::ast; +use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; use oxc_syntax::scope::ScopeId; #[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] use tsify::Tsify; use super::{inherit_variants, js::*, jsx::*, literal::*}; @@ -45,11 +44,11 @@ export interface TSIndexSignatureName extends Span { /// * [TypeScript Handbook - `this` parameters](https://www.typescriptlang.org/docs/handbook/2/functions.html#this-parameters) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSThisParameter<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub this_span: Span, /// Type type the `this` keyword will have in the function @@ -79,11 +78,11 @@ pub struct TSThisParameter<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSEnumDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub id: BindingIdentifier<'a>, #[scope(enter_before)] @@ -91,7 +90,7 @@ pub struct TSEnumDeclaration<'a> { /// `true` for const enums pub r#const: bool, pub declare: bool, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -115,11 +114,11 @@ pub struct TSEnumDeclaration<'a> { /// * [TypeScript Handbook - Enums](https://www.typescriptlang.org/docs/handbook/enums.html) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSEnumMember<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub id: TSEnumMemberName<'a>, pub initializer: Option>, @@ -134,9 +133,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum TSEnumMemberName<'a> { StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64, StaticStringLiteral(Box<'a, StringLiteral<'a>>) = 65, @@ -163,11 +162,11 @@ pub enum TSEnumMemberName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeAnnotation<'a> { - #[serde(flatten)] + #[estree(flatten)] /// starts at the `:` token and ends at the end of the type annotation pub span: Span, /// The actual type in the annotation @@ -190,11 +189,11 @@ pub struct TSTypeAnnotation<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSLiteralType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub literal: TSLiteral<'a>, } @@ -202,9 +201,9 @@ pub struct TSLiteralType<'a> { /// A literal in a [`TSLiteralType`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged, rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged, rename_all = "camelCase")] pub enum TSLiteral<'a> { BooleanLiteral(Box<'a, BooleanLiteral>) = 0, NullLiteral(Box<'a, NullLiteral>) = 1, @@ -229,9 +228,9 @@ pub enum TSLiteral<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged, rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged, rename_all = "camelCase")] pub enum TSType<'a> { // Keyword TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0, @@ -338,11 +337,11 @@ pub use match_ts_type; #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSConditionalType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The type before `extends` in the test expression. pub check_type: TSType<'a>, @@ -354,7 +353,7 @@ pub struct TSConditionalType<'a> { /// The type evaluated to if the test is false. #[scope(exit_before)] pub false_type: TSType<'a>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -370,11 +369,11 @@ pub struct TSConditionalType<'a> { /// * [TypeScript Handbook - Union Types](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes-func.html#unions) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSUnionType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The types in the union. pub types: Vec<'a, TSType<'a>>, @@ -395,11 +394,11 @@ pub struct TSUnionType<'a> { /// * [TypeScript Handbook - Intersection Types](https://www.typescriptlang.org/docs/handbook/2/objects.html#intersection-types) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSIntersectionType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub types: Vec<'a, TSType<'a>>, } @@ -415,11 +414,11 @@ pub struct TSIntersectionType<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSParenthesizedType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, } @@ -435,11 +434,11 @@ pub struct TSParenthesizedType<'a> { /// * [TypeScript Handbook - Keyof Types](https://www.typescriptlang.org/docs/handbook/2/keyof-types.html) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeOperator<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub operator: TSTypeOperatorOperator, /// The type being operated on @@ -449,9 +448,9 @@ pub struct TSTypeOperator<'a> { /// Operator in a [`TSTypeOperator`]. #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum TSTypeOperatorOperator { Keyof = 0, Unique = 1, @@ -471,11 +470,11 @@ pub enum TSTypeOperatorOperator { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSArrayType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub element_type: TSType<'a>, } @@ -493,11 +492,11 @@ pub struct TSArrayType<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSIndexedAccessType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object_type: TSType<'a>, pub index_type: TSType<'a>, @@ -514,11 +513,11 @@ pub struct TSIndexedAccessType<'a> { /// #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTupleType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub element_types: Vec<'a, TSTupleElement<'a>>, } @@ -535,11 +534,11 @@ pub struct TSTupleType<'a> { /// * [TypeScript Handbook - Tuple Types](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSNamedTupleMember<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub element_type: TSTupleElement<'a>, pub label: IdentifierName<'a>, @@ -557,11 +556,11 @@ pub struct TSNamedTupleMember<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSOptionalType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, } @@ -576,11 +575,11 @@ pub struct TSOptionalType<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSRestType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, } @@ -595,9 +594,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged, rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged, rename_all = "camelCase")] pub enum TSTupleElement<'a> { // Discriminants start at 64, so that `TSTupleElement::is_ts_type` is a single // bitwise AND operation on the discriminant (`discriminant & 63 != 0`). @@ -619,11 +618,11 @@ pub enum TSTupleElement<'a> { /// * [TypeScript Handbook - Any Type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSAnyKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -638,11 +637,11 @@ pub struct TSAnyKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSStringKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -657,11 +656,11 @@ pub struct TSStringKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSBooleanKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -676,11 +675,11 @@ pub struct TSBooleanKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSNumberKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -696,11 +695,11 @@ pub struct TSNumberKeyword { /// * [TypeScript Handbook - Advanced Topics](https://www.typescriptlang.org/docs/handbook/type-compatibility.html#advanced-topics) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSNeverKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -716,11 +715,11 @@ pub struct TSNeverKeyword { /// * [microsoft/TypeScript #40580](https://github.com/microsoft/TypeScript/pull/40580) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSIntrinsicKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -737,11 +736,11 @@ pub struct TSIntrinsicKeyword { /// * [TypeScript Handbook - Advanced Topics](https://www.typescriptlang.org/docs/handbook/type-compatibility.html#advanced-topics) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSUnknownKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -757,11 +756,11 @@ pub struct TSUnknownKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#null-and-undefined) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSNullKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -779,61 +778,61 @@ pub struct TSNullKeyword { /// * [TypeScript Handbook - Everyday Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#null-and-undefined) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSUndefinedKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSVoidKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSSymbolKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSThisType { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSObjectKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct TSBigIntKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -847,11 +846,11 @@ pub struct TSBigIntKeyword { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeReference<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_name: TSTypeName<'a>, pub type_parameters: Option>>, @@ -862,9 +861,9 @@ pub struct TSTypeReference<'a> { /// NamespaceName . IdentifierReference #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum TSTypeName<'a> { IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1, @@ -889,11 +888,11 @@ pub use match_ts_type_name; /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSQualifiedName<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: TSTypeName<'a>, pub right: IdentifierName<'a>, @@ -901,11 +900,11 @@ pub struct TSQualifiedName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeParameterInstantiation<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub params: Vec<'a, TSType<'a>>, } @@ -929,11 +928,11 @@ pub struct TSTypeParameterInstantiation<'a> { /// * [TypeScript Handbook - Variance Annotations](https://www.typescriptlang.org/docs/handbook/2/generics.html#variance-annotations) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeParameter<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the parameter, e.g. `T` in `type Foo = ...`. pub name: BindingIdentifier<'a>, @@ -951,11 +950,11 @@ pub struct TSTypeParameter<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeParameterDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub params: Vec<'a, TSTypeParameter<'a>>, } @@ -971,11 +970,11 @@ pub struct TSTypeParameterDeclaration<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeAliasDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Type alias's identifier, e.g. `Foo` in `type Foo = number`. pub id: BindingIdentifier<'a>, @@ -983,16 +982,16 @@ pub struct TSTypeAliasDeclaration<'a> { pub type_parameters: Option>>, pub type_annotation: TSType<'a>, pub declare: bool, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum TSAccessibility { Private = 0, Protected = 1, @@ -1011,11 +1010,11 @@ pub enum TSAccessibility { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSClassImplements<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: TSTypeName<'a>, pub type_parameters: Option>>, @@ -1039,11 +1038,11 @@ pub struct TSClassImplements<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInterfaceDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The identifier (name) of the interface. pub id: BindingIdentifier<'a>, @@ -1055,7 +1054,7 @@ pub struct TSInterfaceDeclaration<'a> { pub body: Box<'a, TSInterfaceBody<'a>>, /// `true` for `declare interface Foo {}` pub declare: bool, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1063,11 +1062,11 @@ pub struct TSInterfaceDeclaration<'a> { /// Body of a [`TSInterfaceDeclaration`]. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInterfaceBody<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, TSSignature<'a>>, } @@ -1089,11 +1088,11 @@ pub struct TSInterfaceBody<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSPropertySignature<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub computed: bool, pub optional: bool, @@ -1104,9 +1103,9 @@ pub struct TSPropertySignature<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged, rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged, rename_all = "camelCase")] pub enum TSSignature<'a> { TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0, TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1, @@ -1128,11 +1127,11 @@ pub enum TSSignature<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSIndexSignature<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub parameters: Vec<'a, TSIndexSignatureName<'a>>, pub type_annotation: Box<'a, TSTypeAnnotation<'a>>, @@ -1141,11 +1140,11 @@ pub struct TSIndexSignature<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSCallSignatureDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub this_param: Option>, pub params: Box<'a, FormalParameters<'a>>, @@ -1155,9 +1154,9 @@ pub struct TSCallSignatureDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum TSMethodSignatureKind { Method = 0, Get = 1, @@ -1178,11 +1177,11 @@ pub enum TSMethodSignatureKind { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSMethodSignature<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub key: PropertyKey<'a>, pub computed: bool, @@ -1192,7 +1191,7 @@ pub struct TSMethodSignature<'a> { pub params: Box<'a, FormalParameters<'a>>, pub return_type: Option>>, pub type_parameters: Option>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1201,27 +1200,26 @@ pub struct TSMethodSignature<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSConstructSignatureDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub params: Box<'a, FormalParameters<'a>>, pub return_type: Option>>, pub type_parameters: Option>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[serde(tag = "type", rename = "Identifier", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(tag = "type", rename = "Identifier", rename_all = "camelCase")] pub struct TSIndexSignatureName<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, pub type_annotation: Box<'a, TSTypeAnnotation<'a>>, @@ -1229,11 +1227,11 @@ pub struct TSIndexSignatureName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInterfaceHeritage<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, pub type_parameters: Option>>, @@ -1261,11 +1259,11 @@ pub struct TSInterfaceHeritage<'a> { /// * [TypeScript Handbook - Assertion Functions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypePredicate<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The identifier the predicate operates on pub parameter_name: TSTypePredicateName<'a>, @@ -1281,9 +1279,9 @@ pub struct TSTypePredicate<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged, rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged, rename_all = "camelCase")] pub enum TSTypePredicateName<'a> { Identifier(Box<'a, IdentifierName<'a>>) = 0, This(TSThisType) = 1, @@ -1321,11 +1319,11 @@ pub enum TSTypePredicateName<'a> { strict_if(self.body.as_ref().is_some_and(TSModuleDeclarationBody::is_strict)), )] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSModuleDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the module/namespace being declared. /// @@ -1348,16 +1346,16 @@ pub struct TSModuleDeclaration<'a> { /// ``` pub kind: TSModuleDeclarationKind, pub declare: bool, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum TSModuleDeclarationKind { /// `declare global {}` Global = 0, @@ -1389,9 +1387,9 @@ pub enum TSModuleDeclarationKind { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum TSModuleDeclarationName<'a> { Identifier(BindingIdentifier<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -1399,9 +1397,9 @@ pub enum TSModuleDeclarationName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum TSModuleDeclarationBody<'a> { TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0, TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1, @@ -1412,22 +1410,22 @@ pub enum TSModuleDeclarationBody<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSModuleBlock<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, - #[serde(skip)] + #[estree(skip)] pub directives: Vec<'a, Directive<'a>>, pub body: Vec<'a, Statement<'a>>, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub members: Vec<'a, TSSignature<'a>>, } @@ -1447,11 +1445,11 @@ pub struct TSTypeLiteral<'a> { /// * [TypeScript Handbook - Inferring With Conditional Types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInferType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The type bound when the pub type_parameter: Box<'a, TSTypeParameter<'a>>, @@ -1468,11 +1466,11 @@ pub struct TSInferType<'a> { /// * [TypeScript Handbook - Typeof Type Operator](https://www.typescriptlang.org/docs/handbook/2/typeof-types.html) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeQuery<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expr_name: TSTypeQueryExprName<'a>, pub type_parameters: Option>>, @@ -1486,9 +1484,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum TSTypeQueryExprName<'a> { TSImportType(Box<'a, TSImportType<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1498,11 +1496,11 @@ pub enum TSTypeQueryExprName<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSImportType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `true` for `typeof import("foo")` pub is_type_of: bool, @@ -1514,11 +1512,11 @@ pub struct TSImportType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSImportAttributes<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub attributes_keyword: IdentifierName<'a>, // `with` or `assert` pub elements: Vec<'a, TSImportAttribute<'a>>, @@ -1526,11 +1524,11 @@ pub struct TSImportAttributes<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSImportAttribute<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: TSImportAttributeName<'a>, pub value: Expression<'a>, @@ -1538,9 +1536,9 @@ pub struct TSImportAttribute<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged)] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum TSImportAttributeName<'a> { Identifier(IdentifierName<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -1556,11 +1554,11 @@ pub enum TSImportAttributeName<'a> { /// ``` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSFunctionType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `this` parameter /// @@ -1588,11 +1586,11 @@ pub struct TSFunctionType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSConstructorType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub r#abstract: bool, pub params: Box<'a, FormalParameters<'a>>, @@ -1624,11 +1622,11 @@ pub struct TSConstructorType<'a> { #[ast(visit)] #[scope] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSMappedType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Key type parameter, e.g. `P` in `[P in keyof T]`. pub type_parameter: Box<'a, TSTypeParameter<'a>>, @@ -1658,24 +1656,24 @@ pub struct TSMappedType<'a> { /// type Qux = { [P in keyof T]: T[P] } // None /// ``` pub readonly: TSMappedTypeModifierOperator, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum TSMappedTypeModifierOperator { /// e.g. `?` in `{ [P in K]?: T }` True = 0, /// e.g. `+?` in `{ [P in K]+?: T }` - #[serde(rename = "+")] + #[estree(rename = "+")] Plus = 1, /// e.g. `-?` in `{ [P in K]-?: T }` - #[serde(rename = "-")] + #[estree(rename = "-")] Minus = 2, /// No modifier present None = 3, @@ -1694,11 +1692,11 @@ pub enum TSMappedTypeModifierOperator { /// * [TypeScript Handbook - Template Literal Types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#handbook-content) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTemplateLiteralType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The string parts of the template literal. pub quasis: Vec<'a, TemplateElement<'a>>, @@ -1708,11 +1706,11 @@ pub struct TSTemplateLiteralType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSAsExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, pub type_annotation: TSType<'a>, @@ -1732,11 +1730,11 @@ pub struct TSAsExpression<'a> { /// * [TypeScript Handbook - The `satisfies` Operator](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator) #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSSatisfiesExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The value expression being constrained. pub expression: Expression<'a>, @@ -1746,11 +1744,11 @@ pub struct TSSatisfiesExpression<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeAssertion<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, pub type_annotation: TSType<'a>, @@ -1758,11 +1756,11 @@ pub struct TSTypeAssertion<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSImportEqualsDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub id: BindingIdentifier<'a>, pub module_reference: TSModuleReference<'a>, @@ -1777,9 +1775,9 @@ inherit_variants! { /// [`ast` module docs]: `super` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(untagged, rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged, rename_all = "camelCase")] pub enum TSModuleReference<'a> { ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1789,22 +1787,22 @@ pub enum TSModuleReference<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSExternalModuleReference<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: StringLiteral<'a>, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSNonNullExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1835,11 +1833,11 @@ pub struct TSNonNullExpression<'a> { /// [`CallExpression`]: crate::ast::js::CallExpression #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct Decorator<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1849,11 +1847,11 @@ pub struct Decorator<'a> { /// `export = foo` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSExportAssignment<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1863,22 +1861,22 @@ pub struct TSExportAssignment<'a> { /// `export as namespace foo` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSNamespaceExportDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub id: IdentifierName<'a>, } #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInstantiationExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, pub type_parameters: Box<'a, TSTypeParameterInstantiation<'a>>, @@ -1887,9 +1885,9 @@ pub struct TSInstantiationExpression<'a> { /// See [TypeScript - Type-Only Imports and Exports](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html) #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum ImportOrExportKind { /// `import { foo } from './foo'`; Value = 0, @@ -1902,11 +1900,11 @@ pub enum ImportOrExportKind { /// `type foo = ty?` or `type foo = ?ty` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct JSDocNullableType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, /// Was `?` after the type annotation? @@ -1916,11 +1914,11 @@ pub struct JSDocNullableType<'a> { /// `type foo = ty!` or `type foo = !ty` #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct JSDocNonNullableType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, pub postfix: bool, @@ -1928,10 +1926,10 @@ pub struct JSDocNonNullableType<'a> { #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type", rename_all = "camelCase")] pub struct JSDocUnknownType { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs new file mode 100644 index 0000000000000..1c3c4f895a7a1 --- /dev/null +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -0,0 +1,2158 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` + +use serde::{Serialize, Serializer}; + +#[allow(clippy::wildcard_imports)] +use crate::ast::js::*; + +#[allow(clippy::wildcard_imports)] +use crate::ast::jsx::*; + +#[allow(clippy::wildcard_imports)] +use crate::ast::literal::*; + +#[allow(clippy::wildcard_imports)] +use crate::ast::ts::*; + +impl Serialize for BooleanLiteral { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for NullLiteral { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for NumericLiteral<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BigIntLiteral<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for RegExpLiteral<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for RegExp<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for RegExpPattern<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for EmptyObject { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for StringLiteral<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Program<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Expression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for IdentifierName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for IdentifierReference<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BindingIdentifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for LabelIdentifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for ThisExpression { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ArrayExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ArrayExpressionElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ObjectExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ObjectPropertyKind<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ObjectProperty<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for PropertyKey<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for PropertyKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TemplateLiteral<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TaggedTemplateExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TemplateElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TemplateElementValue<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for MemberExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ComputedMemberExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for StaticMemberExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for PrivateFieldExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for CallExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for NewExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for MetaProperty<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for SpreadElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Argument<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for UpdateExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for UnaryExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BinaryExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for PrivateInExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for LogicalExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ConditionalExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentTarget<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for SimpleAssignmentTarget<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentTargetPattern<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentTargetRest<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentTargetMaybeDefault<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentTargetWithDefault<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentTargetProperty<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentTargetPropertyIdentifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentTargetPropertyProperty<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for SequenceExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for Super { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AwaitExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ChainExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ChainElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ParenthesizedExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Statement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Directive<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Hashbang<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BlockStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Declaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for VariableDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for VariableDeclarationKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for VariableDeclarator<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for EmptyStatement { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ExpressionStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for IfStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for DoWhileStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for WhileStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ForStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ForStatementInit<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ForInStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ForStatementLeft<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ForOfStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ContinueStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BreakStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ReturnStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for WithStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for SwitchStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for SwitchCase<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for LabeledStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ThrowStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TryStatement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for CatchClause<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for CatchParameter<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for DebuggerStatement { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BindingPattern<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BindingPatternKind<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AssignmentPattern<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BindingProperty<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for BindingRestElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Function<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for FunctionType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for FormalParameter<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for FormalParameterKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for FunctionBody<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ArrowFunctionExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for YieldExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Class<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for ClassType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ClassBody<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ClassElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for MethodDefinition<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for MethodDefinitionType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for PropertyDefinition<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for PropertyDefinitionType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for MethodDefinitionKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for PrivateIdentifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for StaticBlock<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ModuleDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for AccessorPropertyType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for AccessorProperty<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ImportExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ImportDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ImportDeclarationSpecifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ImportSpecifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ImportDefaultSpecifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ImportNamespaceSpecifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for WithClause<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ImportAttribute<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ImportAttributeKey<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ExportNamedDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ExportDefaultDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ExportAllDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ExportSpecifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ExportDefaultDeclarationKind<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for ModuleExportName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSThisParameter<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSEnumDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSEnumMember<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSEnumMemberName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeAnnotation<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSLiteralType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSLiteral<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSConditionalType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSUnionType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSIntersectionType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSParenthesizedType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeOperator<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSTypeOperatorOperator { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSArrayType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSIndexedAccessType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTupleType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSNamedTupleMember<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSOptionalType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSRestType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTupleElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSAnyKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSStringKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSBooleanKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSNumberKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSNeverKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSIntrinsicKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSUnknownKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSNullKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSUndefinedKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSVoidKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSSymbolKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSThisType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSObjectKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSBigIntKeyword { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeReference<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSQualifiedName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeParameterInstantiation<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeParameter<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeParameterDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeAliasDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSAccessibility { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSClassImplements<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSInterfaceDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSInterfaceBody<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSPropertySignature<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSSignature<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSIndexSignature<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSCallSignatureDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSMethodSignatureKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSMethodSignature<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSConstructSignatureDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSIndexSignatureName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSInterfaceHeritage<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypePredicate<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypePredicateName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSModuleDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSModuleDeclarationKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSModuleDeclarationName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSModuleDeclarationBody<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeLiteral<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSInferType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeQuery<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeQueryExprName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSImportType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSImportAttributes<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSImportAttribute<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSImportAttributeName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSFunctionType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSConstructorType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSMappedType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for TSMappedTypeModifierOperator { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTemplateLiteralType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSAsExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSSatisfiesExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSTypeAssertion<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSImportEqualsDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSModuleReference<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSExternalModuleReference<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSNonNullExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for Decorator<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSExportAssignment<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSNamespaceExportDeclaration<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for TSInstantiationExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for ImportOrExportKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSDocNullableType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSDocNonNullableType<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for JSDocUnknownType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXOpeningElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXClosingElement<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXFragment<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for JSXOpeningFragment { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for JSXClosingFragment { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXNamespacedName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXMemberExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXExpressionContainer<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXExpression<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for JSXEmptyExpression { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXAttributeItem<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXAttribute<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXSpreadAttribute<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXAttributeName<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXAttributeValue<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXIdentifier<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXChild<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXSpreadChild<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl<'a> Serialize for JSXText<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index 2a99c0960347f..f54f3b91bfa60 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -43,6 +43,8 @@ mod generated { pub mod derive_clone_in; pub mod derive_content_eq; pub mod derive_content_hash; + #[cfg(feature = "serialize")] + pub mod derive_estree; pub mod derive_get_span; pub mod derive_get_span_mut; pub mod visit; diff --git a/crates/oxc_ast_macros/src/ast.rs b/crates/oxc_ast_macros/src/ast.rs index 454e397f11bc5..3354fd07017ab 100644 --- a/crates/oxc_ast_macros/src/ast.rs +++ b/crates/oxc_ast_macros/src/ast.rs @@ -81,8 +81,8 @@ fn abs_trait( (quote!(::oxc_span::cmp::ContentEq), TokenStream::default()) } else if ident == "ContentHash" { (quote!(::oxc_span::hash::ContentHash), TokenStream::default()) - } else if ident == "Serialize" { - (quote!(::serde::Serialize), TokenStream::default()) + } else if ident == "ESTree" { + (quote!(::oxc_estree::ESTree), TokenStream::default()) } else { invalid_derive(ident) } diff --git a/crates/oxc_ast_macros/src/lib.rs b/crates/oxc_ast_macros/src/lib.rs index f657bff3281d2..4e6d6a21fddfd 100644 --- a/crates/oxc_ast_macros/src/lib.rs +++ b/crates/oxc_ast_macros/src/lib.rs @@ -81,7 +81,7 @@ pub fn ast(_args: TokenStream, input: TokenStream) -> TokenStream { /// The only purpose is to allow the occurrence of helper attributes used with the `tasks/ast_tools`. /// /// Read [`macro@ast`] for further details. -#[proc_macro_derive(Ast, attributes(scope, visit, span, generate_derive, clone_in, serde, tsify))] +#[proc_macro_derive(Ast, attributes(scope, visit, span, generate_derive, clone_in, estree, tsify))] pub fn ast_derive(_input: TokenStream) -> TokenStream { TokenStream::new() } diff --git a/crates/oxc_estree/Cargo.toml b/crates/oxc_estree/Cargo.toml new file mode 100644 index 0000000000000..405b1a1a970ca --- /dev/null +++ b/crates/oxc_estree/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "oxc_estree" +version = "0.31.0" +authors.workspace = true +categories.workspace = true +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +description.workspace = true + +[dependencies] + +[lints] +workspace = true diff --git a/crates/oxc_estree/src/lib.rs b/crates/oxc_estree/src/lib.rs new file mode 100644 index 0000000000000..457144eedc6f6 --- /dev/null +++ b/crates/oxc_estree/src/lib.rs @@ -0,0 +1 @@ +pub trait ESTree {} diff --git a/crates/oxc_regular_expression/Cargo.toml b/crates/oxc_regular_expression/Cargo.toml index 16f5f0c94bd09..c614397612fb1 100644 --- a/crates/oxc_regular_expression/Cargo.toml +++ b/crates/oxc_regular_expression/Cargo.toml @@ -23,6 +23,7 @@ doctest = false oxc_allocator = { workspace = true } oxc_ast_macros = { workspace = true } oxc_diagnostics = { workspace = true } +oxc_estree = { workspace = true } oxc_span = { workspace = true } phf = { workspace = true, features = ["macros"] } @@ -35,7 +36,13 @@ wasm-bindgen = { workspace = true, optional = true } [features] default = [] -serialize = ["dep:serde", "dep:tsify", "dep:wasm-bindgen", "oxc_allocator/serialize", "oxc_span/serialize"] +serialize = [ + "dep:serde", + "dep:tsify", + "dep:wasm-bindgen", + "oxc_allocator/serialize", + "oxc_span/serialize", +] [package.metadata.cargo-shear] ignored = ["wasm-bindgen"] # wasm-bindgen used by tsify diff --git a/crates/oxc_regular_expression/src/ast.rs b/crates/oxc_regular_expression/src/ast.rs index f42ec56346e96..87092dd49e09b 100644 --- a/crates/oxc_regular_expression/src/ast.rs +++ b/crates/oxc_regular_expression/src/ast.rs @@ -3,6 +3,7 @@ use oxc_allocator::{Box, CloneIn, Vec}; use oxc_ast_macros::ast; +use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, Span}; #[cfg(feature = "serialize")] use serde::Serialize; @@ -12,10 +13,11 @@ use tsify::Tsify; /// The root of the `PatternParser` result. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Pattern<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Disjunction<'a>, } @@ -23,10 +25,11 @@ pub struct Pattern<'a> { /// Pile of [`Alternative`]s separated by `|`. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Disjunction<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, Alternative<'a>>, } @@ -34,10 +37,11 @@ pub struct Disjunction<'a> { /// Single unit of `|` separated alternatives. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Alternative<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, Term<'a>>, } @@ -45,8 +49,9 @@ pub struct Alternative<'a> { /// Single unit of [`Alternative`], containing various kinds. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum Term<'a> { // Assertion, QuantifiableAssertion BoundaryAssertion(Box<'a, BoundaryAssertion>) = 0, @@ -89,8 +94,9 @@ impl<'a> GetSpan for Term<'a> { /// e.g. `^`, `$`, `\b`, `\B` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct BoundaryAssertion { pub span: Span, pub kind: BoundaryAssertionKind, @@ -98,8 +104,9 @@ pub struct BoundaryAssertion { #[ast] #[derive(Debug, Clone, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum BoundaryAssertionKind { Start = 0, End = 1, @@ -111,10 +118,11 @@ pub enum BoundaryAssertionKind { /// e.g. `(?=...)`, `(?!...)`, `(?<=...)`, `(? { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: LookAroundAssertionKind, pub body: Disjunction<'a>, @@ -122,8 +130,9 @@ pub struct LookAroundAssertion<'a> { #[ast] #[derive(Debug, Clone, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum LookAroundAssertionKind { Lookahead = 0, NegativeLookahead = 1, @@ -135,10 +144,11 @@ pub enum LookAroundAssertionKind { /// e.g. `a*`, `b+`, `c?`, `d{3}`, `e{4,}`, `f{5,6}` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Quantifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub min: u64, /// `None` means no upper bound. @@ -150,11 +160,12 @@ pub struct Quantifier<'a> { /// Single character. #[ast] #[derive(Debug, Clone, Copy)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Character { /// This will be invalid position when `UnicodeMode` is disabled and `value` is a surrogate pair. - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: CharacterKind, /// Unicode code point or UTF-16 code unit. @@ -163,8 +174,9 @@ pub struct Character { #[ast] #[derive(Debug, Clone, Copy, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum CharacterKind { ControlLetter = 0, HexadecimalEscape = 1, @@ -183,18 +195,20 @@ pub enum CharacterKind { /// e.g. `\d`, `\D`, `\s`, `\S`, `\w`, `\W` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct CharacterClassEscape { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: CharacterClassEscapeKind, } #[ast] #[derive(Debug, Clone, Copy, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum CharacterClassEscapeKind { D = 0, NegativeD = 1, @@ -208,10 +222,11 @@ pub enum CharacterClassEscapeKind { /// e.g. `\p{ASCII}`, `\P{ASCII}`, `\p{sc=Hiragana}`, `\P{sc=Hiragana}` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct UnicodePropertyEscape<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub negative: bool, /// `true` if `UnicodeSetsMode` and `name` matches unicode property of strings. @@ -223,10 +238,11 @@ pub struct UnicodePropertyEscape<'a> { /// The `.`. #[ast] #[derive(Debug, Clone, Copy)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct Dot { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -234,10 +250,11 @@ pub struct Dot { /// e.g. `[a-z]`, `[^A-Z]`, `[abc]`, `[a&&b&&c]`, `[[a-z]--x--y]` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct CharacterClass<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub negative: bool, /// `true` if: @@ -250,8 +267,9 @@ pub struct CharacterClass<'a> { #[ast] #[derive(Debug, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum CharacterClassContentsKind { Union = 0, /// `UnicodeSetsMode` only. @@ -262,8 +280,9 @@ pub enum CharacterClassContentsKind { #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum CharacterClassContents<'a> { CharacterClassRange(Box<'a, CharacterClassRange>) = 0, CharacterClassEscape(Box<'a, CharacterClassEscape>) = 1, @@ -293,10 +312,11 @@ impl<'a> GetSpan for CharacterClassContents<'a> { /// e.g. `a-z`, `A-Z`, `0-9` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct CharacterClassRange { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub min: Character, pub max: Character, @@ -305,10 +325,11 @@ pub struct CharacterClassRange { /// `|` separated string of characters wrapped by `\q{}`. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ClassStringDisjunction<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `true` if body is empty or contains [`ClassString`] which `strings` is `true`. pub strings: bool, @@ -318,10 +339,11 @@ pub struct ClassStringDisjunction<'a> { /// Single unit of [`ClassStringDisjunction`]. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ClassString<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `true` if body is empty or contain 2 more characters. pub strings: bool, @@ -332,10 +354,11 @@ pub struct ClassString<'a> { /// e.g. `(...)`, `(?...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct CapturingGroup<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Group name to be referenced by [`NamedReference`]. pub name: Option>, @@ -346,10 +369,11 @@ pub struct CapturingGroup<'a> { /// e.g. `(?:...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct IgnoreGroup<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub enabling_modifiers: Option, pub disabling_modifiers: Option, @@ -360,8 +384,9 @@ pub struct IgnoreGroup<'a> { /// e.g. `(?i:...)`, `(?-s:...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct ModifierFlags { pub ignore_case: bool, pub sticky: bool, @@ -372,10 +397,11 @@ pub struct ModifierFlags { /// e.g. `\1`, `\2`, `\3` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct IndexedReference { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub index: u32, } @@ -384,10 +410,11 @@ pub struct IndexedReference { /// e.g. `\k` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash, Serialize)] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(tag = "type")] pub struct NamedReference<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, } diff --git a/crates/oxc_regular_expression/src/generated/derive_serialize.rs b/crates/oxc_regular_expression/src/generated/derive_estree.rs similarity index 100% rename from crates/oxc_regular_expression/src/generated/derive_serialize.rs rename to crates/oxc_regular_expression/src/generated/derive_estree.rs diff --git a/crates/oxc_regular_expression/src/lib.rs b/crates/oxc_regular_expression/src/lib.rs index 509b3c33c3d14..5b22c6408168a 100644 --- a/crates/oxc_regular_expression/src/lib.rs +++ b/crates/oxc_regular_expression/src/lib.rs @@ -11,7 +11,7 @@ mod generated { mod derive_content_eq; mod derive_content_hash; #[cfg(feature = "serialize")] - mod derive_serialize; + mod derive_estree; } pub mod ast; diff --git a/crates/oxc_span/Cargo.toml b/crates/oxc_span/Cargo.toml index 1936bb2536d73..e985b3267a6b6 100644 --- a/crates/oxc_span/Cargo.toml +++ b/crates/oxc_span/Cargo.toml @@ -22,6 +22,7 @@ doctest = false [dependencies] oxc_allocator = { workspace = true } oxc_ast_macros = { workspace = true } +oxc_estree = { workspace = true } compact_str = { workspace = true } miette = { workspace = true } diff --git a/crates/oxc_span/src/generated/derive_estree.rs b/crates/oxc_span/src/generated/derive_estree.rs new file mode 100644 index 0000000000000..e06daeb82d42e --- /dev/null +++ b/crates/oxc_span/src/generated/derive_estree.rs @@ -0,0 +1,44 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` + +use serde::{Serialize, Serializer}; + +#[allow(clippy::wildcard_imports)] +use crate::source_type::*; + + +impl Serialize for SourceType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for Language { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for ModuleKind { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for LanguageVariant { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} diff --git a/crates/oxc_span/src/source_type/mod.rs b/crates/oxc_span/src/source_type/mod.rs index 8b6a759e75739..290a56a22fb8c 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -7,17 +7,19 @@ use std::{hash::Hash, path::Path}; use oxc_allocator::{Allocator, CloneIn}; use oxc_ast_macros::ast; +use oxc_estree::ESTree; #[cfg(feature = "serialize")] -use {serde::Serialize, tsify::Tsify}; +use tsify::Tsify; use crate::{cmp::ContentEq, hash::ContentHash}; pub use error::UnknownExtension; /// Source Type for JavaScript vs TypeScript / Script vs Module / JSX #[ast] +#[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub struct SourceType { /// JavaScript or TypeScript, default JavaScript pub(super) language: Language, @@ -31,21 +33,23 @@ pub struct SourceType { /// JavaScript or TypeScript #[ast] +#[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "lowercase")] pub enum Language { JavaScript = 0, TypeScript = 1, - #[serde(rename = "typescriptDefinition")] + #[estree(rename = "typescriptDefinition")] TypeScriptDefinition = 2, } /// Script or Module #[ast] +#[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum ModuleKind { /// Regular JS script or CommonJS file Script = 0, @@ -63,9 +67,10 @@ pub enum ModuleKind { /// JSX for JavaScript and TypeScript #[ast] +#[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum LanguageVariant { Standard = 0, Jsx = 1, diff --git a/crates/oxc_syntax/Cargo.toml b/crates/oxc_syntax/Cargo.toml index 03901101e7caa..ac548f3bbcfc6 100644 --- a/crates/oxc_syntax/Cargo.toml +++ b/crates/oxc_syntax/Cargo.toml @@ -22,6 +22,7 @@ doctest = false [dependencies] oxc_allocator = { workspace = true } oxc_ast_macros = { workspace = true } +oxc_estree = { workspace = true } oxc_index = { workspace = true } oxc_span = { workspace = true } diff --git a/crates/oxc_syntax/src/generated/derive_estree.rs b/crates/oxc_syntax/src/generated/derive_estree.rs new file mode 100644 index 0000000000000..42200684ae53e --- /dev/null +++ b/crates/oxc_syntax/src/generated/derive_estree.rs @@ -0,0 +1,53 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` + +use serde::{Serialize, Serializer}; + +#[allow(clippy::wildcard_imports)] +use crate::operator::*; + + +impl Serialize for AssignmentOperator { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for BinaryOperator { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for LogicalOperator { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for UnaryOperator { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +impl Serialize for UpdateOperator { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} diff --git a/crates/oxc_syntax/src/lib.rs b/crates/oxc_syntax/src/lib.rs index c64073bbb4208..dcfd35fd2abf9 100644 --- a/crates/oxc_syntax/src/lib.rs +++ b/crates/oxc_syntax/src/lib.rs @@ -17,4 +17,6 @@ mod generated { mod derive_clone_in; mod derive_content_eq; mod derive_content_hash; + #[cfg(feature = "serialize")] + mod derive_estree; } diff --git a/crates/oxc_syntax/src/operator.rs b/crates/oxc_syntax/src/operator.rs index 56f28112c7067..9f44b8f6f2603 100644 --- a/crates/oxc_syntax/src/operator.rs +++ b/crates/oxc_syntax/src/operator.rs @@ -3,48 +3,49 @@ use oxc_allocator::CloneIn; use oxc_ast_macros::ast; +use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash}; #[cfg(feature = "serialize")] -use {serde::Serialize, tsify::Tsify}; +use tsify::Tsify; use crate::precedence::{GetPrecedence, Precedence}; #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum AssignmentOperator { - #[serde(rename = "=")] + #[estree(rename = "=")] Assign = 0, - #[serde(rename = "+=")] + #[estree(rename = "+=")] Addition = 1, - #[serde(rename = "-=")] + #[estree(rename = "-=")] Subtraction = 2, - #[serde(rename = "*=")] + #[estree(rename = "*=")] Multiplication = 3, - #[serde(rename = "/=")] + #[estree(rename = "/=")] Division = 4, - #[serde(rename = "%=")] + #[estree(rename = "%=")] Remainder = 5, - #[serde(rename = "<<=")] + #[estree(rename = "<<=")] ShiftLeft = 6, - #[serde(rename = ">>=")] + #[estree(rename = ">>=")] ShiftRight = 7, - #[serde(rename = ">>>=")] + #[estree(rename = ">>>=")] ShiftRightZeroFill = 8, - #[serde(rename = "|=")] + #[estree(rename = "|=")] BitwiseOR = 9, - #[serde(rename = "^=")] + #[estree(rename = "^=")] BitwiseXOR = 10, - #[serde(rename = "&=")] + #[estree(rename = "&=")] BitwiseAnd = 11, - #[serde(rename = "&&=")] + #[estree(rename = "&&=")] LogicalAnd = 12, - #[serde(rename = "||=")] + #[estree(rename = "||=")] LogicalOr = 13, - #[serde(rename = "??=")] + #[estree(rename = "??=")] LogicalNullish = 14, - #[serde(rename = "**=")] + #[estree(rename = "**=")] Exponential = 15, } @@ -91,52 +92,52 @@ impl AssignmentOperator { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum BinaryOperator { - #[serde(rename = "==")] + #[estree(rename = "==")] Equality = 0, - #[serde(rename = "!=")] + #[estree(rename = "!=")] Inequality = 1, - #[serde(rename = "===")] + #[estree(rename = "===")] StrictEquality = 2, - #[serde(rename = "!==")] + #[estree(rename = "!==")] StrictInequality = 3, - #[serde(rename = "<")] + #[estree(rename = "<")] LessThan = 4, - #[serde(rename = "<=")] + #[estree(rename = "<=")] LessEqualThan = 5, - #[serde(rename = ">")] + #[estree(rename = ">")] GreaterThan = 6, - #[serde(rename = ">=")] + #[estree(rename = ">=")] GreaterEqualThan = 7, - #[serde(rename = "<<")] + #[estree(rename = "<<")] ShiftLeft = 8, - #[serde(rename = ">>")] + #[estree(rename = ">>")] ShiftRight = 9, - #[serde(rename = ">>>")] + #[estree(rename = ">>>")] ShiftRightZeroFill = 10, - #[serde(rename = "+")] + #[estree(rename = "+")] Addition = 11, - #[serde(rename = "-")] + #[estree(rename = "-")] Subtraction = 12, - #[serde(rename = "*")] + #[estree(rename = "*")] Multiplication = 13, - #[serde(rename = "/")] + #[estree(rename = "/")] Division = 14, - #[serde(rename = "%")] + #[estree(rename = "%")] Remainder = 15, - #[serde(rename = "|")] + #[estree(rename = "|")] BitwiseOR = 16, - #[serde(rename = "^")] + #[estree(rename = "^")] BitwiseXOR = 17, - #[serde(rename = "&")] + #[estree(rename = "&")] BitwiseAnd = 18, - #[serde(rename = "in")] + #[estree(rename = "in")] In = 19, - #[serde(rename = "instanceof")] + #[estree(rename = "instanceof")] Instanceof = 20, - #[serde(rename = "**")] + #[estree(rename = "**")] Exponential = 21, } @@ -280,14 +281,14 @@ impl GetPrecedence for BinaryOperator { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum LogicalOperator { - #[serde(rename = "||")] + #[estree(rename = "||")] Or = 0, - #[serde(rename = "&&")] + #[estree(rename = "&&")] And = 1, - #[serde(rename = "??")] + #[estree(rename = "??")] Coalesce = 2, } @@ -321,22 +322,22 @@ impl GetPrecedence for LogicalOperator { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum UnaryOperator { - #[serde(rename = "-")] + #[estree(rename = "-")] UnaryNegation = 0, - #[serde(rename = "+")] + #[estree(rename = "+")] UnaryPlus = 1, - #[serde(rename = "!")] + #[estree(rename = "!")] LogicalNot = 2, - #[serde(rename = "~")] + #[estree(rename = "~")] BitwiseNot = 3, - #[serde(rename = "typeof")] + #[estree(rename = "typeof")] Typeof = 4, - #[serde(rename = "void")] + #[estree(rename = "void")] Void = 5, - #[serde(rename = "delete")] + #[estree(rename = "delete")] Delete = 6, } @@ -379,12 +380,12 @@ impl UnaryOperator { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum UpdateOperator { - #[serde(rename = "++")] + #[estree(rename = "++")] Increment = 0, - #[serde(rename = "--")] + #[estree(rename = "--")] Decrement = 1, } diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index beece941b586d..e06efd467266c 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -4,7 +4,7 @@ use quote::quote; use super::{define_derive, Derive, DeriveOutput}; use crate::{ codegen::LateCtx, - schema::{GetGenerics, GetIdent, TypeDef}, + schema::{EnumDef, GetGenerics, GetIdent, TypeDef}, }; define_derive! { @@ -13,23 +13,31 @@ define_derive! { impl Derive for DeriveESTree { fn trait_name() -> &'static str { - "Serialize" + "ESTree" } fn derive(&mut self, def: &TypeDef, _: &LateCtx) -> TokenStream { let ident = def.ident(); if let TypeDef::Struct(it) = def { + println!("{ident:?} {:?}", it.markers.estree); for field in &it.fields { - println!("{:?}: {:?}", field.name, field.markers.derive_attributes.estree); + println!("- {:?}: {:?}", field.name, field.markers.derive_attributes.estree); } } + + // let body = match def { + // TypeDef::Enum(def) => serialize_enum(def), + // _ => quote! { serializer.serialize_none() }, + // }; + let body = quote! { serializer.serialize_none() }; + if def.has_lifetime() { quote! { impl<'a> Serialize for #ident<'a> { fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + #body } } } @@ -39,7 +47,7 @@ impl Derive for DeriveESTree { fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + #body } } } @@ -52,3 +60,18 @@ impl Derive for DeriveESTree { } } } + +fn serialize_enum(def: &EnumDef) -> TokenStream { + let ident = def.ident(); + // if def.markers.estree.untagged { + // let match_branches = def.variants.iter().map(|var| { + // let var_ident= var.ident(); + // var.fields + // quote! { + // #ident::#var_ident() + // } + // }) + // } + // def.markers.estree. + todo!() +} diff --git a/tasks/ast_tools/src/derives/mod.rs b/tasks/ast_tools/src/derives/mod.rs index 8a809ef1802b0..34d5c4bf0399f 100644 --- a/tasks/ast_tools/src/derives/mod.rs +++ b/tasks/ast_tools/src/derives/mod.rs @@ -45,9 +45,10 @@ macro_rules! define_derive { let use_modules = module_paths.into_iter().map(|it|{ let local_path = ["crate"] .into_iter() - .chain(it.split("::").skip(1)) + .chain(it.strip_suffix("::mod").unwrap_or(it).split("::").skip(1)) .chain(["*"]) .join("::"); + println!("{local_path}"); let use_module: syn::ItemUse = syn::parse_str(format!("use {local_path};").as_str()).unwrap(); quote::quote! { diff --git a/tasks/ast_tools/src/markers.rs b/tasks/ast_tools/src/markers.rs index 468c22262d6cc..83ea27bf98ada 100644 --- a/tasks/ast_tools/src/markers.rs +++ b/tasks/ast_tools/src/markers.rs @@ -12,8 +12,6 @@ use syn::{ use crate::util::NormalizeError; -const ESTREE_ATTR: &str = "serde"; - /// A single visit argument passed via `#[visit(args(...))]` #[derive(Debug, Clone)] pub struct VisitArg { @@ -76,7 +74,7 @@ pub struct ScopeMarkers { #[derive(Debug, Default, Serialize)] pub struct DeriveAttributes { pub clone_in: CloneInAttribute, - pub estree: Vec, + pub estree: ESTreeFieldAttribute, } /// A enum representing the value passed in `#[clone_in(...)]` derive helper attribute. @@ -98,54 +96,113 @@ impl From<&Ident> for CloneInAttribute { } /// A struct representing the serde attributes (`$[serde(...)]`) that we implement for structs and enums. -#[derive(Debug, Serialize)] -pub enum ESTreeOuterAttribute { - Tag(String), - Rename(String), - RenameAll(String), - Untagged, +#[derive(Debug, Serialize, Default)] +pub struct ESTreeOuterAttribute { + pub tag: Option, + pub rename: Option, + pub rename_all: Option, + pub untagged: bool, } impl Parse for ESTreeOuterAttribute { fn parse(input: ParseStream) -> Result { - let ident = input.call(Ident::parse_any).unwrap().to_string(); - Ok(match ident.as_str() { - "tag" => { - input.parse::()?; - let tag = input.parse::()?.value(); - Self::Tag(tag) - } - "rename" => { - input.parse::()?; - let rename = input.parse::()?.value(); - Self::Rename(rename) + let mut tag = None; + let mut rename = None; + let mut rename_all = None; + let mut untagged = false; + + loop { + let ident = input.call(Ident::parse_any).unwrap().to_string(); + match ident.as_str() { + "tag" => { + input.parse::()?; + assert!( + tag.replace(input.parse::()?.value()).is_none(), + "Duplicate estree(tag)" + ); + } + "rename" => { + input.parse::()?; + assert!( + rename.replace(input.parse::()?.value()).is_none(), + "Duplicate estree(rename)" + ); + } + "rename_all" => { + input.parse::()?; + assert!( + rename_all.replace(input.parse::()?.value()).is_none(), + "Duplicate estree(rename_all)" + ); + } + "untagged" => { + if untagged { + panic!("Duplicate estree(untagged)"); + } else { + untagged = true; + } + } + arg => panic!("Unsupported #[estree(...)] argument: {arg}"), } - "rename_all" => { - input.parse::()?; - let rename = input.parse::()?.value(); - Self::RenameAll(rename) + let comma = input.peek(Token![,]); + if comma { + input.parse::().unwrap(); + } else { + break; } - "untagged" => Self::Untagged, - arg => panic!("Unsupported #[{ESTREE_ATTR}(...)] argument: {arg}"), - }) + } + Ok(Self { tag, rename, rename_all, untagged }) } } /// A struct representing the serde attributes (`$[serde(...)]`) that we implement for fields. -#[derive(Debug, Serialize)] -pub enum ESTreeFieldAttribute { - Flatten, - Skip, +#[derive(Debug, Serialize, Default)] +pub struct ESTreeFieldAttribute { + pub flatten: bool, + pub skip: bool, + pub rename: Option, } impl Parse for ESTreeFieldAttribute { fn parse(input: ParseStream) -> Result { - let ident = input.call(Ident::parse_any).unwrap().to_string(); - Ok(match ident.as_str() { - "flatten" => Self::Flatten, - "skip" => Self::Skip, - arg => panic!("Unsupported #[{ESTREE_ATTR}(...)] argument: {arg}"), - }) + let mut flatten = false; + let mut skip = false; + let mut rename = None; + + loop { + let ident = input.call(Ident::parse_any).unwrap().to_string(); + match ident.as_str() { + "rename" => { + input.parse::()?; + assert!( + rename.replace(input.parse::()?.value()).is_none(), + "Duplicate estree(rename)" + ); + } + "flatten" => { + if flatten { + panic!("Duplicate estree(flatten)"); + } else { + flatten = true; + } + } + "skip" => { + if skip { + panic!("Duplicate estree(skip)"); + } else { + skip = true; + } + } + arg => panic!("Unsupported #[estree(...)] argument: {arg}"), + } + let comma = input.peek(Token![,]); + if comma { + input.parse::().unwrap(); + } else { + break; + } + } + Ok(Self { flatten, skip, rename }) } } @@ -283,14 +340,10 @@ where Ok(None) } } - fn try_parse_estree(attr: &Attribute) -> crate::Result>> { - if attr.path().is_ident(ESTREE_ATTR) { - let args = attr - .parse_args_with(Punctuated::::parse_terminated) - .normalize()? - .into_iter() - .collect(); - Ok(Some(args)) + fn try_parse_estree(attr: &Attribute) -> crate::Result> { + if attr.path().is_ident("estree") { + let arg = attr.parse_args_with(ESTreeFieldAttribute::parse).normalize()?; + Ok(Some(arg)) } else { Ok(None) } @@ -302,7 +355,7 @@ where assert!(clone_in.replace(attr).is_none(), "Duplicate `#[clone_in(...)]` attribute."); } if let Some(attr) = try_parse_estree(attr)? { - assert!(estree.replace(attr).is_none(), "Duplicate `#[{ESTREE_ATTR}(...)]` attribute."); + assert!(estree.replace(attr).is_none(), "Duplicate `#[estree(...)]` attribute."); } } Ok(DeriveAttributes { @@ -329,20 +382,13 @@ where }) } -pub fn get_estree_attribute<'a, I>(attrs: I) -> Option>> +pub fn get_estree_attribute<'a, I>(attrs: I) -> Option> where I: IntoIterator, { - let attr = attrs.into_iter().find(|it| it.path().is_ident(ESTREE_ATTR)); + let attr = attrs.into_iter().find(|it| it.path().is_ident("estree")); attr.map(|attr| { - debug_assert!(attr.path().is_ident("scope")); - let result = if matches!(attr.meta, Meta::Path(_)) { - // empty `#[scope]`. - Ok(ScopeAttribute::default()) - } else { - attr.parse_args_with(ScopeAttribute::parse) - }; - - result.normalize() + debug_assert!(attr.path().is_ident("estree")); + attr.parse_args_with(ESTreeOuterAttribute::parse).normalize() }) } diff --git a/tasks/ast_tools/src/schema/defs.rs b/tasks/ast_tools/src/schema/defs.rs index 512713e87b489..eb9de3c547595 100644 --- a/tasks/ast_tools/src/schema/defs.rs +++ b/tasks/ast_tools/src/schema/defs.rs @@ -84,6 +84,8 @@ pub struct EnumDef { pub generated_derives: Vec, #[serde(skip)] pub module_path: String, + #[serde(skip)] + pub markers: OuterMarkers, } impl EnumDef { @@ -228,7 +230,7 @@ impl TypeRef { #[derive(Debug)] pub struct OuterMarkers { pub scope: Option, - pub estree: Vec, + pub estree: ESTreeOuterAttribute, } #[derive(Debug, Serialize)] diff --git a/tasks/ast_tools/src/schema/mod.rs b/tasks/ast_tools/src/schema/mod.rs index 5afa37e2b62ae..2a5651d9710ee 100644 --- a/tasks/ast_tools/src/schema/mod.rs +++ b/tasks/ast_tools/src/schema/mod.rs @@ -109,7 +109,7 @@ impl<'a> IntoIterator for &'a Schema { fn parse_outer_markers(attrs: &Vec) -> Result { Ok(OuterMarkers { scope: get_scope_attribute(attrs).transpose()?, - estree: get_estree_attribute(attrs).transpose()?, + estree: get_estree_attribute(attrs).transpose()?.unwrap_or_default(), }) } @@ -173,6 +173,7 @@ fn lower_ast_enum(it @ rust::Enum { item, meta }: &rust::Enum, ctx: &codegen::Ea align_32, offsets_32, + markers: parse_outer_markers(&item.attrs).unwrap(), generated_derives: parse_generate_derive(&item.attrs), module_path: meta.module_path.clone(), From a478deaa04a782f41c85fb272083c8d0e4e4f796 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 10 Oct 2024 15:33:07 -0700 Subject: [PATCH 05/28] Finished --- crates/oxc_ast/src/ast/js.rs | 101 +- crates/oxc_ast/src/ast/jsx.rs | 15 - crates/oxc_ast/src/ast/literal.rs | 9 +- crates/oxc_ast/src/ast/ts.rs | 85 +- crates/oxc_ast/src/generated/derive_estree.rs | 2743 +++++++++++++++-- crates/oxc_regular_expression/src/ast.rs | 21 - .../src/generated/derive_estree.rs | 294 +- .../oxc_span/src/generated/derive_estree.rs | 43 +- crates/oxc_span/src/lib.rs | 5 + crates/oxc_span/src/source_type/mod.rs | 5 +- .../oxc_syntax/src/generated/derive_estree.rs | 168 +- crates/oxc_syntax/src/operator.rs | 5 + tasks/ast_tools/src/derives/estree.rs | 138 +- tasks/ast_tools/src/derives/mod.rs | 1 - tasks/ast_tools/src/markers.rs | 56 +- tasks/ast_tools/src/schema/defs.rs | 18 +- tasks/ast_tools/src/schema/mod.rs | 14 +- 17 files changed, 3128 insertions(+), 593 deletions(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 5c4d06001fc7d..76f64d96eb5f2 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -33,7 +33,6 @@ use super::{macros::inherit_variants, *}; #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct Program<'a> { #[estree(flatten)] pub span: Span, @@ -205,7 +204,7 @@ pub use match_expression; #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[estree(tag = "type", rename = "Identifier")] +#[estree(type = "Identifier")] pub struct IdentifierName<'a> { #[estree(flatten)] pub span: Span, @@ -220,7 +219,7 @@ pub struct IdentifierName<'a> { #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[estree(tag = "type", rename = "Identifier")] +#[estree(type = "Identifier")] pub struct IdentifierReference<'a> { #[estree(flatten)] pub span: Span, @@ -244,7 +243,7 @@ pub struct IdentifierReference<'a> { #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[estree(tag = "type", rename = "Identifier")] +#[estree(type = "Identifier")] pub struct BindingIdentifier<'a> { #[estree(flatten)] pub span: Span, @@ -269,7 +268,7 @@ pub struct BindingIdentifier<'a> { #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[estree(tag = "type", rename = "Identifier")] +#[estree(type = "Identifier")] pub struct LabelIdentifier<'a> { #[estree(flatten)] pub span: Span, @@ -283,7 +282,6 @@ pub struct LabelIdentifier<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ThisExpression { #[estree(flatten)] pub span: Span, @@ -296,7 +294,6 @@ pub struct ThisExpression { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct ArrayExpression<'a> { #[estree(flatten)] pub span: Span, @@ -349,7 +346,6 @@ pub struct Elision { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ObjectExpression<'a> { #[estree(flatten)] pub span: Span, @@ -379,7 +375,6 @@ pub enum ObjectPropertyKind<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ObjectProperty<'a> { #[estree(flatten)] pub span: Span, @@ -435,7 +430,6 @@ pub enum PropertyKind { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TemplateLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -450,7 +444,6 @@ pub struct TemplateLiteral<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TaggedTemplateExpression<'a> { #[estree(flatten)] pub span: Span, @@ -466,7 +459,6 @@ pub struct TaggedTemplateExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TemplateElement<'a> { #[estree(flatten)] pub span: Span, @@ -479,6 +471,7 @@ pub struct TemplateElement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(no_type)] pub struct TemplateElementValue<'a> { /// A raw interpretation where backslashes do not have special meaning. /// For example, \t produces two characters – a backslash and a t. @@ -526,7 +519,6 @@ pub use match_member_expression; #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ComputedMemberExpression<'a> { #[estree(flatten)] pub span: Span, @@ -542,7 +534,6 @@ pub struct ComputedMemberExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct StaticMemberExpression<'a> { #[estree(flatten)] pub span: Span, @@ -558,7 +549,6 @@ pub struct StaticMemberExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct PrivateFieldExpression<'a> { #[estree(flatten)] pub span: Span, @@ -587,7 +577,6 @@ pub struct PrivateFieldExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct CallExpression<'a> { #[estree(flatten)] pub span: Span, @@ -613,7 +602,6 @@ pub struct CallExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct NewExpression<'a> { #[estree(flatten)] pub span: Span, @@ -629,7 +617,6 @@ pub struct NewExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct MetaProperty<'a> { #[estree(flatten)] pub span: Span, @@ -644,7 +631,6 @@ pub struct MetaProperty<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct SpreadElement<'a> { #[estree(flatten)] pub span: Span, @@ -678,7 +664,6 @@ pub enum Argument<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct UpdateExpression<'a> { #[estree(flatten)] pub span: Span, @@ -694,7 +679,6 @@ pub struct UpdateExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct UnaryExpression<'a> { #[estree(flatten)] pub span: Span, @@ -709,7 +693,6 @@ pub struct UnaryExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct BinaryExpression<'a> { #[estree(flatten)] pub span: Span, @@ -725,7 +708,6 @@ pub struct BinaryExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct PrivateInExpression<'a> { #[estree(flatten)] pub span: Span, @@ -741,7 +723,6 @@ pub struct PrivateInExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct LogicalExpression<'a> { #[estree(flatten)] pub span: Span, @@ -757,7 +738,6 @@ pub struct LogicalExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ConditionalExpression<'a> { #[estree(flatten)] pub span: Span, @@ -773,7 +753,6 @@ pub struct ConditionalExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct AssignmentExpression<'a> { #[estree(flatten)] pub span: Span, @@ -889,7 +868,6 @@ pub use match_assignment_target_pattern; #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ArrayAssignmentTarget<'a> { #[estree(flatten)] pub span: Span, @@ -908,7 +886,6 @@ pub struct ArrayAssignmentTarget<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ObjectAssignmentTarget<'a> { #[estree(flatten)] pub span: Span, @@ -924,7 +901,7 @@ pub struct ObjectAssignmentTarget<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[estree(tag = "type", rename = "RestElement")] +#[estree(type = "RestElement")] pub struct AssignmentTargetRest<'a> { #[estree(flatten)] pub span: Span, @@ -954,7 +931,6 @@ pub enum AssignmentTargetMaybeDefault<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct AssignmentTargetWithDefault<'a> { #[estree(flatten)] pub span: Span, @@ -979,7 +955,6 @@ pub enum AssignmentTargetProperty<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct AssignmentTargetPropertyIdentifier<'a> { #[estree(flatten)] pub span: Span, @@ -994,7 +969,6 @@ pub struct AssignmentTargetPropertyIdentifier<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct AssignmentTargetPropertyProperty<'a> { #[estree(flatten)] pub span: Span, @@ -1009,7 +983,6 @@ pub struct AssignmentTargetPropertyProperty<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct SequenceExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1023,7 +996,6 @@ pub struct SequenceExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Super { #[estree(flatten)] pub span: Span, @@ -1036,7 +1008,6 @@ pub struct Super { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct AwaitExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1050,7 +1021,6 @@ pub struct AwaitExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ChainExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1082,7 +1052,6 @@ pub enum ChainElement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ParenthesizedExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1135,7 +1104,6 @@ pub enum Statement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Directive<'a> { #[estree(flatten)] pub span: Span, @@ -1152,7 +1120,6 @@ pub struct Directive<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Hashbang<'a> { #[estree(flatten)] pub span: Span, @@ -1167,7 +1134,6 @@ pub struct Hashbang<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct BlockStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1219,7 +1185,6 @@ pub use match_declaration; #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct VariableDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1254,7 +1219,6 @@ pub enum VariableDeclarationKind { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct VariableDeclarator<'a> { #[estree(flatten)] pub span: Span, @@ -1270,7 +1234,6 @@ pub struct VariableDeclarator<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct EmptyStatement { #[estree(flatten)] pub span: Span, @@ -1281,7 +1244,6 @@ pub struct EmptyStatement { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ExpressionStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1293,7 +1255,6 @@ pub struct ExpressionStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct IfStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1307,7 +1268,6 @@ pub struct IfStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct DoWhileStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1320,7 +1280,6 @@ pub struct DoWhileStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct WhileStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1334,7 +1293,6 @@ pub struct WhileStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ForStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1371,7 +1329,6 @@ pub enum ForStatementInit<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ForInStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1406,7 +1363,6 @@ pub enum ForStatementLeft<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ForOfStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1424,7 +1380,6 @@ pub struct ForOfStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ContinueStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1436,7 +1391,6 @@ pub struct ContinueStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct BreakStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1448,7 +1402,6 @@ pub struct BreakStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ReturnStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1460,7 +1413,6 @@ pub struct ReturnStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct WithStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1474,7 +1426,6 @@ pub struct WithStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct SwitchStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1490,7 +1441,6 @@ pub struct SwitchStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct SwitchCase<'a> { #[estree(flatten)] pub span: Span, @@ -1503,7 +1453,6 @@ pub struct SwitchCase<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct LabeledStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1522,7 +1471,6 @@ pub struct LabeledStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ThrowStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1549,7 +1497,6 @@ pub struct ThrowStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TryStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1579,7 +1526,6 @@ pub struct TryStatement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct CatchClause<'a> { #[estree(flatten)] pub span: Span, @@ -1609,7 +1555,6 @@ pub struct CatchClause<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct CatchParameter<'a> { #[estree(flatten)] pub span: Span, @@ -1628,7 +1573,6 @@ pub struct CatchParameter<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct DebuggerStatement { #[estree(flatten)] pub span: Span, @@ -1640,7 +1584,7 @@ pub struct DebuggerStatement { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "camelCase")] +#[estree(no_type)] pub struct BindingPattern<'a> { // serde(flatten) the attributes because estree has no `BindingPattern` #[estree(flatten)] @@ -1674,7 +1618,6 @@ pub enum BindingPatternKind<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct AssignmentPattern<'a> { #[estree(flatten)] pub span: Span, @@ -1687,7 +1630,6 @@ pub struct AssignmentPattern<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ObjectPattern<'a> { #[estree(flatten)] pub span: Span, @@ -1701,7 +1643,6 @@ pub struct ObjectPattern<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct BindingProperty<'a> { #[estree(flatten)] pub span: Span, @@ -1716,7 +1657,6 @@ pub struct BindingProperty<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ArrayPattern<'a> { #[estree(flatten)] pub span: Span, @@ -1738,7 +1678,7 @@ pub struct ArrayPattern<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[estree(tag = "type", rename = "RestElement")] +#[estree(type = "RestElement")] pub struct BindingRestElement<'a> { #[estree(flatten)] pub span: Span, @@ -1789,7 +1729,6 @@ pub struct BindingRestElement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "camelCase")] pub struct Function<'a> { pub r#type: FunctionType, #[estree(flatten)] @@ -1865,7 +1804,6 @@ pub enum FunctionType { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct FormalParameters<'a> { #[estree(flatten)] pub span: Span, @@ -1880,7 +1818,6 @@ pub struct FormalParameters<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct FormalParameter<'a> { #[estree(flatten)] pub span: Span, @@ -1895,6 +1832,7 @@ pub struct FormalParameter<'a> { #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum FormalParameterKind { /// FormalParameter = 0, @@ -1911,7 +1849,6 @@ pub enum FormalParameterKind { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct FunctionBody<'a> { #[estree(flatten)] pub span: Span, @@ -1928,7 +1865,6 @@ pub struct FunctionBody<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct ArrowFunctionExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1950,7 +1886,6 @@ pub struct ArrowFunctionExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct YieldExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1964,7 +1899,6 @@ pub struct YieldExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "camelCase")] pub struct Class<'a> { pub r#type: ClassType, #[estree(flatten)] @@ -2055,7 +1989,6 @@ pub enum ClassType { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ClassBody<'a> { #[estree(flatten)] pub span: Span, @@ -2108,7 +2041,6 @@ pub enum ClassElement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "camelCase")] pub struct MethodDefinition<'a> { /// Method definition type /// @@ -2146,7 +2078,6 @@ pub enum MethodDefinitionType { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "camelCase")] pub struct PropertyDefinition<'a> { pub r#type: PropertyDefinitionType, #[estree(flatten)] @@ -2256,7 +2187,6 @@ pub enum MethodDefinitionKind { #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct PrivateIdentifier<'a> { #[estree(flatten)] pub span: Span, @@ -2281,7 +2211,6 @@ pub struct PrivateIdentifier<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct StaticBlock<'a> { #[estree(flatten)] pub span: Span, @@ -2372,7 +2301,6 @@ pub enum AccessorPropertyType { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "camelCase")] pub struct AccessorProperty<'a> { pub r#type: AccessorPropertyType, #[estree(flatten)] @@ -2416,7 +2344,6 @@ pub struct AccessorProperty<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ImportExpression<'a> { #[estree(flatten)] pub span: Span, @@ -2428,7 +2355,6 @@ pub struct ImportExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct ImportDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -2462,7 +2388,6 @@ pub enum ImportDeclarationSpecifier<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct ImportSpecifier<'a> { #[estree(flatten)] pub span: Span, @@ -2493,7 +2418,6 @@ pub struct ImportSpecifier<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ImportDefaultSpecifier<'a> { #[estree(flatten)] pub span: Span, @@ -2511,7 +2435,6 @@ pub struct ImportDefaultSpecifier<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ImportNamespaceSpecifier<'a> { #[estree(flatten)] pub span: Span, @@ -2522,7 +2445,6 @@ pub struct ImportNamespaceSpecifier<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct WithClause<'a> { #[estree(flatten)] pub span: Span, @@ -2534,7 +2456,6 @@ pub struct WithClause<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ImportAttribute<'a> { #[estree(flatten)] pub span: Span, @@ -2567,7 +2488,6 @@ pub enum ImportAttributeKey<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct ExportNamedDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -2593,7 +2513,6 @@ pub struct ExportNamedDeclaration<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ExportDefaultDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -2614,7 +2533,6 @@ pub struct ExportDefaultDeclaration<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct ExportAllDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -2641,7 +2559,6 @@ pub struct ExportAllDeclaration<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct ExportSpecifier<'a> { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_ast/src/ast/jsx.rs b/crates/oxc_ast/src/ast/jsx.rs index c70b05d42d253..6be9ce56e373e 100644 --- a/crates/oxc_ast/src/ast/jsx.rs +++ b/crates/oxc_ast/src/ast/jsx.rs @@ -39,7 +39,6 @@ use super::{inherit_variants, js::*, literal::*, ts::*}; #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct JSXElement<'a> { #[estree(flatten)] pub span: Span, @@ -70,7 +69,6 @@ pub struct JSXElement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct JSXOpeningElement<'a> { #[estree(flatten)] pub span: Span, @@ -104,7 +102,6 @@ pub struct JSXOpeningElement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXClosingElement<'a> { #[estree(flatten)] pub span: Span, @@ -123,7 +120,6 @@ pub struct JSXClosingElement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct JSXFragment<'a> { #[estree(flatten)] pub span: Span, @@ -140,7 +136,6 @@ pub struct JSXFragment<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXOpeningFragment { #[estree(flatten)] pub span: Span, @@ -151,7 +146,6 @@ pub struct JSXOpeningFragment { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXClosingFragment { #[estree(flatten)] pub span: Span, @@ -186,7 +180,6 @@ pub enum JSXElementName<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXNamespacedName<'a> { #[estree(flatten)] pub span: Span, @@ -215,7 +208,6 @@ pub struct JSXNamespacedName<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXMemberExpression<'a> { #[estree(flatten)] pub span: Span, @@ -252,7 +244,6 @@ pub enum JSXMemberExpressionObject<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXExpressionContainer<'a> { #[estree(flatten)] pub span: Span, @@ -284,7 +275,6 @@ pub enum JSXExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXEmptyExpression { #[estree(flatten)] pub span: Span, @@ -328,7 +318,6 @@ pub enum JSXAttributeItem<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXAttribute<'a> { #[estree(flatten)] pub span: Span, @@ -351,7 +340,6 @@ pub struct JSXAttribute<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXSpreadAttribute<'a> { #[estree(flatten)] pub span: Span, @@ -424,7 +412,6 @@ pub enum JSXAttributeValue<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXIdentifier<'a> { #[estree(flatten)] pub span: Span, @@ -462,7 +449,6 @@ pub enum JSXChild<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXSpreadChild<'a> { #[estree(flatten)] pub span: Span, @@ -484,7 +470,6 @@ pub struct JSXSpreadChild<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct JSXText<'a> { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_ast/src/ast/literal.rs b/crates/oxc_ast/src/ast/literal.rs index 8f09351752ce7..4c1074f8c9d80 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -26,7 +26,6 @@ use tsify::Tsify; #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct BooleanLiteral { #[estree(flatten)] pub span: Span, @@ -40,7 +39,6 @@ pub struct BooleanLiteral { #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct NullLiteral { #[estree(flatten)] pub span: Span, @@ -53,7 +51,6 @@ pub struct NullLiteral { #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct NumericLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -71,7 +68,6 @@ pub struct NumericLiteral<'a> { #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct BigIntLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -89,7 +85,6 @@ pub struct BigIntLiteral<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct RegExpLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -106,6 +101,7 @@ pub struct RegExpLiteral<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(no_type)] pub struct RegExp<'a> { /// The regex pattern between the slashes pub pattern: RegExpPattern<'a>, @@ -120,6 +116,7 @@ pub struct RegExp<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(untagged)] pub enum RegExpPattern<'a> { /// Unparsed pattern. Contains string slice of the pattern. /// Pattern was not parsed, so may be valid or invalid. @@ -136,6 +133,7 @@ pub enum RegExpPattern<'a> { #[derive(Debug, Clone)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(no_type)] pub struct EmptyObject; /// String literal @@ -145,7 +143,6 @@ pub struct EmptyObject; #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct StringLiteral<'a> { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index fa46ad2505104..e0ad5dead0b49 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -46,7 +46,6 @@ export interface TSIndexSignatureName extends Span { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSThisParameter<'a> { #[estree(flatten)] pub span: Span, @@ -80,7 +79,6 @@ pub struct TSThisParameter<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSEnumDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -116,7 +114,6 @@ pub struct TSEnumDeclaration<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSEnumMember<'a> { #[estree(flatten)] pub span: Span, @@ -164,7 +161,6 @@ pub enum TSEnumMemberName<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeAnnotation<'a> { #[estree(flatten)] /// starts at the `:` token and ends at the end of the type annotation @@ -191,7 +187,6 @@ pub struct TSTypeAnnotation<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSLiteralType<'a> { #[estree(flatten)] pub span: Span, @@ -203,7 +198,7 @@ pub struct TSLiteralType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(untagged, rename_all = "camelCase")] +#[estree(untagged)] pub enum TSLiteral<'a> { BooleanLiteral(Box<'a, BooleanLiteral>) = 0, NullLiteral(Box<'a, NullLiteral>) = 1, @@ -230,7 +225,7 @@ pub enum TSLiteral<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(untagged, rename_all = "camelCase")] +#[estree(untagged)] pub enum TSType<'a> { // Keyword TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0, @@ -339,7 +334,6 @@ pub use match_ts_type; #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSConditionalType<'a> { #[estree(flatten)] pub span: Span, @@ -371,7 +365,6 @@ pub struct TSConditionalType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSUnionType<'a> { #[estree(flatten)] pub span: Span, @@ -396,7 +389,6 @@ pub struct TSUnionType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSIntersectionType<'a> { #[estree(flatten)] pub span: Span, @@ -416,7 +408,6 @@ pub struct TSIntersectionType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSParenthesizedType<'a> { #[estree(flatten)] pub span: Span, @@ -436,7 +427,6 @@ pub struct TSParenthesizedType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeOperator<'a> { #[estree(flatten)] pub span: Span, @@ -472,7 +462,6 @@ pub enum TSTypeOperatorOperator { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSArrayType<'a> { #[estree(flatten)] pub span: Span, @@ -494,7 +483,6 @@ pub struct TSArrayType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSIndexedAccessType<'a> { #[estree(flatten)] pub span: Span, @@ -515,7 +503,6 @@ pub struct TSIndexedAccessType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTupleType<'a> { #[estree(flatten)] pub span: Span, @@ -536,7 +523,6 @@ pub struct TSTupleType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSNamedTupleMember<'a> { #[estree(flatten)] pub span: Span, @@ -558,7 +544,6 @@ pub struct TSNamedTupleMember<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSOptionalType<'a> { #[estree(flatten)] pub span: Span, @@ -577,7 +562,6 @@ pub struct TSOptionalType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSRestType<'a> { #[estree(flatten)] pub span: Span, @@ -596,7 +580,7 @@ inherit_variants! { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(untagged, rename_all = "camelCase")] +#[estree(untagged)] pub enum TSTupleElement<'a> { // Discriminants start at 64, so that `TSTupleElement::is_ts_type` is a single // bitwise AND operation on the discriminant (`discriminant & 63 != 0`). @@ -620,7 +604,6 @@ pub enum TSTupleElement<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSAnyKeyword { #[estree(flatten)] pub span: Span, @@ -639,7 +622,6 @@ pub struct TSAnyKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSStringKeyword { #[estree(flatten)] pub span: Span, @@ -658,7 +640,6 @@ pub struct TSStringKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSBooleanKeyword { #[estree(flatten)] pub span: Span, @@ -677,7 +658,6 @@ pub struct TSBooleanKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSNumberKeyword { #[estree(flatten)] pub span: Span, @@ -697,7 +677,6 @@ pub struct TSNumberKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSNeverKeyword { #[estree(flatten)] pub span: Span, @@ -717,7 +696,6 @@ pub struct TSNeverKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSIntrinsicKeyword { #[estree(flatten)] pub span: Span, @@ -738,7 +716,6 @@ pub struct TSIntrinsicKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSUnknownKeyword { #[estree(flatten)] pub span: Span, @@ -758,7 +735,6 @@ pub struct TSUnknownKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSNullKeyword { #[estree(flatten)] pub span: Span, @@ -780,7 +756,6 @@ pub struct TSNullKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSUndefinedKeyword { #[estree(flatten)] pub span: Span, @@ -790,7 +765,6 @@ pub struct TSUndefinedKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSVoidKeyword { #[estree(flatten)] pub span: Span, @@ -800,7 +774,6 @@ pub struct TSVoidKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSSymbolKeyword { #[estree(flatten)] pub span: Span, @@ -810,7 +783,6 @@ pub struct TSSymbolKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSThisType { #[estree(flatten)] pub span: Span, @@ -820,7 +792,6 @@ pub struct TSThisType { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSObjectKeyword { #[estree(flatten)] pub span: Span, @@ -830,7 +801,6 @@ pub struct TSObjectKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct TSBigIntKeyword { #[estree(flatten)] pub span: Span, @@ -848,7 +818,6 @@ pub struct TSBigIntKeyword { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeReference<'a> { #[estree(flatten)] pub span: Span, @@ -890,7 +859,6 @@ pub use match_ts_type_name; #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSQualifiedName<'a> { #[estree(flatten)] pub span: Span, @@ -902,7 +870,6 @@ pub struct TSQualifiedName<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeParameterInstantiation<'a> { #[estree(flatten)] pub span: Span, @@ -930,7 +897,6 @@ pub struct TSTypeParameterInstantiation<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeParameter<'a> { #[estree(flatten)] pub span: Span, @@ -952,7 +918,6 @@ pub struct TSTypeParameter<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeParameterDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -972,7 +937,6 @@ pub struct TSTypeParameterDeclaration<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeAliasDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1012,7 +976,6 @@ pub enum TSAccessibility { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSClassImplements<'a> { #[estree(flatten)] pub span: Span, @@ -1040,7 +1003,6 @@ pub struct TSClassImplements<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInterfaceDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1064,7 +1026,6 @@ pub struct TSInterfaceDeclaration<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInterfaceBody<'a> { #[estree(flatten)] pub span: Span, @@ -1090,7 +1051,6 @@ pub struct TSInterfaceBody<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSPropertySignature<'a> { #[estree(flatten)] pub span: Span, @@ -1105,7 +1065,7 @@ pub struct TSPropertySignature<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(untagged, rename_all = "camelCase")] +#[estree(untagged)] pub enum TSSignature<'a> { TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0, TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1, @@ -1129,7 +1089,6 @@ pub enum TSSignature<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSIndexSignature<'a> { #[estree(flatten)] pub span: Span, @@ -1142,7 +1101,6 @@ pub struct TSIndexSignature<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSCallSignatureDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1179,7 +1137,6 @@ pub enum TSMethodSignatureKind { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSMethodSignature<'a> { #[estree(flatten)] pub span: Span, @@ -1202,7 +1159,6 @@ pub struct TSMethodSignature<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSConstructSignatureDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1217,7 +1173,7 @@ pub struct TSConstructSignatureDeclaration<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[estree(tag = "type", rename = "Identifier", rename_all = "camelCase")] +#[estree(type = "Identifier")] pub struct TSIndexSignatureName<'a> { #[estree(flatten)] pub span: Span, @@ -1229,7 +1185,6 @@ pub struct TSIndexSignatureName<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInterfaceHeritage<'a> { #[estree(flatten)] pub span: Span, @@ -1261,7 +1216,6 @@ pub struct TSInterfaceHeritage<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypePredicate<'a> { #[estree(flatten)] pub span: Span, @@ -1281,7 +1235,7 @@ pub struct TSTypePredicate<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(untagged, rename_all = "camelCase")] +#[estree(untagged)] pub enum TSTypePredicateName<'a> { Identifier(Box<'a, IdentifierName<'a>>) = 0, This(TSThisType) = 1, @@ -1321,7 +1275,6 @@ pub enum TSTypePredicateName<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSModuleDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1410,7 +1363,6 @@ pub enum TSModuleDeclarationBody<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSModuleBlock<'a> { #[estree(flatten)] pub span: Span, @@ -1423,7 +1375,6 @@ pub struct TSModuleBlock<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -1447,7 +1398,6 @@ pub struct TSTypeLiteral<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInferType<'a> { #[estree(flatten)] pub span: Span, @@ -1468,7 +1418,6 @@ pub struct TSInferType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeQuery<'a> { #[estree(flatten)] pub span: Span, @@ -1498,7 +1447,6 @@ pub enum TSTypeQueryExprName<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSImportType<'a> { #[estree(flatten)] pub span: Span, @@ -1514,7 +1462,6 @@ pub struct TSImportType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSImportAttributes<'a> { #[estree(flatten)] pub span: Span, @@ -1526,7 +1473,6 @@ pub struct TSImportAttributes<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSImportAttribute<'a> { #[estree(flatten)] pub span: Span, @@ -1556,7 +1502,6 @@ pub enum TSImportAttributeName<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSFunctionType<'a> { #[estree(flatten)] pub span: Span, @@ -1588,7 +1533,6 @@ pub struct TSFunctionType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSConstructorType<'a> { #[estree(flatten)] pub span: Span, @@ -1624,7 +1568,6 @@ pub struct TSConstructorType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSMappedType<'a> { #[estree(flatten)] pub span: Span, @@ -1694,7 +1637,6 @@ pub enum TSMappedTypeModifierOperator { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTemplateLiteralType<'a> { #[estree(flatten)] pub span: Span, @@ -1708,7 +1650,6 @@ pub struct TSTemplateLiteralType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSAsExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1732,7 +1673,6 @@ pub struct TSAsExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSSatisfiesExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1746,7 +1686,6 @@ pub struct TSSatisfiesExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSTypeAssertion<'a> { #[estree(flatten)] pub span: Span, @@ -1758,7 +1697,6 @@ pub struct TSTypeAssertion<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSImportEqualsDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1777,7 +1715,7 @@ inherit_variants! { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(untagged, rename_all = "camelCase")] +#[estree(untagged)] pub enum TSModuleReference<'a> { ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1789,7 +1727,6 @@ pub enum TSModuleReference<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSExternalModuleReference<'a> { #[estree(flatten)] pub span: Span, @@ -1800,7 +1737,6 @@ pub struct TSExternalModuleReference<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSNonNullExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1835,7 +1771,6 @@ pub struct TSNonNullExpression<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct Decorator<'a> { #[estree(flatten)] pub span: Span, @@ -1849,7 +1784,6 @@ pub struct Decorator<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSExportAssignment<'a> { #[estree(flatten)] pub span: Span, @@ -1863,7 +1797,6 @@ pub struct TSExportAssignment<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSNamespaceExportDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1874,7 +1807,6 @@ pub struct TSNamespaceExportDeclaration<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct TSInstantiationExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1902,7 +1834,6 @@ pub enum ImportOrExportKind { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct JSDocNullableType<'a> { #[estree(flatten)] pub span: Span, @@ -1916,7 +1847,6 @@ pub struct JSDocNullableType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct JSDocNonNullableType<'a> { #[estree(flatten)] pub span: Span, @@ -1928,7 +1858,6 @@ pub struct JSDocNonNullableType<'a> { #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type", rename_all = "camelCase")] pub struct JSDocUnknownType { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs index 1c3c4f895a7a1..81db32b391267 100644 --- a/crates/oxc_ast/src/generated/derive_estree.rs +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -1,7 +1,8 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! // To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` -use serde::{Serialize, Serializer}; +#[allow(unused_imports)] +use serde::{ser::SerializeMap, Serialize, Serializer}; #[allow(clippy::wildcard_imports)] use crate::ast::js::*; @@ -16,2143 +17,4303 @@ use crate::ast::literal::*; use crate::ast::ts::*; impl Serialize for BooleanLiteral { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "BooleanLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl Serialize for NullLiteral { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "NullLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for NumericLiteral<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "NumericLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("value", &self.value)?; + map.serialize_entry("raw", &self.raw)?; + map.end() } } impl<'a> Serialize for BigIntLiteral<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "BigIntLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("raw", &self.raw)?; + map.end() } } impl<'a> Serialize for RegExpLiteral<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "RegExpLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("value", &self.value)?; + map.serialize_entry("regex", &self.regex)?; + map.end() } } impl<'a> Serialize for RegExp<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("pattern", &self.pattern)?; + map.serialize_entry("flags", &self.flags)?; + map.end() } } impl<'a> Serialize for RegExpPattern<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + RegExpPattern::Raw(ref x) => Serialize::serialize(x, serializer), + RegExpPattern::Invalid(ref x) => Serialize::serialize(x, serializer), + RegExpPattern::Pattern(ref x) => Serialize::serialize(x, serializer), + } } } impl Serialize for EmptyObject { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.end() } } impl<'a> Serialize for StringLiteral<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "StringLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl<'a> Serialize for Program<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Program")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("source_type", &self.source_type)?; + map.serialize_entry("hashbang", &self.hashbang)?; + map.serialize_entry("directives", &self.directives)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for Expression<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + Expression::BooleanLiteral(ref x) => Serialize::serialize(x, serializer), + Expression::NullLiteral(ref x) => Serialize::serialize(x, serializer), + Expression::NumericLiteral(ref x) => Serialize::serialize(x, serializer), + Expression::BigIntLiteral(ref x) => Serialize::serialize(x, serializer), + Expression::RegExpLiteral(ref x) => Serialize::serialize(x, serializer), + Expression::StringLiteral(ref x) => Serialize::serialize(x, serializer), + Expression::TemplateLiteral(ref x) => Serialize::serialize(x, serializer), + Expression::Identifier(ref x) => Serialize::serialize(x, serializer), + Expression::MetaProperty(ref x) => Serialize::serialize(x, serializer), + Expression::Super(ref x) => Serialize::serialize(x, serializer), + Expression::ArrayExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ArrowFunctionExpression(ref x) => Serialize::serialize(x, serializer), + Expression::AssignmentExpression(ref x) => Serialize::serialize(x, serializer), + Expression::AwaitExpression(ref x) => Serialize::serialize(x, serializer), + Expression::BinaryExpression(ref x) => Serialize::serialize(x, serializer), + Expression::CallExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ChainExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ClassExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ConditionalExpression(ref x) => Serialize::serialize(x, serializer), + Expression::FunctionExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ImportExpression(ref x) => Serialize::serialize(x, serializer), + Expression::LogicalExpression(ref x) => Serialize::serialize(x, serializer), + Expression::NewExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ObjectExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ParenthesizedExpression(ref x) => Serialize::serialize(x, serializer), + Expression::SequenceExpression(ref x) => Serialize::serialize(x, serializer), + Expression::TaggedTemplateExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ThisExpression(ref x) => Serialize::serialize(x, serializer), + Expression::UnaryExpression(ref x) => Serialize::serialize(x, serializer), + Expression::UpdateExpression(ref x) => Serialize::serialize(x, serializer), + Expression::YieldExpression(ref x) => Serialize::serialize(x, serializer), + Expression::PrivateInExpression(ref x) => Serialize::serialize(x, serializer), + Expression::JSXElement(ref x) => Serialize::serialize(x, serializer), + Expression::JSXFragment(ref x) => Serialize::serialize(x, serializer), + Expression::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + Expression::TSSatisfiesExpression(ref x) => Serialize::serialize(x, serializer), + Expression::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + Expression::TSNonNullExpression(ref x) => Serialize::serialize(x, serializer), + Expression::TSInstantiationExpression(ref x) => Serialize::serialize(x, serializer), + Expression::ComputedMemberExpression(ref x) => Serialize::serialize(x, serializer), + Expression::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + Expression::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for IdentifierName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Identifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() } } impl<'a> Serialize for IdentifierReference<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Identifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() } } impl<'a> Serialize for BindingIdentifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Identifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() } } impl<'a> Serialize for LabelIdentifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Identifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() } } impl Serialize for ThisExpression { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ThisExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for ArrayExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ArrayExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("elements", &self.elements)?; + map.end() } } impl<'a> Serialize for ArrayExpressionElement<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + ArrayExpressionElement::SpreadElement(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::Elision(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::BooleanLiteral(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::NullLiteral(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::NumericLiteral(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::BigIntLiteral(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::RegExpLiteral(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::StringLiteral(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::TemplateLiteral(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::Identifier(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::MetaProperty(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::Super(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::ArrayExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::ArrowFunctionExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::AssignmentExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::AwaitExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::BinaryExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::CallExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::ChainExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::ClassExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::ConditionalExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::FunctionExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::ImportExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::LogicalExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::NewExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::ObjectExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::ParenthesizedExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::SequenceExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::TaggedTemplateExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::ThisExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::UnaryExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::UpdateExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::YieldExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::PrivateInExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::JSXElement(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::JSXFragment(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::TSSatisfiesExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + ArrayExpressionElement::TSNonNullExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::TSInstantiationExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::StaticMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ArrayExpressionElement::PrivateFieldExpression(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl<'a> Serialize for ObjectExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ObjectExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("properties", &self.properties)?; + map.end() } } impl<'a> Serialize for ObjectPropertyKind<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ObjectPropertyKind::ObjectProperty(ref x) => Serialize::serialize(x, serializer), + ObjectPropertyKind::SpreadProperty(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for ObjectProperty<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ObjectProperty")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("kind", &self.kind)?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("value", &self.value)?; + map.serialize_entry("init", &self.init)?; + map.serialize_entry("method", &self.method)?; + map.serialize_entry("shorthand", &self.shorthand)?; + map.serialize_entry("computed", &self.computed)?; + map.end() } } impl<'a> Serialize for PropertyKey<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + PropertyKey::StaticIdentifier(ref x) => Serialize::serialize(x, serializer), + PropertyKey::PrivateIdentifier(ref x) => Serialize::serialize(x, serializer), + PropertyKey::BooleanLiteral(ref x) => Serialize::serialize(x, serializer), + PropertyKey::NullLiteral(ref x) => Serialize::serialize(x, serializer), + PropertyKey::NumericLiteral(ref x) => Serialize::serialize(x, serializer), + PropertyKey::BigIntLiteral(ref x) => Serialize::serialize(x, serializer), + PropertyKey::RegExpLiteral(ref x) => Serialize::serialize(x, serializer), + PropertyKey::StringLiteral(ref x) => Serialize::serialize(x, serializer), + PropertyKey::TemplateLiteral(ref x) => Serialize::serialize(x, serializer), + PropertyKey::Identifier(ref x) => Serialize::serialize(x, serializer), + PropertyKey::MetaProperty(ref x) => Serialize::serialize(x, serializer), + PropertyKey::Super(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ArrayExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ArrowFunctionExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::AssignmentExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::AwaitExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::BinaryExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::CallExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ChainExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ClassExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ConditionalExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::FunctionExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ImportExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::LogicalExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::NewExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ObjectExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ParenthesizedExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::SequenceExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::TaggedTemplateExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ThisExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::UnaryExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::UpdateExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::YieldExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::PrivateInExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::JSXElement(ref x) => Serialize::serialize(x, serializer), + PropertyKey::JSXFragment(ref x) => Serialize::serialize(x, serializer), + PropertyKey::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::TSSatisfiesExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + PropertyKey::TSNonNullExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::TSInstantiationExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::ComputedMemberExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + PropertyKey::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl Serialize for PropertyKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + PropertyKind::Init => serializer.serialize_unit_variant("PropertyKind", 0u32, "init"), + PropertyKind::Get => serializer.serialize_unit_variant("PropertyKind", 1u32, "get"), + PropertyKind::Set => serializer.serialize_unit_variant("PropertyKind", 2u32, "set"), + } } } impl<'a> Serialize for TemplateLiteral<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TemplateLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("quasis", &self.quasis)?; + map.serialize_entry("expressions", &self.expressions)?; + map.end() } } impl<'a> Serialize for TaggedTemplateExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TaggedTemplateExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("tag", &self.tag)?; + map.serialize_entry("quasi", &self.quasi)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TemplateElement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TemplateElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("tail", &self.tail)?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl<'a> Serialize for TemplateElementValue<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("raw", &self.raw)?; + map.serialize_entry("cooked", &self.cooked)?; + map.end() } } impl<'a> Serialize for MemberExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + MemberExpression::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + MemberExpression::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + MemberExpression::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for ComputedMemberExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ComputedMemberExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("object", &self.object)?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("optional", &self.optional)?; + map.end() } } impl<'a> Serialize for StaticMemberExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "StaticMemberExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("object", &self.object)?; + map.serialize_entry("property", &self.property)?; + map.serialize_entry("optional", &self.optional)?; + map.end() } } impl<'a> Serialize for PrivateFieldExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "PrivateFieldExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("object", &self.object)?; + map.serialize_entry("field", &self.field)?; + map.serialize_entry("optional", &self.optional)?; + map.end() } } impl<'a> Serialize for CallExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "CallExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("callee", &self.callee)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("arguments", &self.arguments)?; + map.serialize_entry("optional", &self.optional)?; + map.end() } } impl<'a> Serialize for NewExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "NewExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("callee", &self.callee)?; + map.serialize_entry("arguments", &self.arguments)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for MetaProperty<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "MetaProperty")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("meta", &self.meta)?; + map.serialize_entry("property", &self.property)?; + map.end() } } impl<'a> Serialize for SpreadElement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "SpreadElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for Argument<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + Argument::SpreadElement(ref x) => Serialize::serialize(x, serializer), + Argument::BooleanLiteral(ref x) => Serialize::serialize(x, serializer), + Argument::NullLiteral(ref x) => Serialize::serialize(x, serializer), + Argument::NumericLiteral(ref x) => Serialize::serialize(x, serializer), + Argument::BigIntLiteral(ref x) => Serialize::serialize(x, serializer), + Argument::RegExpLiteral(ref x) => Serialize::serialize(x, serializer), + Argument::StringLiteral(ref x) => Serialize::serialize(x, serializer), + Argument::TemplateLiteral(ref x) => Serialize::serialize(x, serializer), + Argument::Identifier(ref x) => Serialize::serialize(x, serializer), + Argument::MetaProperty(ref x) => Serialize::serialize(x, serializer), + Argument::Super(ref x) => Serialize::serialize(x, serializer), + Argument::ArrayExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ArrowFunctionExpression(ref x) => Serialize::serialize(x, serializer), + Argument::AssignmentExpression(ref x) => Serialize::serialize(x, serializer), + Argument::AwaitExpression(ref x) => Serialize::serialize(x, serializer), + Argument::BinaryExpression(ref x) => Serialize::serialize(x, serializer), + Argument::CallExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ChainExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ClassExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ConditionalExpression(ref x) => Serialize::serialize(x, serializer), + Argument::FunctionExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ImportExpression(ref x) => Serialize::serialize(x, serializer), + Argument::LogicalExpression(ref x) => Serialize::serialize(x, serializer), + Argument::NewExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ObjectExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ParenthesizedExpression(ref x) => Serialize::serialize(x, serializer), + Argument::SequenceExpression(ref x) => Serialize::serialize(x, serializer), + Argument::TaggedTemplateExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ThisExpression(ref x) => Serialize::serialize(x, serializer), + Argument::UnaryExpression(ref x) => Serialize::serialize(x, serializer), + Argument::UpdateExpression(ref x) => Serialize::serialize(x, serializer), + Argument::YieldExpression(ref x) => Serialize::serialize(x, serializer), + Argument::PrivateInExpression(ref x) => Serialize::serialize(x, serializer), + Argument::JSXElement(ref x) => Serialize::serialize(x, serializer), + Argument::JSXFragment(ref x) => Serialize::serialize(x, serializer), + Argument::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + Argument::TSSatisfiesExpression(ref x) => Serialize::serialize(x, serializer), + Argument::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + Argument::TSNonNullExpression(ref x) => Serialize::serialize(x, serializer), + Argument::TSInstantiationExpression(ref x) => Serialize::serialize(x, serializer), + Argument::ComputedMemberExpression(ref x) => Serialize::serialize(x, serializer), + Argument::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + Argument::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for UpdateExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "UpdateExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("operator", &self.operator)?; + map.serialize_entry("prefix", &self.prefix)?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for UnaryExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "UnaryExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("operator", &self.operator)?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for BinaryExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "BinaryExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("left", &self.left)?; + map.serialize_entry("operator", &self.operator)?; + map.serialize_entry("right", &self.right)?; + map.end() } } impl<'a> Serialize for PrivateInExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "PrivateInExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("left", &self.left)?; + map.serialize_entry("operator", &self.operator)?; + map.serialize_entry("right", &self.right)?; + map.end() } } impl<'a> Serialize for LogicalExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "LogicalExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("left", &self.left)?; + map.serialize_entry("operator", &self.operator)?; + map.serialize_entry("right", &self.right)?; + map.end() } } impl<'a> Serialize for ConditionalExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ConditionalExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("test", &self.test)?; + map.serialize_entry("consequent", &self.consequent)?; + map.serialize_entry("alternate", &self.alternate)?; + map.end() } } impl<'a> Serialize for AssignmentExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "AssignmentExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("operator", &self.operator)?; + map.serialize_entry("left", &self.left)?; + map.serialize_entry("right", &self.right)?; + map.end() } } impl<'a> Serialize for AssignmentTarget<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + AssignmentTarget::AssignmentTargetIdentifier(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTarget::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + AssignmentTarget::TSSatisfiesExpression(ref x) => Serialize::serialize(x, serializer), + AssignmentTarget::TSNonNullExpression(ref x) => Serialize::serialize(x, serializer), + AssignmentTarget::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + AssignmentTarget::TSInstantiationExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTarget::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTarget::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + AssignmentTarget::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + AssignmentTarget::ArrayAssignmentTarget(ref x) => Serialize::serialize(x, serializer), + AssignmentTarget::ObjectAssignmentTarget(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for SimpleAssignmentTarget<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + SimpleAssignmentTarget::AssignmentTargetIdentifier(ref x) => { + Serialize::serialize(x, serializer) + } + SimpleAssignmentTarget::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + SimpleAssignmentTarget::TSSatisfiesExpression(ref x) => { + Serialize::serialize(x, serializer) + } + SimpleAssignmentTarget::TSNonNullExpression(ref x) => { + Serialize::serialize(x, serializer) + } + SimpleAssignmentTarget::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + SimpleAssignmentTarget::TSInstantiationExpression(ref x) => { + Serialize::serialize(x, serializer) + } + SimpleAssignmentTarget::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + SimpleAssignmentTarget::StaticMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + SimpleAssignmentTarget::PrivateFieldExpression(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl<'a> Serialize for AssignmentTargetPattern<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + AssignmentTargetPattern::ArrayAssignmentTarget(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetPattern::ObjectAssignmentTarget(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl<'a> Serialize for AssignmentTargetRest<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "RestElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.target)?; + map.end() } } impl<'a> Serialize for AssignmentTargetMaybeDefault<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + AssignmentTargetMaybeDefault::AssignmentTargetWithDefault(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::AssignmentTargetIdentifier(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::TSAsExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::TSSatisfiesExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::TSNonNullExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::TSTypeAssertion(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::TSInstantiationExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::StaticMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::PrivateFieldExpression(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::ArrayAssignmentTarget(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetMaybeDefault::ObjectAssignmentTarget(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl<'a> Serialize for AssignmentTargetWithDefault<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "AssignmentTargetWithDefault")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("binding", &self.binding)?; + map.serialize_entry("init", &self.init)?; + map.end() } } impl<'a> Serialize for AssignmentTargetProperty<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + AssignmentTargetProperty::AssignmentTargetPropertyIdentifier(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetProperty::AssignmentTargetPropertyProperty(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl<'a> Serialize for AssignmentTargetPropertyIdentifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "AssignmentTargetPropertyIdentifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("binding", &self.binding)?; + map.serialize_entry("init", &self.init)?; + map.end() } } impl<'a> Serialize for AssignmentTargetPropertyProperty<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "AssignmentTargetPropertyProperty")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("binding", &self.binding)?; + map.end() } } impl<'a> Serialize for SequenceExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "SequenceExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expressions", &self.expressions)?; + map.end() } } impl Serialize for Super { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Super")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for AwaitExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "AwaitExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for ChainExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ChainExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for ChainElement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ChainElement::CallExpression(ref x) => Serialize::serialize(x, serializer), + ChainElement::ComputedMemberExpression(ref x) => Serialize::serialize(x, serializer), + ChainElement::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + ChainElement::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for ParenthesizedExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ParenthesizedExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for Statement<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + Statement::BlockStatement(ref x) => Serialize::serialize(x, serializer), + Statement::BreakStatement(ref x) => Serialize::serialize(x, serializer), + Statement::ContinueStatement(ref x) => Serialize::serialize(x, serializer), + Statement::DebuggerStatement(ref x) => Serialize::serialize(x, serializer), + Statement::DoWhileStatement(ref x) => Serialize::serialize(x, serializer), + Statement::EmptyStatement(ref x) => Serialize::serialize(x, serializer), + Statement::ExpressionStatement(ref x) => Serialize::serialize(x, serializer), + Statement::ForInStatement(ref x) => Serialize::serialize(x, serializer), + Statement::ForOfStatement(ref x) => Serialize::serialize(x, serializer), + Statement::ForStatement(ref x) => Serialize::serialize(x, serializer), + Statement::IfStatement(ref x) => Serialize::serialize(x, serializer), + Statement::LabeledStatement(ref x) => Serialize::serialize(x, serializer), + Statement::ReturnStatement(ref x) => Serialize::serialize(x, serializer), + Statement::SwitchStatement(ref x) => Serialize::serialize(x, serializer), + Statement::ThrowStatement(ref x) => Serialize::serialize(x, serializer), + Statement::TryStatement(ref x) => Serialize::serialize(x, serializer), + Statement::WhileStatement(ref x) => Serialize::serialize(x, serializer), + Statement::WithStatement(ref x) => Serialize::serialize(x, serializer), + Statement::VariableDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::FunctionDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::ClassDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::TSTypeAliasDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::TSInterfaceDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::TSEnumDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::TSModuleDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::TSImportEqualsDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::ImportDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::ExportAllDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::ExportDefaultDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::ExportNamedDeclaration(ref x) => Serialize::serialize(x, serializer), + Statement::TSExportAssignment(ref x) => Serialize::serialize(x, serializer), + Statement::TSNamespaceExportDeclaration(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for Directive<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Directive")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("directive", &self.directive)?; + map.end() } } impl<'a> Serialize for Hashbang<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Hashbang")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl<'a> Serialize for BlockStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "BlockStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for Declaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + Declaration::VariableDeclaration(ref x) => Serialize::serialize(x, serializer), + Declaration::FunctionDeclaration(ref x) => Serialize::serialize(x, serializer), + Declaration::ClassDeclaration(ref x) => Serialize::serialize(x, serializer), + Declaration::TSTypeAliasDeclaration(ref x) => Serialize::serialize(x, serializer), + Declaration::TSInterfaceDeclaration(ref x) => Serialize::serialize(x, serializer), + Declaration::TSEnumDeclaration(ref x) => Serialize::serialize(x, serializer), + Declaration::TSModuleDeclaration(ref x) => Serialize::serialize(x, serializer), + Declaration::TSImportEqualsDeclaration(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for VariableDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "VariableDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("kind", &self.kind)?; + map.serialize_entry("declarations", &self.declarations)?; + map.serialize_entry("declare", &self.declare)?; + map.end() } } impl Serialize for VariableDeclarationKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + VariableDeclarationKind::Var => { + serializer.serialize_unit_variant("VariableDeclarationKind", 0u32, "var") + } + VariableDeclarationKind::Const => { + serializer.serialize_unit_variant("VariableDeclarationKind", 1u32, "const") + } + VariableDeclarationKind::Let => { + serializer.serialize_unit_variant("VariableDeclarationKind", 2u32, "let") + } + VariableDeclarationKind::Using => { + serializer.serialize_unit_variant("VariableDeclarationKind", 3u32, "using") + } + VariableDeclarationKind::AwaitUsing => { + serializer.serialize_unit_variant("VariableDeclarationKind", 4u32, "await using") + } + } } } impl<'a> Serialize for VariableDeclarator<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "VariableDeclarator")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("init", &self.init)?; + map.serialize_entry("definite", &self.definite)?; + map.end() } } impl Serialize for EmptyStatement { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "EmptyStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for ExpressionStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ExpressionStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for IfStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "IfStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("test", &self.test)?; + map.serialize_entry("consequent", &self.consequent)?; + map.serialize_entry("alternate", &self.alternate)?; + map.end() } } impl<'a> Serialize for DoWhileStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "DoWhileStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("body", &self.body)?; + map.serialize_entry("test", &self.test)?; + map.end() } } impl<'a> Serialize for WhileStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "WhileStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("test", &self.test)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for ForStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ForStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("init", &self.init)?; + map.serialize_entry("test", &self.test)?; + map.serialize_entry("update", &self.update)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for ForStatementInit<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + ForStatementInit::VariableDeclaration(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::BooleanLiteral(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::NullLiteral(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::NumericLiteral(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::BigIntLiteral(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::RegExpLiteral(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::StringLiteral(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::TemplateLiteral(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::Identifier(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::MetaProperty(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::Super(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::ArrayExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::ArrowFunctionExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::AssignmentExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::AwaitExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::BinaryExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::CallExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::ChainExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::ClassExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::ConditionalExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::FunctionExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::ImportExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::LogicalExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::NewExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::ObjectExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::ParenthesizedExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::SequenceExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::TaggedTemplateExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ForStatementInit::ThisExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::UnaryExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::UpdateExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::YieldExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::PrivateInExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::JSXElement(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::JSXFragment(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::TSSatisfiesExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::TSNonNullExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::TSInstantiationExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ForStatementInit::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ForStatementInit::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementInit::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for ForInStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ForInStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("left", &self.left)?; + map.serialize_entry("right", &self.right)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for ForStatementLeft<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ForStatementLeft::VariableDeclaration(ref x) => Serialize::serialize(x, serializer), + ForStatementLeft::AssignmentTargetIdentifier(ref x) => { + Serialize::serialize(x, serializer) + } + ForStatementLeft::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementLeft::TSSatisfiesExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementLeft::TSNonNullExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementLeft::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + ForStatementLeft::TSInstantiationExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ForStatementLeft::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ForStatementLeft::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementLeft::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + ForStatementLeft::ArrayAssignmentTarget(ref x) => Serialize::serialize(x, serializer), + ForStatementLeft::ObjectAssignmentTarget(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for ForOfStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ForOfStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("await", &self.r#await)?; + map.serialize_entry("left", &self.left)?; + map.serialize_entry("right", &self.right)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for ContinueStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ContinueStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("label", &self.label)?; + map.end() } } impl<'a> Serialize for BreakStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "BreakStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("label", &self.label)?; + map.end() } } impl<'a> Serialize for ReturnStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ReturnStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for WithStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "WithStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("object", &self.object)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for SwitchStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "SwitchStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("discriminant", &self.discriminant)?; + map.serialize_entry("cases", &self.cases)?; + map.end() } } impl<'a> Serialize for SwitchCase<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "SwitchCase")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("test", &self.test)?; + map.serialize_entry("consequent", &self.consequent)?; + map.end() } } impl<'a> Serialize for LabeledStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "LabeledStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("label", &self.label)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for ThrowStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ThrowStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for TryStatement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TryStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("block", &self.block)?; + map.serialize_entry("handler", &self.handler)?; + map.serialize_entry("finalizer", &self.finalizer)?; + map.end() } } impl<'a> Serialize for CatchClause<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "CatchClause")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("param", &self.param)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for CatchParameter<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "CatchParameter")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("pattern", &self.pattern)?; + map.end() } } impl Serialize for DebuggerStatement { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "DebuggerStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for BindingPattern<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + self.kind.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("optional", &self.optional)?; + map.end() } } impl<'a> Serialize for BindingPatternKind<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + BindingPatternKind::BindingIdentifier(ref x) => Serialize::serialize(x, serializer), + BindingPatternKind::ObjectPattern(ref x) => Serialize::serialize(x, serializer), + BindingPatternKind::ArrayPattern(ref x) => Serialize::serialize(x, serializer), + BindingPatternKind::AssignmentPattern(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for AssignmentPattern<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "AssignmentPattern")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("left", &self.left)?; + map.serialize_entry("right", &self.right)?; + map.end() } } impl<'a> Serialize for BindingProperty<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "BindingProperty")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("value", &self.value)?; + map.serialize_entry("shorthand", &self.shorthand)?; + map.serialize_entry("computed", &self.computed)?; + map.end() } } impl<'a> Serialize for BindingRestElement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "RestElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for Function<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", &self.r#type)?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("generator", &self.generator)?; + map.serialize_entry("async", &self.r#async)?; + map.serialize_entry("declare", &self.declare)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("this_param", &self.this_param)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl Serialize for FunctionType { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + FunctionType::FunctionDeclaration => { + serializer.serialize_unit_variant("FunctionType", 0u32, "FunctionDeclaration") + } + FunctionType::FunctionExpression => { + serializer.serialize_unit_variant("FunctionType", 1u32, "FunctionExpression") + } + FunctionType::TSDeclareFunction => { + serializer.serialize_unit_variant("FunctionType", 2u32, "TSDeclareFunction") + } + FunctionType::TSEmptyBodyFunctionExpression => serializer.serialize_unit_variant( + "FunctionType", + 3u32, + "TSEmptyBodyFunctionExpression", + ), + } } } impl<'a> Serialize for FormalParameter<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "FormalParameter")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("decorators", &self.decorators)?; + map.serialize_entry("pattern", &self.pattern)?; + map.serialize_entry("accessibility", &self.accessibility)?; + map.serialize_entry("readonly", &self.readonly)?; + map.serialize_entry("override", &self.r#override)?; + map.end() } } impl Serialize for FormalParameterKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + FormalParameterKind::FormalParameter => { + serializer.serialize_unit_variant("FormalParameterKind", 0u32, "formalParameter") + } + FormalParameterKind::UniqueFormalParameters => serializer.serialize_unit_variant( + "FormalParameterKind", + 1u32, + "uniqueFormalParameters", + ), + FormalParameterKind::ArrowFormalParameters => serializer.serialize_unit_variant( + "FormalParameterKind", + 2u32, + "arrowFormalParameters", + ), + FormalParameterKind::Signature => { + serializer.serialize_unit_variant("FormalParameterKind", 3u32, "signature") + } + } } } impl<'a> Serialize for FunctionBody<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "FunctionBody")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("directives", &self.directives)?; + map.serialize_entry("statements", &self.statements)?; + map.end() } } impl<'a> Serialize for ArrowFunctionExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ArrowFunctionExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("async", &self.r#async)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for YieldExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "YieldExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("delegate", &self.delegate)?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for Class<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", &self.r#type)?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("decorators", &self.decorators)?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("super_class", &self.super_class)?; + map.serialize_entry("super_type_parameters", &self.super_type_parameters)?; + map.serialize_entry("implements", &self.implements)?; + map.serialize_entry("body", &self.body)?; + map.serialize_entry("abstract", &self.r#abstract)?; + map.serialize_entry("declare", &self.declare)?; + map.end() } } impl Serialize for ClassType { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ClassType::ClassDeclaration => { + serializer.serialize_unit_variant("ClassType", 0u32, "ClassDeclaration") + } + ClassType::ClassExpression => { + serializer.serialize_unit_variant("ClassType", 1u32, "ClassExpression") + } + } } } impl<'a> Serialize for ClassBody<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ClassBody")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for ClassElement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ClassElement::StaticBlock(ref x) => Serialize::serialize(x, serializer), + ClassElement::MethodDefinition(ref x) => Serialize::serialize(x, serializer), + ClassElement::PropertyDefinition(ref x) => Serialize::serialize(x, serializer), + ClassElement::AccessorProperty(ref x) => Serialize::serialize(x, serializer), + ClassElement::TSIndexSignature(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for MethodDefinition<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", &self.r#type)?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("decorators", &self.decorators)?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("value", &self.value)?; + map.serialize_entry("kind", &self.kind)?; + map.serialize_entry("computed", &self.computed)?; + map.serialize_entry("static", &self.r#static)?; + map.serialize_entry("override", &self.r#override)?; + map.serialize_entry("optional", &self.optional)?; + map.serialize_entry("accessibility", &self.accessibility)?; + map.end() } } impl Serialize for MethodDefinitionType { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + MethodDefinitionType::MethodDefinition => { + serializer.serialize_unit_variant("MethodDefinitionType", 0u32, "MethodDefinition") + } + MethodDefinitionType::TSAbstractMethodDefinition => serializer.serialize_unit_variant( + "MethodDefinitionType", + 1u32, + "TSAbstractMethodDefinition", + ), + } } } impl<'a> Serialize for PropertyDefinition<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", &self.r#type)?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("decorators", &self.decorators)?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("value", &self.value)?; + map.serialize_entry("computed", &self.computed)?; + map.serialize_entry("static", &self.r#static)?; + map.serialize_entry("declare", &self.declare)?; + map.serialize_entry("override", &self.r#override)?; + map.serialize_entry("optional", &self.optional)?; + map.serialize_entry("definite", &self.definite)?; + map.serialize_entry("readonly", &self.readonly)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("accessibility", &self.accessibility)?; + map.end() } } impl Serialize for PropertyDefinitionType { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + PropertyDefinitionType::PropertyDefinition => serializer.serialize_unit_variant( + "PropertyDefinitionType", + 0u32, + "PropertyDefinition", + ), + PropertyDefinitionType::TSAbstractPropertyDefinition => serializer + .serialize_unit_variant( + "PropertyDefinitionType", + 1u32, + "TSAbstractPropertyDefinition", + ), + } } } impl Serialize for MethodDefinitionKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + MethodDefinitionKind::Constructor => { + serializer.serialize_unit_variant("MethodDefinitionKind", 0u32, "constructor") + } + MethodDefinitionKind::Method => { + serializer.serialize_unit_variant("MethodDefinitionKind", 1u32, "method") + } + MethodDefinitionKind::Get => { + serializer.serialize_unit_variant("MethodDefinitionKind", 2u32, "get") + } + MethodDefinitionKind::Set => { + serializer.serialize_unit_variant("MethodDefinitionKind", 3u32, "set") + } + } } } impl<'a> Serialize for PrivateIdentifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "PrivateIdentifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() } } impl<'a> Serialize for StaticBlock<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "StaticBlock")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for ModuleDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ModuleDeclaration::ImportDeclaration(ref x) => Serialize::serialize(x, serializer), + ModuleDeclaration::ExportAllDeclaration(ref x) => Serialize::serialize(x, serializer), + ModuleDeclaration::ExportDefaultDeclaration(ref x) => { + Serialize::serialize(x, serializer) + } + ModuleDeclaration::ExportNamedDeclaration(ref x) => Serialize::serialize(x, serializer), + ModuleDeclaration::TSExportAssignment(ref x) => Serialize::serialize(x, serializer), + ModuleDeclaration::TSNamespaceExportDeclaration(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl Serialize for AccessorPropertyType { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + AccessorPropertyType::AccessorProperty => { + serializer.serialize_unit_variant("AccessorPropertyType", 0u32, "AccessorProperty") + } + AccessorPropertyType::TSAbstractAccessorProperty => serializer.serialize_unit_variant( + "AccessorPropertyType", + 1u32, + "TSAbstractAccessorProperty", + ), + } } } impl<'a> Serialize for AccessorProperty<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", &self.r#type)?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("decorators", &self.decorators)?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("value", &self.value)?; + map.serialize_entry("computed", &self.computed)?; + map.serialize_entry("static", &self.r#static)?; + map.serialize_entry("definite", &self.definite)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("accessibility", &self.accessibility)?; + map.end() } } impl<'a> Serialize for ImportExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ImportExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("source", &self.source)?; + map.serialize_entry("arguments", &self.arguments)?; + map.end() } } impl<'a> Serialize for ImportDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ImportDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("specifiers", &self.specifiers)?; + map.serialize_entry("source", &self.source)?; + map.serialize_entry("with_clause", &self.with_clause)?; + map.serialize_entry("import_kind", &self.import_kind)?; + map.end() } } impl<'a> Serialize for ImportDeclarationSpecifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ImportDeclarationSpecifier::ImportSpecifier(ref x) => { + Serialize::serialize(x, serializer) + } + ImportDeclarationSpecifier::ImportDefaultSpecifier(ref x) => { + Serialize::serialize(x, serializer) + } + ImportDeclarationSpecifier::ImportNamespaceSpecifier(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl<'a> Serialize for ImportSpecifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ImportSpecifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("imported", &self.imported)?; + map.serialize_entry("local", &self.local)?; + map.serialize_entry("import_kind", &self.import_kind)?; + map.end() } } impl<'a> Serialize for ImportDefaultSpecifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ImportDefaultSpecifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("local", &self.local)?; + map.end() } } impl<'a> Serialize for ImportNamespaceSpecifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ImportNamespaceSpecifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("local", &self.local)?; + map.end() } } impl<'a> Serialize for WithClause<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "WithClause")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("attributes_keyword", &self.attributes_keyword)?; + map.serialize_entry("with_entries", &self.with_entries)?; + map.end() } } impl<'a> Serialize for ImportAttribute<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ImportAttribute")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl<'a> Serialize for ImportAttributeKey<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ImportAttributeKey::Identifier(ref x) => Serialize::serialize(x, serializer), + ImportAttributeKey::StringLiteral(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for ExportNamedDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ExportNamedDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("declaration", &self.declaration)?; + map.serialize_entry("specifiers", &self.specifiers)?; + map.serialize_entry("source", &self.source)?; + map.serialize_entry("export_kind", &self.export_kind)?; + map.serialize_entry("with_clause", &self.with_clause)?; + map.end() } } impl<'a> Serialize for ExportDefaultDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ExportDefaultDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("declaration", &self.declaration)?; + map.serialize_entry("exported", &self.exported)?; + map.end() } } impl<'a> Serialize for ExportAllDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ExportAllDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("exported", &self.exported)?; + map.serialize_entry("source", &self.source)?; + map.serialize_entry("with_clause", &self.with_clause)?; + map.serialize_entry("export_kind", &self.export_kind)?; + map.end() } } impl<'a> Serialize for ExportSpecifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ExportSpecifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("local", &self.local)?; + map.serialize_entry("exported", &self.exported)?; + map.serialize_entry("export_kind", &self.export_kind)?; + map.end() } } impl<'a> Serialize for ExportDefaultDeclarationKind<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + ExportDefaultDeclarationKind::FunctionDeclaration(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ClassDeclaration(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::TSInterfaceDeclaration(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::BooleanLiteral(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::NullLiteral(ref x) => Serialize::serialize(x, serializer), + ExportDefaultDeclarationKind::NumericLiteral(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::BigIntLiteral(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::RegExpLiteral(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::StringLiteral(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::TemplateLiteral(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::Identifier(ref x) => Serialize::serialize(x, serializer), + ExportDefaultDeclarationKind::MetaProperty(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::Super(ref x) => Serialize::serialize(x, serializer), + ExportDefaultDeclarationKind::ArrayExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ArrowFunctionExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::AssignmentExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::AwaitExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::BinaryExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::CallExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ChainExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ClassExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ConditionalExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::FunctionExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ImportExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::LogicalExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::NewExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ObjectExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ParenthesizedExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::SequenceExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::TaggedTemplateExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ThisExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::UnaryExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::UpdateExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::YieldExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::PrivateInExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::JSXElement(ref x) => Serialize::serialize(x, serializer), + ExportDefaultDeclarationKind::JSXFragment(ref x) => Serialize::serialize(x, serializer), + ExportDefaultDeclarationKind::TSAsExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::TSSatisfiesExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::TSTypeAssertion(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::TSNonNullExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::TSInstantiationExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::StaticMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + ExportDefaultDeclarationKind::PrivateFieldExpression(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl<'a> Serialize for ModuleExportName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ModuleExportName::IdentifierName(ref x) => Serialize::serialize(x, serializer), + ModuleExportName::IdentifierReference(ref x) => Serialize::serialize(x, serializer), + ModuleExportName::StringLiteral(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSThisParameter<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSThisParameter")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("this_span", &self.this_span)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSEnumDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSEnumDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("members", &self.members)?; + map.serialize_entry("const", &self.r#const)?; + map.serialize_entry("declare", &self.declare)?; + map.end() } } impl<'a> Serialize for TSEnumMember<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSEnumMember")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("initializer", &self.initializer)?; + map.end() } } impl<'a> Serialize for TSEnumMemberName<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + TSEnumMemberName::StaticIdentifier(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::StaticStringLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::StaticTemplateLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::StaticNumericLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::BooleanLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::NullLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::NumericLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::BigIntLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::RegExpLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::StringLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::TemplateLiteral(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::Identifier(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::MetaProperty(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::Super(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::ArrayExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::ArrowFunctionExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::AssignmentExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::AwaitExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::BinaryExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::CallExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::ChainExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::ClassExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::ConditionalExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::FunctionExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::ImportExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::LogicalExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::NewExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::ObjectExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::ParenthesizedExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::SequenceExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::TaggedTemplateExpression(ref x) => { + Serialize::serialize(x, serializer) + } + TSEnumMemberName::ThisExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::UnaryExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::UpdateExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::YieldExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::PrivateInExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::JSXElement(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::JSXFragment(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::TSSatisfiesExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::TSNonNullExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::TSInstantiationExpression(ref x) => { + Serialize::serialize(x, serializer) + } + TSEnumMemberName::ComputedMemberExpression(ref x) => { + Serialize::serialize(x, serializer) + } + TSEnumMemberName::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + TSEnumMemberName::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSTypeAnnotation<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeAnnotation")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSLiteralType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSLiteralType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("literal", &self.literal)?; + map.end() } } impl<'a> Serialize for TSLiteral<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSLiteral::BooleanLiteral(ref x) => Serialize::serialize(x, serializer), + TSLiteral::NullLiteral(ref x) => Serialize::serialize(x, serializer), + TSLiteral::NumericLiteral(ref x) => Serialize::serialize(x, serializer), + TSLiteral::BigIntLiteral(ref x) => Serialize::serialize(x, serializer), + TSLiteral::RegExpLiteral(ref x) => Serialize::serialize(x, serializer), + TSLiteral::StringLiteral(ref x) => Serialize::serialize(x, serializer), + TSLiteral::TemplateLiteral(ref x) => Serialize::serialize(x, serializer), + TSLiteral::UnaryExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSType<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + TSType::TSAnyKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSBigIntKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSBooleanKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSIntrinsicKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSNeverKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSNullKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSNumberKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSObjectKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSStringKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSSymbolKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSUndefinedKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSUnknownKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSVoidKeyword(ref x) => Serialize::serialize(x, serializer), + TSType::TSArrayType(ref x) => Serialize::serialize(x, serializer), + TSType::TSConditionalType(ref x) => Serialize::serialize(x, serializer), + TSType::TSConstructorType(ref x) => Serialize::serialize(x, serializer), + TSType::TSFunctionType(ref x) => Serialize::serialize(x, serializer), + TSType::TSImportType(ref x) => Serialize::serialize(x, serializer), + TSType::TSIndexedAccessType(ref x) => Serialize::serialize(x, serializer), + TSType::TSInferType(ref x) => Serialize::serialize(x, serializer), + TSType::TSIntersectionType(ref x) => Serialize::serialize(x, serializer), + TSType::TSLiteralType(ref x) => Serialize::serialize(x, serializer), + TSType::TSMappedType(ref x) => Serialize::serialize(x, serializer), + TSType::TSNamedTupleMember(ref x) => Serialize::serialize(x, serializer), + TSType::TSQualifiedName(ref x) => Serialize::serialize(x, serializer), + TSType::TSTemplateLiteralType(ref x) => Serialize::serialize(x, serializer), + TSType::TSThisType(ref x) => Serialize::serialize(x, serializer), + TSType::TSTupleType(ref x) => Serialize::serialize(x, serializer), + TSType::TSTypeLiteral(ref x) => Serialize::serialize(x, serializer), + TSType::TSTypeOperatorType(ref x) => Serialize::serialize(x, serializer), + TSType::TSTypePredicate(ref x) => Serialize::serialize(x, serializer), + TSType::TSTypeQuery(ref x) => Serialize::serialize(x, serializer), + TSType::TSTypeReference(ref x) => Serialize::serialize(x, serializer), + TSType::TSUnionType(ref x) => Serialize::serialize(x, serializer), + TSType::TSParenthesizedType(ref x) => Serialize::serialize(x, serializer), + TSType::JSDocNullableType(ref x) => Serialize::serialize(x, serializer), + TSType::JSDocNonNullableType(ref x) => Serialize::serialize(x, serializer), + TSType::JSDocUnknownType(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSConditionalType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSConditionalType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("check_type", &self.check_type)?; + map.serialize_entry("extends_type", &self.extends_type)?; + map.serialize_entry("true_type", &self.true_type)?; + map.serialize_entry("false_type", &self.false_type)?; + map.end() } } impl<'a> Serialize for TSUnionType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSUnionType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("types", &self.types)?; + map.end() } } impl<'a> Serialize for TSIntersectionType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSIntersectionType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("types", &self.types)?; + map.end() } } impl<'a> Serialize for TSParenthesizedType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSParenthesizedType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSTypeOperator<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeOperator")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("operator", &self.operator)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl Serialize for TSTypeOperatorOperator { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSTypeOperatorOperator::Keyof => { + serializer.serialize_unit_variant("TSTypeOperatorOperator", 0u32, "keyof") + } + TSTypeOperatorOperator::Unique => { + serializer.serialize_unit_variant("TSTypeOperatorOperator", 1u32, "unique") + } + TSTypeOperatorOperator::Readonly => { + serializer.serialize_unit_variant("TSTypeOperatorOperator", 2u32, "readonly") + } + } } } impl<'a> Serialize for TSArrayType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSArrayType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("element_type", &self.element_type)?; + map.end() } } impl<'a> Serialize for TSIndexedAccessType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSIndexedAccessType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("object_type", &self.object_type)?; + map.serialize_entry("index_type", &self.index_type)?; + map.end() } } impl<'a> Serialize for TSTupleType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTupleType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("element_types", &self.element_types)?; + map.end() } } impl<'a> Serialize for TSNamedTupleMember<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNamedTupleMember")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("element_type", &self.element_type)?; + map.serialize_entry("label", &self.label)?; + map.serialize_entry("optional", &self.optional)?; + map.end() } } impl<'a> Serialize for TSOptionalType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSOptionalType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSRestType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSRestType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSTupleElement<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + TSTupleElement::TSOptionalType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSRestType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSAnyKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSBigIntKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSBooleanKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSIntrinsicKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSNeverKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSNullKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSNumberKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSObjectKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSStringKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSSymbolKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSUndefinedKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSUnknownKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSVoidKeyword(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSArrayType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSConditionalType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSConstructorType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSFunctionType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSImportType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSIndexedAccessType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSInferType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSIntersectionType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSLiteralType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSMappedType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSNamedTupleMember(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSQualifiedName(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSTemplateLiteralType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSThisType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSTupleType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSTypeLiteral(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSTypeOperatorType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSTypePredicate(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSTypeQuery(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSTypeReference(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSUnionType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::TSParenthesizedType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::JSDocNullableType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::JSDocNonNullableType(ref x) => Serialize::serialize(x, serializer), + TSTupleElement::JSDocUnknownType(ref x) => Serialize::serialize(x, serializer), + } } } impl Serialize for TSAnyKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSAnyKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSStringKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSStringKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSBooleanKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSBooleanKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSNumberKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNumberKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSNeverKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNeverKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSIntrinsicKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSIntrinsicKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSUnknownKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSUnknownKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSNullKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNullKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSUndefinedKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSUndefinedKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSVoidKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSVoidKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSSymbolKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSSymbolKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSThisType { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSThisType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSObjectKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSObjectKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for TSBigIntKeyword { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSBigIntKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for TSTypeReference<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeReference")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_name", &self.type_name)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSTypeName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSTypeName::IdentifierReference(ref x) => Serialize::serialize(x, serializer), + TSTypeName::QualifiedName(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSQualifiedName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSQualifiedName")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("left", &self.left)?; + map.serialize_entry("right", &self.right)?; + map.end() } } impl<'a> Serialize for TSTypeParameterInstantiation<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeParameterInstantiation")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("params", &self.params)?; + map.end() } } impl<'a> Serialize for TSTypeParameter<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeParameter")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("constraint", &self.constraint)?; + map.serialize_entry("default", &self.default)?; + map.serialize_entry("in", &self.r#in)?; + map.serialize_entry("out", &self.out)?; + map.serialize_entry("const", &self.r#const)?; + map.end() } } impl<'a> Serialize for TSTypeParameterDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeParameterDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("params", &self.params)?; + map.end() } } impl<'a> Serialize for TSTypeAliasDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeAliasDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("declare", &self.declare)?; + map.end() } } impl Serialize for TSAccessibility { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSAccessibility::Private => { + serializer.serialize_unit_variant("TSAccessibility", 0u32, "private") + } + TSAccessibility::Protected => { + serializer.serialize_unit_variant("TSAccessibility", 1u32, "protected") + } + TSAccessibility::Public => { + serializer.serialize_unit_variant("TSAccessibility", 2u32, "public") + } + } } } impl<'a> Serialize for TSClassImplements<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSClassImplements")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSInterfaceDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSInterfaceDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("extends", &self.extends)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("body", &self.body)?; + map.serialize_entry("declare", &self.declare)?; + map.end() } } impl<'a> Serialize for TSInterfaceBody<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSInterfaceBody")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for TSPropertySignature<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSPropertySignature")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("computed", &self.computed)?; + map.serialize_entry("optional", &self.optional)?; + map.serialize_entry("readonly", &self.readonly)?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSSignature<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSSignature::TSIndexSignature(ref x) => Serialize::serialize(x, serializer), + TSSignature::TSPropertySignature(ref x) => Serialize::serialize(x, serializer), + TSSignature::TSCallSignatureDeclaration(ref x) => Serialize::serialize(x, serializer), + TSSignature::TSConstructSignatureDeclaration(ref x) => { + Serialize::serialize(x, serializer) + } + TSSignature::TSMethodSignature(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSIndexSignature<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSIndexSignature")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("parameters", &self.parameters)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("readonly", &self.readonly)?; + map.end() } } impl<'a> Serialize for TSCallSignatureDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSCallSignatureDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("this_param", &self.this_param)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl Serialize for TSMethodSignatureKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSMethodSignatureKind::Method => { + serializer.serialize_unit_variant("TSMethodSignatureKind", 0u32, "method") + } + TSMethodSignatureKind::Get => { + serializer.serialize_unit_variant("TSMethodSignatureKind", 1u32, "get") + } + TSMethodSignatureKind::Set => { + serializer.serialize_unit_variant("TSMethodSignatureKind", 2u32, "set") + } + } } } impl<'a> Serialize for TSMethodSignature<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSMethodSignature")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("key", &self.key)?; + map.serialize_entry("computed", &self.computed)?; + map.serialize_entry("optional", &self.optional)?; + map.serialize_entry("kind", &self.kind)?; + map.serialize_entry("this_param", &self.this_param)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSConstructSignatureDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSConstructSignatureDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSIndexSignatureName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Identifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSInterfaceHeritage<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSInterfaceHeritage")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSTypePredicate<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypePredicate")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("parameter_name", &self.parameter_name)?; + map.serialize_entry("asserts", &self.asserts)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSTypePredicateName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSTypePredicateName::Identifier(ref x) => Serialize::serialize(x, serializer), + TSTypePredicateName::This(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSModuleDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSModuleDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("body", &self.body)?; + map.serialize_entry("kind", &self.kind)?; + map.serialize_entry("declare", &self.declare)?; + map.end() } } impl Serialize for TSModuleDeclarationKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSModuleDeclarationKind::Global => { + serializer.serialize_unit_variant("TSModuleDeclarationKind", 0u32, "global") + } + TSModuleDeclarationKind::Module => { + serializer.serialize_unit_variant("TSModuleDeclarationKind", 1u32, "module") + } + TSModuleDeclarationKind::Namespace => { + serializer.serialize_unit_variant("TSModuleDeclarationKind", 2u32, "namespace") + } + } } } impl<'a> Serialize for TSModuleDeclarationName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSModuleDeclarationName::Identifier(ref x) => Serialize::serialize(x, serializer), + TSModuleDeclarationName::StringLiteral(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSModuleDeclarationBody<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSModuleDeclarationBody::TSModuleDeclaration(ref x) => { + Serialize::serialize(x, serializer) + } + TSModuleDeclarationBody::TSModuleBlock(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSTypeLiteral<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("members", &self.members)?; + map.end() } } impl<'a> Serialize for TSInferType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSInferType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_parameter", &self.type_parameter)?; + map.end() } } impl<'a> Serialize for TSTypeQuery<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeQuery")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expr_name", &self.expr_name)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSTypeQueryExprName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSTypeQueryExprName::TSImportType(ref x) => Serialize::serialize(x, serializer), + TSTypeQueryExprName::IdentifierReference(ref x) => Serialize::serialize(x, serializer), + TSTypeQueryExprName::QualifiedName(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSImportType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSImportType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("is_type_of", &self.is_type_of)?; + map.serialize_entry("parameter", &self.parameter)?; + map.serialize_entry("qualifier", &self.qualifier)?; + map.serialize_entry("attributes", &self.attributes)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSImportAttributes<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSImportAttributes")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("attributes_keyword", &self.attributes_keyword)?; + map.serialize_entry("elements", &self.elements)?; + map.end() } } impl<'a> Serialize for TSImportAttribute<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSImportAttribute")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl<'a> Serialize for TSImportAttributeName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSImportAttributeName::Identifier(ref x) => Serialize::serialize(x, serializer), + TSImportAttributeName::StringLiteral(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSFunctionType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSFunctionType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("this_param", &self.this_param)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSConstructorType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSConstructorType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("abstract", &self.r#abstract)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for TSMappedType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSMappedType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_parameter", &self.type_parameter)?; + map.serialize_entry("name_type", &self.name_type)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("optional", &self.optional)?; + map.serialize_entry("readonly", &self.readonly)?; + map.end() } } impl Serialize for TSMappedTypeModifierOperator { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSMappedTypeModifierOperator::True => { + serializer.serialize_unit_variant("TSMappedTypeModifierOperator", 0u32, "true") + } + TSMappedTypeModifierOperator::Plus => { + serializer.serialize_unit_variant("TSMappedTypeModifierOperator", 1u32, "+") + } + TSMappedTypeModifierOperator::Minus => { + serializer.serialize_unit_variant("TSMappedTypeModifierOperator", 2u32, "-") + } + TSMappedTypeModifierOperator::None => { + serializer.serialize_unit_variant("TSMappedTypeModifierOperator", 3u32, "none") + } + } } } impl<'a> Serialize for TSTemplateLiteralType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTemplateLiteralType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("quasis", &self.quasis)?; + map.serialize_entry("types", &self.types)?; + map.end() } } impl<'a> Serialize for TSAsExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSAsExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSSatisfiesExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSSatisfiesExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSTypeAssertion<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeAssertion")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.end() } } impl<'a> Serialize for TSImportEqualsDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSImportEqualsDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("module_reference", &self.module_reference)?; + map.serialize_entry("import_kind", &self.import_kind)?; + map.end() } } impl<'a> Serialize for TSModuleReference<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + TSModuleReference::ExternalModuleReference(ref x) => { + Serialize::serialize(x, serializer) + } + TSModuleReference::IdentifierReference(ref x) => Serialize::serialize(x, serializer), + TSModuleReference::QualifiedName(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for TSExternalModuleReference<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSExternalModuleReference")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for TSNonNullExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNonNullExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for Decorator<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Decorator")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for TSExportAssignment<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSExportAssignment")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for TSNamespaceExportDeclaration<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNamespaceExportDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.end() } } impl<'a> Serialize for TSInstantiationExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSInstantiationExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl Serialize for ImportOrExportKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ImportOrExportKind::Value => { + serializer.serialize_unit_variant("ImportOrExportKind", 0u32, "value") + } + ImportOrExportKind::Type => { + serializer.serialize_unit_variant("ImportOrExportKind", 1u32, "type") + } + } } } impl<'a> Serialize for JSDocNullableType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSDocNullableType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("postfix", &self.postfix)?; + map.end() } } impl<'a> Serialize for JSDocNonNullableType<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSDocNonNullableType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("postfix", &self.postfix)?; + map.end() } } impl Serialize for JSDocUnknownType { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSDocUnknownType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for JSXElement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("opening_element", &self.opening_element)?; + map.serialize_entry("closing_element", &self.closing_element)?; + map.serialize_entry("children", &self.children)?; + map.end() } } impl<'a> Serialize for JSXOpeningElement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXOpeningElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("self_closing", &self.self_closing)?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("attributes", &self.attributes)?; + map.serialize_entry("type_parameters", &self.type_parameters)?; + map.end() } } impl<'a> Serialize for JSXClosingElement<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXClosingElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() } } impl<'a> Serialize for JSXFragment<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXFragment")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("opening_fragment", &self.opening_fragment)?; + map.serialize_entry("closing_fragment", &self.closing_fragment)?; + map.serialize_entry("children", &self.children)?; + map.end() } } impl Serialize for JSXOpeningFragment { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXOpeningFragment")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl Serialize for JSXClosingFragment { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXClosingFragment")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for JSXNamespacedName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXNamespacedName")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("namespace", &self.namespace)?; + map.serialize_entry("property", &self.property)?; + map.end() } } impl<'a> Serialize for JSXMemberExpression<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXMemberExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("object", &self.object)?; + map.serialize_entry("property", &self.property)?; + map.end() } } impl<'a> Serialize for JSXExpressionContainer<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXExpressionContainer")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for JSXExpression<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_none() + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + JSXExpression::EmptyExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::BooleanLiteral(ref x) => Serialize::serialize(x, serializer), + JSXExpression::NullLiteral(ref x) => Serialize::serialize(x, serializer), + JSXExpression::NumericLiteral(ref x) => Serialize::serialize(x, serializer), + JSXExpression::BigIntLiteral(ref x) => Serialize::serialize(x, serializer), + JSXExpression::RegExpLiteral(ref x) => Serialize::serialize(x, serializer), + JSXExpression::StringLiteral(ref x) => Serialize::serialize(x, serializer), + JSXExpression::TemplateLiteral(ref x) => Serialize::serialize(x, serializer), + JSXExpression::Identifier(ref x) => Serialize::serialize(x, serializer), + JSXExpression::MetaProperty(ref x) => Serialize::serialize(x, serializer), + JSXExpression::Super(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ArrayExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ArrowFunctionExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::AssignmentExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::AwaitExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::BinaryExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::CallExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ChainExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ClassExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ConditionalExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::FunctionExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ImportExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::LogicalExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::NewExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ObjectExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ParenthesizedExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::SequenceExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::TaggedTemplateExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ThisExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::UnaryExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::UpdateExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::YieldExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::PrivateInExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::JSXElement(ref x) => Serialize::serialize(x, serializer), + JSXExpression::JSXFragment(ref x) => Serialize::serialize(x, serializer), + JSXExpression::TSAsExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::TSSatisfiesExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::TSTypeAssertion(ref x) => Serialize::serialize(x, serializer), + JSXExpression::TSNonNullExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::TSInstantiationExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::ComputedMemberExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::StaticMemberExpression(ref x) => Serialize::serialize(x, serializer), + JSXExpression::PrivateFieldExpression(ref x) => Serialize::serialize(x, serializer), + } } } impl Serialize for JSXEmptyExpression { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXEmptyExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for JSXAttributeItem<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + JSXAttributeItem::Attribute(ref x) => Serialize::serialize(x, serializer), + JSXAttributeItem::SpreadAttribute(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for JSXAttribute<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXAttribute")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl<'a> Serialize for JSXSpreadAttribute<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXSpreadAttribute")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.argument)?; + map.end() } } impl<'a> Serialize for JSXAttributeName<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + JSXAttributeName::Identifier(ref x) => Serialize::serialize(x, serializer), + JSXAttributeName::NamespacedName(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for JSXAttributeValue<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + JSXAttributeValue::StringLiteral(ref x) => Serialize::serialize(x, serializer), + JSXAttributeValue::ExpressionContainer(ref x) => Serialize::serialize(x, serializer), + JSXAttributeValue::Element(ref x) => Serialize::serialize(x, serializer), + JSXAttributeValue::Fragment(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for JSXIdentifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXIdentifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() } } impl<'a> Serialize for JSXChild<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + JSXChild::Text(ref x) => Serialize::serialize(x, serializer), + JSXChild::Element(ref x) => Serialize::serialize(x, serializer), + JSXChild::Fragment(ref x) => Serialize::serialize(x, serializer), + JSXChild::ExpressionContainer(ref x) => Serialize::serialize(x, serializer), + JSXChild::Spread(ref x) => Serialize::serialize(x, serializer), + } } } impl<'a> Serialize for JSXSpreadChild<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXSpreadChild")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() } } impl<'a> Serialize for JSXText<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXText")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("value", &self.value)?; + map.end() } } diff --git a/crates/oxc_regular_expression/src/ast.rs b/crates/oxc_regular_expression/src/ast.rs index 87092dd49e09b..38015127ed57d 100644 --- a/crates/oxc_regular_expression/src/ast.rs +++ b/crates/oxc_regular_expression/src/ast.rs @@ -6,8 +6,6 @@ use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, Span}; #[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] use tsify::Tsify; /// The root of the `PatternParser` result. @@ -15,7 +13,6 @@ use tsify::Tsify; #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Pattern<'a> { #[estree(flatten)] pub span: Span, @@ -27,7 +24,6 @@ pub struct Pattern<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Disjunction<'a> { #[estree(flatten)] pub span: Span, @@ -39,7 +35,6 @@ pub struct Disjunction<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Alternative<'a> { #[estree(flatten)] pub span: Span, @@ -96,7 +91,6 @@ impl<'a> GetSpan for Term<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct BoundaryAssertion { pub span: Span, pub kind: BoundaryAssertionKind, @@ -120,7 +114,6 @@ pub enum BoundaryAssertionKind { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct LookAroundAssertion<'a> { #[estree(flatten)] pub span: Span, @@ -146,7 +139,6 @@ pub enum LookAroundAssertionKind { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Quantifier<'a> { #[estree(flatten)] pub span: Span, @@ -162,7 +154,6 @@ pub struct Quantifier<'a> { #[derive(Debug, Clone, Copy)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Character { /// This will be invalid position when `UnicodeMode` is disabled and `value` is a surrogate pair. #[estree(flatten)] @@ -197,7 +188,6 @@ pub enum CharacterKind { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct CharacterClassEscape { #[estree(flatten)] pub span: Span, @@ -224,7 +214,6 @@ pub enum CharacterClassEscapeKind { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct UnicodePropertyEscape<'a> { #[estree(flatten)] pub span: Span, @@ -240,7 +229,6 @@ pub struct UnicodePropertyEscape<'a> { #[derive(Debug, Clone, Copy)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct Dot { #[estree(flatten)] pub span: Span, @@ -252,7 +240,6 @@ pub struct Dot { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct CharacterClass<'a> { #[estree(flatten)] pub span: Span, @@ -314,7 +301,6 @@ impl<'a> GetSpan for CharacterClassContents<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct CharacterClassRange { #[estree(flatten)] pub span: Span, @@ -327,7 +313,6 @@ pub struct CharacterClassRange { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ClassStringDisjunction<'a> { #[estree(flatten)] pub span: Span, @@ -341,7 +326,6 @@ pub struct ClassStringDisjunction<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ClassString<'a> { #[estree(flatten)] pub span: Span, @@ -356,7 +340,6 @@ pub struct ClassString<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct CapturingGroup<'a> { #[estree(flatten)] pub span: Span, @@ -371,7 +354,6 @@ pub struct CapturingGroup<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct IgnoreGroup<'a> { #[estree(flatten)] pub span: Span, @@ -386,7 +368,6 @@ pub struct IgnoreGroup<'a> { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct ModifierFlags { pub ignore_case: bool, pub sticky: bool, @@ -399,7 +380,6 @@ pub struct ModifierFlags { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct IndexedReference { #[estree(flatten)] pub span: Span, @@ -412,7 +392,6 @@ pub struct IndexedReference { #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(tag = "type")] pub struct NamedReference<'a> { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_regular_expression/src/generated/derive_estree.rs b/crates/oxc_regular_expression/src/generated/derive_estree.rs index d8861e170e430..a6359f6f0c7c9 100644 --- a/crates/oxc_regular_expression/src/generated/derive_estree.rs +++ b/crates/oxc_regular_expression/src/generated/derive_estree.rs @@ -1,241 +1,481 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! // To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` -use serde::{Serialize, Serializer}; +#[allow(unused_imports)] +use serde::{ser::SerializeMap, Serialize, Serializer}; #[allow(clippy::wildcard_imports)] use crate::ast::*; impl<'a> Serialize for Pattern<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Pattern")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for Disjunction<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Disjunction")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for Alternative<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Alternative")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for Term<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + Term::BoundaryAssertion(ref x) => Serialize::serialize(x, serializer), + Term::LookAroundAssertion(ref x) => Serialize::serialize(x, serializer), + Term::Quantifier(ref x) => Serialize::serialize(x, serializer), + Term::Character(ref x) => Serialize::serialize(x, serializer), + Term::Dot(ref x) => Serialize::serialize(x, serializer), + Term::CharacterClassEscape(ref x) => Serialize::serialize(x, serializer), + Term::UnicodePropertyEscape(ref x) => Serialize::serialize(x, serializer), + Term::CharacterClass(ref x) => Serialize::serialize(x, serializer), + Term::CapturingGroup(ref x) => Serialize::serialize(x, serializer), + Term::IgnoreGroup(ref x) => Serialize::serialize(x, serializer), + Term::IndexedReference(ref x) => Serialize::serialize(x, serializer), + Term::NamedReference(ref x) => Serialize::serialize(x, serializer), + } } } impl Serialize for BoundaryAssertion { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "BoundaryAssertion")?; + map.serialize_entry("span", &self.span)?; + map.serialize_entry("kind", &self.kind)?; + map.end() } } impl Serialize for BoundaryAssertionKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + BoundaryAssertionKind::Start => { + serializer.serialize_unit_variant("BoundaryAssertionKind", 0u32, "start") + } + BoundaryAssertionKind::End => { + serializer.serialize_unit_variant("BoundaryAssertionKind", 1u32, "end") + } + BoundaryAssertionKind::Boundary => { + serializer.serialize_unit_variant("BoundaryAssertionKind", 2u32, "boundary") + } + BoundaryAssertionKind::NegativeBoundary => { + serializer.serialize_unit_variant("BoundaryAssertionKind", 3u32, "negativeBoundary") + } + } } } impl<'a> Serialize for LookAroundAssertion<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "LookAroundAssertion")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("kind", &self.kind)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl Serialize for LookAroundAssertionKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + LookAroundAssertionKind::Lookahead => { + serializer.serialize_unit_variant("LookAroundAssertionKind", 0u32, "lookahead") + } + LookAroundAssertionKind::NegativeLookahead => serializer.serialize_unit_variant( + "LookAroundAssertionKind", + 1u32, + "negativeLookahead", + ), + LookAroundAssertionKind::Lookbehind => { + serializer.serialize_unit_variant("LookAroundAssertionKind", 2u32, "lookbehind") + } + LookAroundAssertionKind::NegativeLookbehind => serializer.serialize_unit_variant( + "LookAroundAssertionKind", + 3u32, + "negativeLookbehind", + ), + } } } impl<'a> Serialize for Quantifier<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Quantifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("min", &self.min)?; + map.serialize_entry("max", &self.max)?; + map.serialize_entry("greedy", &self.greedy)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl Serialize for Character { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Character")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("kind", &self.kind)?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl Serialize for CharacterKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + CharacterKind::ControlLetter => { + serializer.serialize_unit_variant("CharacterKind", 0u32, "controlLetter") + } + CharacterKind::HexadecimalEscape => { + serializer.serialize_unit_variant("CharacterKind", 1u32, "hexadecimalEscape") + } + CharacterKind::Identifier => { + serializer.serialize_unit_variant("CharacterKind", 2u32, "identifier") + } + CharacterKind::Null => serializer.serialize_unit_variant("CharacterKind", 3u32, "null"), + CharacterKind::Octal1 => { + serializer.serialize_unit_variant("CharacterKind", 4u32, "octal1") + } + CharacterKind::Octal2 => { + serializer.serialize_unit_variant("CharacterKind", 5u32, "octal2") + } + CharacterKind::Octal3 => { + serializer.serialize_unit_variant("CharacterKind", 6u32, "octal3") + } + CharacterKind::SingleEscape => { + serializer.serialize_unit_variant("CharacterKind", 7u32, "singleEscape") + } + CharacterKind::Symbol => { + serializer.serialize_unit_variant("CharacterKind", 8u32, "symbol") + } + CharacterKind::UnicodeEscape => { + serializer.serialize_unit_variant("CharacterKind", 9u32, "unicodeEscape") + } + } } } impl Serialize for CharacterClassEscape { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "CharacterClassEscape")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("kind", &self.kind)?; + map.end() } } impl Serialize for CharacterClassEscapeKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + CharacterClassEscapeKind::D => { + serializer.serialize_unit_variant("CharacterClassEscapeKind", 0u32, "d") + } + CharacterClassEscapeKind::NegativeD => { + serializer.serialize_unit_variant("CharacterClassEscapeKind", 1u32, "negativeD") + } + CharacterClassEscapeKind::S => { + serializer.serialize_unit_variant("CharacterClassEscapeKind", 2u32, "s") + } + CharacterClassEscapeKind::NegativeS => { + serializer.serialize_unit_variant("CharacterClassEscapeKind", 3u32, "negativeS") + } + CharacterClassEscapeKind::W => { + serializer.serialize_unit_variant("CharacterClassEscapeKind", 4u32, "w") + } + CharacterClassEscapeKind::NegativeW => { + serializer.serialize_unit_variant("CharacterClassEscapeKind", 5u32, "negativeW") + } + } } } impl<'a> Serialize for UnicodePropertyEscape<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "UnicodePropertyEscape")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("negative", &self.negative)?; + map.serialize_entry("strings", &self.strings)?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("value", &self.value)?; + map.end() } } impl Serialize for Dot { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Dot")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() } } impl<'a> Serialize for CharacterClass<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "CharacterClass")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("negative", &self.negative)?; + map.serialize_entry("strings", &self.strings)?; + map.serialize_entry("kind", &self.kind)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl Serialize for CharacterClassContentsKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + CharacterClassContentsKind::Union => { + serializer.serialize_unit_variant("CharacterClassContentsKind", 0u32, "union") + } + CharacterClassContentsKind::Intersection => serializer.serialize_unit_variant( + "CharacterClassContentsKind", + 1u32, + "intersection", + ), + CharacterClassContentsKind::Subtraction => { + serializer.serialize_unit_variant("CharacterClassContentsKind", 2u32, "subtraction") + } + } } } impl<'a> Serialize for CharacterClassContents<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + CharacterClassContents::CharacterClassRange(ref x) => { + Serialize::serialize(x, serializer) + } + CharacterClassContents::CharacterClassEscape(ref x) => { + Serialize::serialize(x, serializer) + } + CharacterClassContents::UnicodePropertyEscape(ref x) => { + Serialize::serialize(x, serializer) + } + CharacterClassContents::Character(ref x) => Serialize::serialize(x, serializer), + CharacterClassContents::NestedCharacterClass(ref x) => { + Serialize::serialize(x, serializer) + } + CharacterClassContents::ClassStringDisjunction(ref x) => { + Serialize::serialize(x, serializer) + } + } } } impl Serialize for CharacterClassRange { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "CharacterClassRange")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("min", &self.min)?; + map.serialize_entry("max", &self.max)?; + map.end() } } impl<'a> Serialize for ClassStringDisjunction<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ClassStringDisjunction")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("strings", &self.strings)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for ClassString<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ClassString")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("strings", &self.strings)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for CapturingGroup<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "CapturingGroup")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl<'a> Serialize for IgnoreGroup<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "IgnoreGroup")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("enabling_modifiers", &self.enabling_modifiers)?; + map.serialize_entry("disabling_modifiers", &self.disabling_modifiers)?; + map.serialize_entry("body", &self.body)?; + map.end() } } impl Serialize for ModifierFlags { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ModifierFlags")?; + map.serialize_entry("ignore_case", &self.ignore_case)?; + map.serialize_entry("sticky", &self.sticky)?; + map.serialize_entry("multiline", &self.multiline)?; + map.end() } } impl Serialize for IndexedReference { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "IndexedReference")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("index", &self.index)?; + map.end() } } impl<'a> Serialize for NamedReference<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "NamedReference")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() } } diff --git a/crates/oxc_span/src/generated/derive_estree.rs b/crates/oxc_span/src/generated/derive_estree.rs index e06daeb82d42e..404a859faddc1 100644 --- a/crates/oxc_span/src/generated/derive_estree.rs +++ b/crates/oxc_span/src/generated/derive_estree.rs @@ -1,44 +1,75 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! // To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` -use serde::{Serialize, Serializer}; +#[allow(unused_imports)] +use serde::{ser::SerializeMap, Serialize, Serializer}; #[allow(clippy::wildcard_imports)] use crate::source_type::*; - impl Serialize for SourceType { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("language", &self.language)?; + map.serialize_entry("module_kind", &self.module_kind)?; + map.serialize_entry("variant", &self.variant)?; + map.end() } } impl Serialize for Language { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + Language::JavaScript => { + serializer.serialize_unit_variant("Language", 0u32, "javascript") + } + Language::TypeScript => { + serializer.serialize_unit_variant("Language", 1u32, "typescript") + } + Language::TypeScriptDefinition => { + serializer.serialize_unit_variant("Language", 2u32, "typescriptDefinition") + } + } } } impl Serialize for ModuleKind { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + ModuleKind::Script => serializer.serialize_unit_variant("ModuleKind", 0u32, "script"), + ModuleKind::Module => serializer.serialize_unit_variant("ModuleKind", 1u32, "module"), + ModuleKind::Unambiguous => { + serializer.serialize_unit_variant("ModuleKind", 2u32, "unambiguous") + } + } } } impl Serialize for LanguageVariant { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + LanguageVariant::Standard => { + serializer.serialize_unit_variant("LanguageVariant", 0u32, "standard") + } + LanguageVariant::Jsx => { + serializer.serialize_unit_variant("LanguageVariant", 1u32, "jsx") + } + } } } diff --git a/crates/oxc_span/src/lib.rs b/crates/oxc_span/src/lib.rs index d33fc2e35fc61..fc3016b6dc798 100644 --- a/crates/oxc_span/src/lib.rs +++ b/crates/oxc_span/src/lib.rs @@ -19,6 +19,11 @@ pub use crate::{ span::{GetSpan, GetSpanMut, Span, SPAN}, }; +mod generated { + #[cfg(feature = "serialize")] + pub mod derive_estree; +} + #[doc(hidden)] pub mod __internal { // Used by `format_compact_str!` macro defined in `compact_str.rs` diff --git a/crates/oxc_span/src/source_type/mod.rs b/crates/oxc_span/src/source_type/mod.rs index 290a56a22fb8c..5032e12934ef2 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -19,7 +19,7 @@ pub use error::UnknownExtension; #[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "camelCase")] +#[estree(no_type)] pub struct SourceType { /// JavaScript or TypeScript, default JavaScript pub(super) language: Language, @@ -36,9 +36,10 @@ pub struct SourceType { #[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "lowercase")] pub enum Language { + #[estree(rename = "javascript")] JavaScript = 0, + #[estree(rename = "typescript")] TypeScript = 1, #[estree(rename = "typescriptDefinition")] TypeScriptDefinition = 2, diff --git a/crates/oxc_syntax/src/generated/derive_estree.rs b/crates/oxc_syntax/src/generated/derive_estree.rs index 42200684ae53e..5fc926c5373e9 100644 --- a/crates/oxc_syntax/src/generated/derive_estree.rs +++ b/crates/oxc_syntax/src/generated/derive_estree.rs @@ -1,53 +1,207 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! // To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` -use serde::{Serialize, Serializer}; +#[allow(unused_imports)] +use serde::{ser::SerializeMap, Serialize, Serializer}; #[allow(clippy::wildcard_imports)] use crate::operator::*; - impl Serialize for AssignmentOperator { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + AssignmentOperator::Assign => { + serializer.serialize_unit_variant("AssignmentOperator", 0u32, "=") + } + AssignmentOperator::Addition => { + serializer.serialize_unit_variant("AssignmentOperator", 1u32, "+=") + } + AssignmentOperator::Subtraction => { + serializer.serialize_unit_variant("AssignmentOperator", 2u32, "-=") + } + AssignmentOperator::Multiplication => { + serializer.serialize_unit_variant("AssignmentOperator", 3u32, "*=") + } + AssignmentOperator::Division => { + serializer.serialize_unit_variant("AssignmentOperator", 4u32, "/=") + } + AssignmentOperator::Remainder => { + serializer.serialize_unit_variant("AssignmentOperator", 5u32, "%=") + } + AssignmentOperator::ShiftLeft => { + serializer.serialize_unit_variant("AssignmentOperator", 6u32, "<<=") + } + AssignmentOperator::ShiftRight => { + serializer.serialize_unit_variant("AssignmentOperator", 7u32, ">>=") + } + AssignmentOperator::ShiftRightZeroFill => { + serializer.serialize_unit_variant("AssignmentOperator", 8u32, ">>>=") + } + AssignmentOperator::BitwiseOR => { + serializer.serialize_unit_variant("AssignmentOperator", 9u32, "|=") + } + AssignmentOperator::BitwiseXOR => { + serializer.serialize_unit_variant("AssignmentOperator", 10u32, "^=") + } + AssignmentOperator::BitwiseAnd => { + serializer.serialize_unit_variant("AssignmentOperator", 11u32, "&=") + } + AssignmentOperator::LogicalAnd => { + serializer.serialize_unit_variant("AssignmentOperator", 12u32, "&&=") + } + AssignmentOperator::LogicalOr => { + serializer.serialize_unit_variant("AssignmentOperator", 13u32, "||=") + } + AssignmentOperator::LogicalNullish => { + serializer.serialize_unit_variant("AssignmentOperator", 14u32, "??=") + } + AssignmentOperator::Exponential => { + serializer.serialize_unit_variant("AssignmentOperator", 15u32, "**=") + } + } } } impl Serialize for BinaryOperator { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + BinaryOperator::Equality => { + serializer.serialize_unit_variant("BinaryOperator", 0u32, "==") + } + BinaryOperator::Inequality => { + serializer.serialize_unit_variant("BinaryOperator", 1u32, "!=") + } + BinaryOperator::StrictEquality => { + serializer.serialize_unit_variant("BinaryOperator", 2u32, "===") + } + BinaryOperator::StrictInequality => { + serializer.serialize_unit_variant("BinaryOperator", 3u32, "!==") + } + BinaryOperator::LessThan => { + serializer.serialize_unit_variant("BinaryOperator", 4u32, "<") + } + BinaryOperator::LessEqualThan => { + serializer.serialize_unit_variant("BinaryOperator", 5u32, "<=") + } + BinaryOperator::GreaterThan => { + serializer.serialize_unit_variant("BinaryOperator", 6u32, ">") + } + BinaryOperator::GreaterEqualThan => { + serializer.serialize_unit_variant("BinaryOperator", 7u32, ">=") + } + BinaryOperator::ShiftLeft => { + serializer.serialize_unit_variant("BinaryOperator", 8u32, "<<") + } + BinaryOperator::ShiftRight => { + serializer.serialize_unit_variant("BinaryOperator", 9u32, ">>") + } + BinaryOperator::ShiftRightZeroFill => { + serializer.serialize_unit_variant("BinaryOperator", 10u32, ">>>") + } + BinaryOperator::Addition => { + serializer.serialize_unit_variant("BinaryOperator", 11u32, "+") + } + BinaryOperator::Subtraction => { + serializer.serialize_unit_variant("BinaryOperator", 12u32, "-") + } + BinaryOperator::Multiplication => { + serializer.serialize_unit_variant("BinaryOperator", 13u32, "*") + } + BinaryOperator::Division => { + serializer.serialize_unit_variant("BinaryOperator", 14u32, "/") + } + BinaryOperator::Remainder => { + serializer.serialize_unit_variant("BinaryOperator", 15u32, "%") + } + BinaryOperator::BitwiseOR => { + serializer.serialize_unit_variant("BinaryOperator", 16u32, "|") + } + BinaryOperator::BitwiseXOR => { + serializer.serialize_unit_variant("BinaryOperator", 17u32, "^") + } + BinaryOperator::BitwiseAnd => { + serializer.serialize_unit_variant("BinaryOperator", 18u32, "&") + } + BinaryOperator::In => serializer.serialize_unit_variant("BinaryOperator", 19u32, "in"), + BinaryOperator::Instanceof => { + serializer.serialize_unit_variant("BinaryOperator", 20u32, "instanceof") + } + BinaryOperator::Exponential => { + serializer.serialize_unit_variant("BinaryOperator", 21u32, "**") + } + } } } impl Serialize for LogicalOperator { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + LogicalOperator::Or => serializer.serialize_unit_variant("LogicalOperator", 0u32, "||"), + LogicalOperator::And => { + serializer.serialize_unit_variant("LogicalOperator", 1u32, "&&") + } + LogicalOperator::Coalesce => { + serializer.serialize_unit_variant("LogicalOperator", 2u32, "??") + } + } } } impl Serialize for UnaryOperator { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + UnaryOperator::UnaryNegation => { + serializer.serialize_unit_variant("UnaryOperator", 0u32, "-") + } + UnaryOperator::UnaryPlus => { + serializer.serialize_unit_variant("UnaryOperator", 1u32, "+") + } + UnaryOperator::LogicalNot => { + serializer.serialize_unit_variant("UnaryOperator", 2u32, "!") + } + UnaryOperator::BitwiseNot => { + serializer.serialize_unit_variant("UnaryOperator", 3u32, "~") + } + UnaryOperator::Typeof => { + serializer.serialize_unit_variant("UnaryOperator", 4u32, "typeof") + } + UnaryOperator::Void => serializer.serialize_unit_variant("UnaryOperator", 5u32, "void"), + UnaryOperator::Delete => { + serializer.serialize_unit_variant("UnaryOperator", 6u32, "delete") + } + } } } impl Serialize for UpdateOperator { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { - serializer.serialize_none() + match *self { + UpdateOperator::Increment => { + serializer.serialize_unit_variant("UpdateOperator", 0u32, "++") + } + UpdateOperator::Decrement => { + serializer.serialize_unit_variant("UpdateOperator", 1u32, "--") + } + } } } diff --git a/crates/oxc_syntax/src/operator.rs b/crates/oxc_syntax/src/operator.rs index 9f44b8f6f2603..50842ef7dccd5 100644 --- a/crates/oxc_syntax/src/operator.rs +++ b/crates/oxc_syntax/src/operator.rs @@ -14,6 +14,7 @@ use crate::precedence::{GetPrecedence, Precedence}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum AssignmentOperator { #[estree(rename = "=")] Assign = 0, @@ -94,6 +95,7 @@ impl AssignmentOperator { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum BinaryOperator { #[estree(rename = "==")] Equality = 0, @@ -283,6 +285,7 @@ impl GetPrecedence for BinaryOperator { #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum LogicalOperator { #[estree(rename = "||")] Or = 0, @@ -324,6 +327,7 @@ impl GetPrecedence for LogicalOperator { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum UnaryOperator { #[estree(rename = "-")] UnaryNegation = 0, @@ -382,6 +386,7 @@ impl UnaryOperator { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] +#[estree(rename_all = "camelCase")] pub enum UpdateOperator { #[estree(rename = "++")] Increment = 0, diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index e06efd467266c..c3fe2d8cdf08b 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -1,9 +1,11 @@ +use convert_case::{Case, Casing}; use proc_macro2::TokenStream; use quote::quote; use super::{define_derive, Derive, DeriveOutput}; use crate::{ codegen::LateCtx, + markers::ESTreeStructAttribute, schema::{EnumDef, GetGenerics, GetIdent, TypeDef}, }; @@ -18,22 +20,22 @@ impl Derive for DeriveESTree { fn derive(&mut self, def: &TypeDef, _: &LateCtx) -> TokenStream { let ident = def.ident(); - if let TypeDef::Struct(it) = def { - println!("{ident:?} {:?}", it.markers.estree); - for field in &it.fields { - println!("- {:?}: {:?}", field.name, field.markers.derive_attributes.estree); - } - } + // if let TypeDef::Struct(it) = def { + // // println!("{ident:?} {:?}", it.markers.estree); + // // for field in &it.variants { + // // println!("- {:?}: {:?}", field.name, field.markers.derive_attributes.estree); + // // } + // } - // let body = match def { - // TypeDef::Enum(def) => serialize_enum(def), - // _ => quote! { serializer.serialize_none() }, - // }; - let body = quote! { serializer.serialize_none() }; + let body = match def { + TypeDef::Enum(def) => serialize_enum(def), + TypeDef::Struct(def) => serialize_struct(def), + }; if def.has_lifetime() { quote! { impl<'a> Serialize for #ident<'a> { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { @@ -44,6 +46,7 @@ impl Derive for DeriveESTree { } else { quote! { impl Serialize for #ident { + #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { @@ -56,13 +59,123 @@ impl Derive for DeriveESTree { fn prelude() -> TokenStream { quote! { - use serde::{Serialize, Serializer}; + #[allow(unused_imports)] + use serde::{Serialize, Serializer, ser::SerializeMap}; + } + } +} + +fn serialize_struct(def: &crate::schema::StructDef) -> TokenStream { + let ident = def.ident(); + // If type_tag is Some, we serialize it manually. If None, either one of + // the fields is named r#type, or the struct does not need a "type" field. + let type_tag = match def.markers.estree { + Some(ESTreeStructAttribute::NoType) => None, + Some(ESTreeStructAttribute::Type(ref type_name)) => Some(type_name.clone()), + None => { + let has_type_field = + def.fields.iter().any(|f| matches!(f.name.as_deref(), Some("type"))); + if has_type_field { + None + } else { + Some(ident.to_string()) + } } + }; + + let mut fields = vec![]; + if let Some(ref ty) = type_tag { + fields.push(quote! { map.serialize_entry("type", #ty)?; }); + } + for field in &def.fields { + if field.markers.derive_attributes.estree.skip { + continue; + } + let name = match &field.markers.derive_attributes.estree.rename { + Some(rename) => rename.to_string(), + None => field.name.clone().unwrap(), + }; + assert!( + !(name == "type" && type_tag.is_some()), + "Unexpected r#type field when #[estree(type = ...)] is specified (on {ident})" + ); + + let ident = field.ident().unwrap(); + if field.markers.derive_attributes.estree.flatten { + fields.push(quote! { + self.#ident.serialize( + serde::__private::ser::FlatMapSerializer(&mut map) + )?; + }); + } else { + fields.push(quote! { + map.serialize_entry(#name, &self.#ident)?; + }); + } + } + + quote! { + let mut map = serializer.serialize_map(None)?; + #(#fields)* + map.end() } } +// 3 different kinds of AST enums: +// 1. Transparent enums, which would be #[serde(untagged)]. These take their +// type tag from their children. Each of the variants is its own struct. +// 2. Type enums, which are not camelCased. These are for example the +// r#type field of a Function, and are used instead of the struct name +// as the type field on the JSON. +// 3. All other enums, which are camelCased. fn serialize_enum(def: &EnumDef) -> TokenStream { let ident = def.ident(); + if def.markers.estree.untagged { + let match_branches = def.all_variants().map(|var| { + let var_ident = var.ident(); + assert!(var.fields.len() == 1, "Each variant of an untagged enum must have exactly one inner field (on {ident}::{var_ident})"); + quote! { + #ident::#var_ident(ref x) => { + Serialize::serialize(x, serializer) + } + } + }); + quote! { + match *self { + #(#match_branches),* + } + } + } else { + let match_branches = def.all_variants().map(|var| { + let var_ident = var.ident(); + let enum_name = ident.to_string(); + let discriminant = u32::from(var.discriminant); + let serialized_to = match var.markers.derive_attributes.estree.rename.as_ref() { + Some(rename) => rename.to_string(), + None => match def.markers.estree.rename_all.as_deref() { + Some("camelCase") => var_ident.to_string().to_case(Case::Camel), + Some(case) => { + panic!("Unsupported rename_all: {case} (on {ident})") + } + None => var_ident.to_string(), + }, + }; + assert!( + var.fields.is_empty(), + "Tagged enums must not have inner fields (on {ident}::{var_ident})" + ); + quote! { + #ident::#var_ident => { + serializer.serialize_unit_variant(#enum_name, #discriminant, #serialized_to) + } + } + }); + quote! { + match *self { + #(#match_branches),* + } + } + } // if def.markers.estree.untagged { // let match_branches = def.variants.iter().map(|var| { // let var_ident= var.ident(); @@ -73,5 +186,4 @@ fn serialize_enum(def: &EnumDef) -> TokenStream { // }) // } // def.markers.estree. - todo!() } diff --git a/tasks/ast_tools/src/derives/mod.rs b/tasks/ast_tools/src/derives/mod.rs index 34d5c4bf0399f..018c37ec94583 100644 --- a/tasks/ast_tools/src/derives/mod.rs +++ b/tasks/ast_tools/src/derives/mod.rs @@ -48,7 +48,6 @@ macro_rules! define_derive { .chain(it.strip_suffix("::mod").unwrap_or(it).split("::").skip(1)) .chain(["*"]) .join("::"); - println!("{local_path}"); let use_module: syn::ItemUse = syn::parse_str(format!("use {local_path};").as_str()).unwrap(); quote::quote! { diff --git a/tasks/ast_tools/src/markers.rs b/tasks/ast_tools/src/markers.rs index 83ea27bf98ada..ea77337dcdc93 100644 --- a/tasks/ast_tools/src/markers.rs +++ b/tasks/ast_tools/src/markers.rs @@ -95,39 +95,46 @@ impl From<&Ident> for CloneInAttribute { } } -/// A struct representing the serde attributes (`$[serde(...)]`) that we implement for structs and enums. +/// An enum representing the serde attributes (`$[serde(...)]`) that we implement for structs. +#[derive(Debug, Serialize)] +pub enum ESTreeStructAttribute { + NoType, + Type(String), +} + +impl Parse for ESTreeStructAttribute { + fn parse(input: ParseStream) -> Result { + let is_type = input.peek(Token![type]); + if is_type { + input.parse::()?; + input.parse::()?; + Ok(Self::Type(input.parse::()?.value())) + } else { + let ident = input.call(Ident::parse_any).unwrap().to_string(); + if ident == "no_type" { + Ok(Self::NoType) + } else { + panic!("Unsupported #[estree(...)] argument: {ident}"); + } + } + } +} + +/// A struct representing the serde attributes (`$[serde(...)]`) that we implement for enums. #[derive(Debug, Serialize, Default)] -pub struct ESTreeOuterAttribute { - pub tag: Option, - pub rename: Option, +pub struct ESTreeEnumAttribute { pub rename_all: Option, pub untagged: bool, } -impl Parse for ESTreeOuterAttribute { +impl Parse for ESTreeEnumAttribute { fn parse(input: ParseStream) -> Result { - let mut tag = None; - let mut rename = None; let mut rename_all = None; let mut untagged = false; loop { let ident = input.call(Ident::parse_any).unwrap().to_string(); match ident.as_str() { - "tag" => { - input.parse::()?; - assert!( - tag.replace(input.parse::()?.value()).is_none(), - "Duplicate estree(tag)" - ); - } - "rename" => { - input.parse::()?; - assert!( - rename.replace(input.parse::()?.value()).is_none(), - "Duplicate estree(rename)" - ); - } "rename_all" => { input.parse::()?; assert!( @@ -151,7 +158,7 @@ impl Parse for ESTreeOuterAttribute { break; } } - Ok(Self { tag, rename, rename_all, untagged }) + Ok(Self { rename_all, untagged }) } } @@ -382,13 +389,14 @@ where }) } -pub fn get_estree_attribute<'a, I>(attrs: I) -> Option> +pub fn get_estree_attribute<'a, T, I>(attrs: I) -> Option> where I: IntoIterator, + T: Parse, { let attr = attrs.into_iter().find(|it| it.path().is_ident("estree")); attr.map(|attr| { debug_assert!(attr.path().is_ident("estree")); - attr.parse_args_with(ESTreeOuterAttribute::parse).normalize() + attr.parse_args_with(T::parse).normalize() }) } diff --git a/tasks/ast_tools/src/schema/defs.rs b/tasks/ast_tools/src/schema/defs.rs index eb9de3c547595..488c8789f1d28 100644 --- a/tasks/ast_tools/src/schema/defs.rs +++ b/tasks/ast_tools/src/schema/defs.rs @@ -2,7 +2,10 @@ use serde::Serialize; use super::{with_either, TypeName}; use crate::{ - markers::{DeriveAttributes, ESTreeOuterAttribute, ScopeAttribute, ScopeMarkers, VisitMarkers}, + markers::{ + DeriveAttributes, ESTreeEnumAttribute, ESTreeStructAttribute, ScopeAttribute, ScopeMarkers, + VisitMarkers, + }, util::{ToIdent, TypeAnalysis, TypeWrapper}, TypeId, }; @@ -60,7 +63,7 @@ pub struct StructDef { #[serde(skip)] pub generated_derives: Vec, #[serde(skip)] - pub markers: OuterMarkers, + pub markers: StructOuterMarkers, #[serde(skip)] pub module_path: String, } @@ -85,7 +88,7 @@ pub struct EnumDef { #[serde(skip)] pub module_path: String, #[serde(skip)] - pub markers: OuterMarkers, + pub markers: EnumOuterMarkers, } impl EnumDef { @@ -228,9 +231,14 @@ impl TypeRef { } #[derive(Debug)] -pub struct OuterMarkers { +pub struct StructOuterMarkers { pub scope: Option, - pub estree: ESTreeOuterAttribute, + pub estree: Option, +} + +#[derive(Debug)] +pub struct EnumOuterMarkers { + pub estree: ESTreeEnumAttribute, } #[derive(Debug, Serialize)] diff --git a/tasks/ast_tools/src/schema/mod.rs b/tasks/ast_tools/src/schema/mod.rs index 2a5651d9710ee..9fb2888ec316f 100644 --- a/tasks/ast_tools/src/schema/mod.rs +++ b/tasks/ast_tools/src/schema/mod.rs @@ -106,13 +106,17 @@ impl<'a> IntoIterator for &'a Schema { } } -fn parse_outer_markers(attrs: &Vec) -> Result { - Ok(OuterMarkers { +fn parse_struct_outer_markers(attrs: &Vec) -> Result { + Ok(StructOuterMarkers { scope: get_scope_attribute(attrs).transpose()?, - estree: get_estree_attribute(attrs).transpose()?.unwrap_or_default(), + estree: get_estree_attribute(attrs).transpose()?, }) } +fn parse_enum_outer_markers(attrs: &Vec) -> Result { + Ok(EnumOuterMarkers { estree: get_estree_attribute(attrs).transpose()?.unwrap_or_default() }) +} + fn parse_inner_markers(attrs: &Vec) -> Result { Ok(InnerMarkers { span: attrs.iter().any(|a| a.path().is_ident("span")), @@ -173,7 +177,7 @@ fn lower_ast_enum(it @ rust::Enum { item, meta }: &rust::Enum, ctx: &codegen::Ea align_32, offsets_32, - markers: parse_outer_markers(&item.attrs).unwrap(), + markers: parse_enum_outer_markers(&item.attrs).unwrap(), generated_derives: parse_generate_derive(&item.attrs), module_path: meta.module_path.clone(), @@ -208,7 +212,7 @@ fn lower_ast_struct( align_32, offsets_32, - markers: parse_outer_markers(&item.attrs).unwrap(), + markers: parse_struct_outer_markers(&item.attrs).unwrap(), generated_derives: parse_generate_derive(&item.attrs), module_path: meta.module_path.clone(), From d9894482fd044fc8946e18a3dac8f72be5ca10f9 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 10 Oct 2024 15:33:53 -0700 Subject: [PATCH 06/28] comment on ESTree trait --- crates/oxc_estree/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/oxc_estree/src/lib.rs b/crates/oxc_estree/src/lib.rs index 457144eedc6f6..9841846ee7278 100644 --- a/crates/oxc_estree/src/lib.rs +++ b/crates/oxc_estree/src/lib.rs @@ -1 +1,3 @@ +/// Empty trait that will be used later for custom serialization and TypeScript +/// generation for AST nodes. pub trait ESTree {} From c0c960e08e640f74c95a7bb49619dc703276f6f2 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 10 Oct 2024 15:56:40 -0700 Subject: [PATCH 07/28] camelCase fields --- crates/oxc_ast/src/ast/js.rs | 1 - crates/oxc_ast/src/generated/derive_estree.rs | 186 +++++++++--------- .../src/generated/derive_estree.rs | 6 +- .../oxc_span/src/generated/derive_estree.rs | 2 +- tasks/ast_tools/src/derives/estree.rs | 2 +- 5 files changed, 98 insertions(+), 99 deletions(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 76f64d96eb5f2..1039888e1f69b 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1832,7 +1832,6 @@ pub struct FormalParameter<'a> { #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] #[cfg_attr(feature = "serialize", derive(Tsify))] -#[estree(rename_all = "camelCase")] pub enum FormalParameterKind { /// FormalParameter = 0, diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs index 81db32b391267..0c6fa7c29b0c5 100644 --- a/crates/oxc_ast/src/generated/derive_estree.rs +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -148,7 +148,7 @@ impl<'a> Serialize for Program<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "Program")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("source_type", &self.source_type)?; + map.serialize_entry("sourceType", &self.source_type)?; map.serialize_entry("hashbang", &self.hashbang)?; map.serialize_entry("directives", &self.directives)?; map.serialize_entry("body", &self.body)?; @@ -517,7 +517,7 @@ impl<'a> Serialize for TaggedTemplateExpression<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("tag", &self.tag)?; map.serialize_entry("quasi", &self.quasi)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -624,7 +624,7 @@ impl<'a> Serialize for CallExpression<'a> { map.serialize_entry("type", "CallExpression")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("callee", &self.callee)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.serialize_entry("arguments", &self.arguments)?; map.serialize_entry("optional", &self.optional)?; map.end() @@ -642,7 +642,7 @@ impl<'a> Serialize for NewExpression<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("callee", &self.callee)?; map.serialize_entry("arguments", &self.arguments)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -1684,7 +1684,7 @@ impl<'a> Serialize for BindingPattern<'a> { { let mut map = serializer.serialize_map(None)?; self.kind.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.serialize_entry("optional", &self.optional)?; map.end() } @@ -1764,10 +1764,10 @@ impl<'a> Serialize for Function<'a> { map.serialize_entry("generator", &self.generator)?; map.serialize_entry("async", &self.r#async)?; map.serialize_entry("declare", &self.declare)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; - map.serialize_entry("this_param", &self.this_param)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + map.serialize_entry("thisParam", &self.this_param)?; map.serialize_entry("params", &self.params)?; - map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("returnType", &self.return_type)?; map.serialize_entry("body", &self.body)?; map.end() } @@ -1824,20 +1824,20 @@ impl Serialize for FormalParameterKind { { match *self { FormalParameterKind::FormalParameter => { - serializer.serialize_unit_variant("FormalParameterKind", 0u32, "formalParameter") + serializer.serialize_unit_variant("FormalParameterKind", 0u32, "FormalParameter") } FormalParameterKind::UniqueFormalParameters => serializer.serialize_unit_variant( "FormalParameterKind", 1u32, - "uniqueFormalParameters", + "UniqueFormalParameters", ), FormalParameterKind::ArrowFormalParameters => serializer.serialize_unit_variant( "FormalParameterKind", 2u32, - "arrowFormalParameters", + "ArrowFormalParameters", ), FormalParameterKind::Signature => { - serializer.serialize_unit_variant("FormalParameterKind", 3u32, "signature") + serializer.serialize_unit_variant("FormalParameterKind", 3u32, "Signature") } } } @@ -1869,9 +1869,9 @@ impl<'a> Serialize for ArrowFunctionExpression<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("expression", &self.expression)?; map.serialize_entry("async", &self.r#async)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.serialize_entry("params", &self.params)?; - map.serialize_entry("return_type", &self.return_type)?; + map.serialize_entry("returnType", &self.return_type)?; map.serialize_entry("body", &self.body)?; map.end() } @@ -1903,9 +1903,9 @@ impl<'a> Serialize for Class<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("decorators", &self.decorators)?; map.serialize_entry("id", &self.id)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; - map.serialize_entry("super_class", &self.super_class)?; - map.serialize_entry("super_type_parameters", &self.super_type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + map.serialize_entry("superClass", &self.super_class)?; + map.serialize_entry("superTypeParameters", &self.super_type_parameters)?; map.serialize_entry("implements", &self.implements)?; map.serialize_entry("body", &self.body)?; map.serialize_entry("abstract", &self.r#abstract)?; @@ -2021,7 +2021,7 @@ impl<'a> Serialize for PropertyDefinition<'a> { map.serialize_entry("optional", &self.optional)?; map.serialize_entry("definite", &self.definite)?; map.serialize_entry("readonly", &self.readonly)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.serialize_entry("accessibility", &self.accessibility)?; map.end() } @@ -2155,7 +2155,7 @@ impl<'a> Serialize for AccessorProperty<'a> { map.serialize_entry("computed", &self.computed)?; map.serialize_entry("static", &self.r#static)?; map.serialize_entry("definite", &self.definite)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.serialize_entry("accessibility", &self.accessibility)?; map.end() } @@ -2187,8 +2187,8 @@ impl<'a> Serialize for ImportDeclaration<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("specifiers", &self.specifiers)?; map.serialize_entry("source", &self.source)?; - map.serialize_entry("with_clause", &self.with_clause)?; - map.serialize_entry("import_kind", &self.import_kind)?; + map.serialize_entry("withClause", &self.with_clause)?; + map.serialize_entry("importKind", &self.import_kind)?; map.end() } } @@ -2224,7 +2224,7 @@ impl<'a> Serialize for ImportSpecifier<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("imported", &self.imported)?; map.serialize_entry("local", &self.local)?; - map.serialize_entry("import_kind", &self.import_kind)?; + map.serialize_entry("importKind", &self.import_kind)?; map.end() } } @@ -2266,8 +2266,8 @@ impl<'a> Serialize for WithClause<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "WithClause")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("attributes_keyword", &self.attributes_keyword)?; - map.serialize_entry("with_entries", &self.with_entries)?; + map.serialize_entry("attributesKeyword", &self.attributes_keyword)?; + map.serialize_entry("withEntries", &self.with_entries)?; map.end() } } @@ -2312,8 +2312,8 @@ impl<'a> Serialize for ExportNamedDeclaration<'a> { map.serialize_entry("declaration", &self.declaration)?; map.serialize_entry("specifiers", &self.specifiers)?; map.serialize_entry("source", &self.source)?; - map.serialize_entry("export_kind", &self.export_kind)?; - map.serialize_entry("with_clause", &self.with_clause)?; + map.serialize_entry("exportKind", &self.export_kind)?; + map.serialize_entry("withClause", &self.with_clause)?; map.end() } } @@ -2344,8 +2344,8 @@ impl<'a> Serialize for ExportAllDeclaration<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("exported", &self.exported)?; map.serialize_entry("source", &self.source)?; - map.serialize_entry("with_clause", &self.with_clause)?; - map.serialize_entry("export_kind", &self.export_kind)?; + map.serialize_entry("withClause", &self.with_clause)?; + map.serialize_entry("exportKind", &self.export_kind)?; map.end() } } @@ -2361,7 +2361,7 @@ impl<'a> Serialize for ExportSpecifier<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("local", &self.local)?; map.serialize_entry("exported", &self.exported)?; - map.serialize_entry("export_kind", &self.export_kind)?; + map.serialize_entry("exportKind", &self.export_kind)?; map.end() } } @@ -2525,8 +2525,8 @@ impl<'a> Serialize for TSThisParameter<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSThisParameter")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("this_span", &self.this_span)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("thisSpan", &self.this_span)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -2635,7 +2635,7 @@ impl<'a> Serialize for TSTypeAnnotation<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSTypeAnnotation")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -2731,10 +2731,10 @@ impl<'a> Serialize for TSConditionalType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSConditionalType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("check_type", &self.check_type)?; - map.serialize_entry("extends_type", &self.extends_type)?; - map.serialize_entry("true_type", &self.true_type)?; - map.serialize_entry("false_type", &self.false_type)?; + map.serialize_entry("checkType", &self.check_type)?; + map.serialize_entry("extendsType", &self.extends_type)?; + map.serialize_entry("trueType", &self.true_type)?; + map.serialize_entry("falseType", &self.false_type)?; map.end() } } @@ -2776,7 +2776,7 @@ impl<'a> Serialize for TSParenthesizedType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSParenthesizedType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -2791,7 +2791,7 @@ impl<'a> Serialize for TSTypeOperator<'a> { map.serialize_entry("type", "TSTypeOperator")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("operator", &self.operator)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -2825,7 +2825,7 @@ impl<'a> Serialize for TSArrayType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSArrayType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("element_type", &self.element_type)?; + map.serialize_entry("elementType", &self.element_type)?; map.end() } } @@ -2839,8 +2839,8 @@ impl<'a> Serialize for TSIndexedAccessType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSIndexedAccessType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("object_type", &self.object_type)?; - map.serialize_entry("index_type", &self.index_type)?; + map.serialize_entry("objectType", &self.object_type)?; + map.serialize_entry("indexType", &self.index_type)?; map.end() } } @@ -2854,7 +2854,7 @@ impl<'a> Serialize for TSTupleType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSTupleType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("element_types", &self.element_types)?; + map.serialize_entry("elementTypes", &self.element_types)?; map.end() } } @@ -2868,7 +2868,7 @@ impl<'a> Serialize for TSNamedTupleMember<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSNamedTupleMember")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("element_type", &self.element_type)?; + map.serialize_entry("elementType", &self.element_type)?; map.serialize_entry("label", &self.label)?; map.serialize_entry("optional", &self.optional)?; map.end() @@ -2884,7 +2884,7 @@ impl<'a> Serialize for TSOptionalType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSOptionalType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -2898,7 +2898,7 @@ impl<'a> Serialize for TSRestType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSRestType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -3145,8 +3145,8 @@ impl<'a> Serialize for TSTypeReference<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSTypeReference")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_name", &self.type_name)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeName", &self.type_name)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3236,8 +3236,8 @@ impl<'a> Serialize for TSTypeAliasDeclaration<'a> { map.serialize_entry("type", "TSTypeAliasDeclaration")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("id", &self.id)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.serialize_entry("declare", &self.declare)?; map.end() } @@ -3273,7 +3273,7 @@ impl<'a> Serialize for TSClassImplements<'a> { map.serialize_entry("type", "TSClassImplements")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("expression", &self.expression)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3289,7 +3289,7 @@ impl<'a> Serialize for TSInterfaceDeclaration<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("id", &self.id)?; map.serialize_entry("extends", &self.extends)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.serialize_entry("body", &self.body)?; map.serialize_entry("declare", &self.declare)?; map.end() @@ -3323,7 +3323,7 @@ impl<'a> Serialize for TSPropertySignature<'a> { map.serialize_entry("optional", &self.optional)?; map.serialize_entry("readonly", &self.readonly)?; map.serialize_entry("key", &self.key)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -3356,7 +3356,7 @@ impl<'a> Serialize for TSIndexSignature<'a> { map.serialize_entry("type", "TSIndexSignature")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("parameters", &self.parameters)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.serialize_entry("readonly", &self.readonly)?; map.end() } @@ -3371,10 +3371,10 @@ impl<'a> Serialize for TSCallSignatureDeclaration<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSCallSignatureDeclaration")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("this_param", &self.this_param)?; + map.serialize_entry("thisParam", &self.this_param)?; map.serialize_entry("params", &self.params)?; - map.serialize_entry("return_type", &self.return_type)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("returnType", &self.return_type)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3412,10 +3412,10 @@ impl<'a> Serialize for TSMethodSignature<'a> { map.serialize_entry("computed", &self.computed)?; map.serialize_entry("optional", &self.optional)?; map.serialize_entry("kind", &self.kind)?; - map.serialize_entry("this_param", &self.this_param)?; + map.serialize_entry("thisParam", &self.this_param)?; map.serialize_entry("params", &self.params)?; - map.serialize_entry("return_type", &self.return_type)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("returnType", &self.return_type)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3430,8 +3430,8 @@ impl<'a> Serialize for TSConstructSignatureDeclaration<'a> { map.serialize_entry("type", "TSConstructSignatureDeclaration")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("params", &self.params)?; - map.serialize_entry("return_type", &self.return_type)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("returnType", &self.return_type)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3446,7 +3446,7 @@ impl<'a> Serialize for TSIndexSignatureName<'a> { map.serialize_entry("type", "Identifier")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("name", &self.name)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -3461,7 +3461,7 @@ impl<'a> Serialize for TSInterfaceHeritage<'a> { map.serialize_entry("type", "TSInterfaceHeritage")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("expression", &self.expression)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3475,9 +3475,9 @@ impl<'a> Serialize for TSTypePredicate<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSTypePredicate")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("parameter_name", &self.parameter_name)?; + map.serialize_entry("parameterName", &self.parameter_name)?; map.serialize_entry("asserts", &self.asserts)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -3583,7 +3583,7 @@ impl<'a> Serialize for TSInferType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSInferType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_parameter", &self.type_parameter)?; + map.serialize_entry("typeParameter", &self.type_parameter)?; map.end() } } @@ -3597,8 +3597,8 @@ impl<'a> Serialize for TSTypeQuery<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSTypeQuery")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("expr_name", &self.expr_name)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("exprName", &self.expr_name)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3626,11 +3626,11 @@ impl<'a> Serialize for TSImportType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSImportType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("is_type_of", &self.is_type_of)?; + map.serialize_entry("isTypeOf", &self.is_type_of)?; map.serialize_entry("parameter", &self.parameter)?; map.serialize_entry("qualifier", &self.qualifier)?; map.serialize_entry("attributes", &self.attributes)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3644,7 +3644,7 @@ impl<'a> Serialize for TSImportAttributes<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSImportAttributes")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("attributes_keyword", &self.attributes_keyword)?; + map.serialize_entry("attributesKeyword", &self.attributes_keyword)?; map.serialize_entry("elements", &self.elements)?; map.end() } @@ -3687,10 +3687,10 @@ impl<'a> Serialize for TSFunctionType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSFunctionType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("this_param", &self.this_param)?; + map.serialize_entry("thisParam", &self.this_param)?; map.serialize_entry("params", &self.params)?; - map.serialize_entry("return_type", &self.return_type)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("returnType", &self.return_type)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3706,8 +3706,8 @@ impl<'a> Serialize for TSConstructorType<'a> { self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("abstract", &self.r#abstract)?; map.serialize_entry("params", &self.params)?; - map.serialize_entry("return_type", &self.return_type)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("returnType", &self.return_type)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3721,9 +3721,9 @@ impl<'a> Serialize for TSMappedType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "TSMappedType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_parameter", &self.type_parameter)?; - map.serialize_entry("name_type", &self.name_type)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeParameter", &self.type_parameter)?; + map.serialize_entry("nameType", &self.name_type)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.serialize_entry("optional", &self.optional)?; map.serialize_entry("readonly", &self.readonly)?; map.end() @@ -3778,7 +3778,7 @@ impl<'a> Serialize for TSAsExpression<'a> { map.serialize_entry("type", "TSAsExpression")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("expression", &self.expression)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -3793,7 +3793,7 @@ impl<'a> Serialize for TSSatisfiesExpression<'a> { map.serialize_entry("type", "TSSatisfiesExpression")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("expression", &self.expression)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -3808,7 +3808,7 @@ impl<'a> Serialize for TSTypeAssertion<'a> { map.serialize_entry("type", "TSTypeAssertion")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("expression", &self.expression)?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } @@ -3823,8 +3823,8 @@ impl<'a> Serialize for TSImportEqualsDeclaration<'a> { map.serialize_entry("type", "TSImportEqualsDeclaration")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("id", &self.id)?; - map.serialize_entry("module_reference", &self.module_reference)?; - map.serialize_entry("import_kind", &self.import_kind)?; + map.serialize_entry("moduleReference", &self.module_reference)?; + map.serialize_entry("importKind", &self.import_kind)?; map.end() } } @@ -3925,7 +3925,7 @@ impl<'a> Serialize for TSInstantiationExpression<'a> { map.serialize_entry("type", "TSInstantiationExpression")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; map.serialize_entry("expression", &self.expression)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -3956,7 +3956,7 @@ impl<'a> Serialize for JSDocNullableType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "JSDocNullableType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.serialize_entry("postfix", &self.postfix)?; map.end() } @@ -3971,7 +3971,7 @@ impl<'a> Serialize for JSDocNonNullableType<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "JSDocNonNullableType")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("type_annotation", &self.type_annotation)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.serialize_entry("postfix", &self.postfix)?; map.end() } @@ -3999,8 +3999,8 @@ impl<'a> Serialize for JSXElement<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "JSXElement")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("opening_element", &self.opening_element)?; - map.serialize_entry("closing_element", &self.closing_element)?; + map.serialize_entry("openingElement", &self.opening_element)?; + map.serialize_entry("closingElement", &self.closing_element)?; map.serialize_entry("children", &self.children)?; map.end() } @@ -4015,10 +4015,10 @@ impl<'a> Serialize for JSXOpeningElement<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "JSXOpeningElement")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("self_closing", &self.self_closing)?; + map.serialize_entry("selfClosing", &self.self_closing)?; map.serialize_entry("name", &self.name)?; map.serialize_entry("attributes", &self.attributes)?; - map.serialize_entry("type_parameters", &self.type_parameters)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; map.end() } } @@ -4046,8 +4046,8 @@ impl<'a> Serialize for JSXFragment<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "JSXFragment")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("opening_fragment", &self.opening_fragment)?; - map.serialize_entry("closing_fragment", &self.closing_fragment)?; + map.serialize_entry("openingFragment", &self.opening_fragment)?; + map.serialize_entry("closingFragment", &self.closing_fragment)?; map.serialize_entry("children", &self.children)?; map.end() } diff --git a/crates/oxc_regular_expression/src/generated/derive_estree.rs b/crates/oxc_regular_expression/src/generated/derive_estree.rs index a6359f6f0c7c9..92cd380e74a3b 100644 --- a/crates/oxc_regular_expression/src/generated/derive_estree.rs +++ b/crates/oxc_regular_expression/src/generated/derive_estree.rs @@ -430,8 +430,8 @@ impl<'a> Serialize for IgnoreGroup<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "IgnoreGroup")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("enabling_modifiers", &self.enabling_modifiers)?; - map.serialize_entry("disabling_modifiers", &self.disabling_modifiers)?; + map.serialize_entry("enablingModifiers", &self.enabling_modifiers)?; + map.serialize_entry("disablingModifiers", &self.disabling_modifiers)?; map.serialize_entry("body", &self.body)?; map.end() } @@ -445,7 +445,7 @@ impl Serialize for ModifierFlags { { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "ModifierFlags")?; - map.serialize_entry("ignore_case", &self.ignore_case)?; + map.serialize_entry("ignoreCase", &self.ignore_case)?; map.serialize_entry("sticky", &self.sticky)?; map.serialize_entry("multiline", &self.multiline)?; map.end() diff --git a/crates/oxc_span/src/generated/derive_estree.rs b/crates/oxc_span/src/generated/derive_estree.rs index 404a859faddc1..eb1622bb49c9a 100644 --- a/crates/oxc_span/src/generated/derive_estree.rs +++ b/crates/oxc_span/src/generated/derive_estree.rs @@ -15,7 +15,7 @@ impl Serialize for SourceType { { let mut map = serializer.serialize_map(None)?; map.serialize_entry("language", &self.language)?; - map.serialize_entry("module_kind", &self.module_kind)?; + map.serialize_entry("moduleKind", &self.module_kind)?; map.serialize_entry("variant", &self.variant)?; map.end() } diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index c3fe2d8cdf08b..9fbbbb367a432 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -93,7 +93,7 @@ fn serialize_struct(def: &crate::schema::StructDef) -> TokenStream { } let name = match &field.markers.derive_attributes.estree.rename { Some(rename) => rename.to_string(), - None => field.name.clone().unwrap(), + None => field.name.clone().unwrap().to_case(Case::Camel), }; assert!( !(name == "type" && type_tag.is_some()), From efbdae6b4a56fa94b9144a9babd1a8d9f8db53f1 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 10 Oct 2024 16:08:42 -0700 Subject: [PATCH 08/28] remove comments --- tasks/ast_tools/src/derives/estree.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index 9fbbbb367a432..0518af22910ed 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -20,12 +20,6 @@ impl Derive for DeriveESTree { fn derive(&mut self, def: &TypeDef, _: &LateCtx) -> TokenStream { let ident = def.ident(); - // if let TypeDef::Struct(it) = def { - // // println!("{ident:?} {:?}", it.markers.estree); - // // for field in &it.variants { - // // println!("- {:?}: {:?}", field.name, field.markers.derive_attributes.estree); - // // } - // } let body = match def { TypeDef::Enum(def) => serialize_enum(def), From fb02a4c4163f1e939ea0c520d050c38fc4b8df18 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 23:13:49 +0000 Subject: [PATCH 09/28] [autofix.ci] apply automated fixes --- crates/oxc_ast/Cargo.toml | 18 +++++++++--------- crates/oxc_regular_expression/Cargo.toml | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 3fcfc8dda24b0..d99e3ca3f86cf 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -38,13 +38,13 @@ wasm-bindgen = { workspace = true, optional = true } [features] default = [] serialize = [ - "dep:serde", - "dep:serde_json", - "dep:tsify", - "dep:wasm-bindgen", - "oxc_allocator/serialize", - "oxc_regular_expression/serialize", - "oxc_span/serialize", - "oxc_syntax/serialize", - "oxc_syntax/to_js_string", + "dep:serde", + "dep:serde_json", + "dep:tsify", + "dep:wasm-bindgen", + "oxc_allocator/serialize", + "oxc_regular_expression/serialize", + "oxc_span/serialize", + "oxc_syntax/serialize", + "oxc_syntax/to_js_string", ] diff --git a/crates/oxc_regular_expression/Cargo.toml b/crates/oxc_regular_expression/Cargo.toml index c614397612fb1..3e1ff4ed02cc2 100644 --- a/crates/oxc_regular_expression/Cargo.toml +++ b/crates/oxc_regular_expression/Cargo.toml @@ -37,11 +37,11 @@ wasm-bindgen = { workspace = true, optional = true } [features] default = [] serialize = [ - "dep:serde", - "dep:tsify", - "dep:wasm-bindgen", - "oxc_allocator/serialize", - "oxc_span/serialize", + "dep:serde", + "dep:tsify", + "dep:wasm-bindgen", + "oxc_allocator/serialize", + "oxc_span/serialize", ] [package.metadata.cargo-shear] From 0b6732b635c9049e91411fee474649376b8cd673 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 10 Oct 2024 16:13:51 -0700 Subject: [PATCH 10/28] regenerate --- .../src/generated/derive_estree.rs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/crates/oxc_regular_expression/src/generated/derive_estree.rs b/crates/oxc_regular_expression/src/generated/derive_estree.rs index 92cd380e74a3b..8acc5287ac264 100644 --- a/crates/oxc_regular_expression/src/generated/derive_estree.rs +++ b/crates/oxc_regular_expression/src/generated/derive_estree.rs @@ -430,24 +430,38 @@ impl<'a> Serialize for IgnoreGroup<'a> { let mut map = serializer.serialize_map(None)?; map.serialize_entry("type", "IgnoreGroup")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("enablingModifiers", &self.enabling_modifiers)?; - map.serialize_entry("disablingModifiers", &self.disabling_modifiers)?; + map.serialize_entry("modifiers", &self.modifiers)?; map.serialize_entry("body", &self.body)?; map.end() } } -impl Serialize for ModifierFlags { +impl Serialize for Modifiers { #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result where S: Serializer, { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "ModifierFlags")?; + map.serialize_entry("type", "Modifiers")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("enabling", &self.enabling)?; + map.serialize_entry("disabling", &self.disabling)?; + map.end() + } +} + +impl Serialize for Modifier { + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Modifier")?; map.serialize_entry("ignoreCase", &self.ignore_case)?; - map.serialize_entry("sticky", &self.sticky)?; map.serialize_entry("multiline", &self.multiline)?; + map.serialize_entry("sticky", &self.sticky)?; map.end() } } From 69884df825e9519ba6f1b950e2b5743731fbfb8d Mon Sep 17 00:00:00 2001 From: Ottomated Date: Fri, 11 Oct 2024 16:14:28 -0700 Subject: [PATCH 11/28] begin tsify work --- .github/.generated_ast_watch_list.yml | 1 + Cargo.lock | 4 + npm/oxc-types/src/generated/types.d.ts | 577 ++++++++++++++++++ tasks/ast_tools/Cargo.toml | 4 + tasks/ast_tools/src/codegen.rs | 5 +- tasks/ast_tools/src/derives/estree.rs | 10 - .../src/generators/assert_layouts.rs | 2 +- tasks/ast_tools/src/generators/ast_builder.rs | 2 +- tasks/ast_tools/src/generators/ast_kind.rs | 2 +- tasks/ast_tools/src/generators/mod.rs | 7 +- tasks/ast_tools/src/generators/typescript.rs | 94 +++ tasks/ast_tools/src/generators/visit.rs | 4 +- tasks/ast_tools/src/main.rs | 4 +- 13 files changed, 698 insertions(+), 18 deletions(-) create mode 100644 npm/oxc-types/src/generated/types.d.ts create mode 100644 tasks/ast_tools/src/generators/typescript.rs diff --git a/.github/.generated_ast_watch_list.yml b/.github/.generated_ast_watch_list.yml index 6b6d63d255f0e..b7a3c803c35d1 100644 --- a/.github/.generated_ast_watch_list.yml +++ b/.github/.generated_ast_watch_list.yml @@ -31,5 +31,6 @@ src: - 'crates/oxc_ast/src/generated/ast_builder.rs' - 'crates/oxc_ast/src/generated/visit.rs' - 'crates/oxc_ast/src/generated/visit_mut.rs' + - 'npm/oxc-types/src/generated/types.d.ts' - 'tasks/ast_tools/src/**' - '.github/.generated_ast_watch_list.yml' diff --git a/Cargo.lock b/Cargo.lock index 79b8d45cb695e..d096ed361a135 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1489,6 +1489,10 @@ dependencies = [ "convert_case", "itertools", "lazy_static", + "oxc_allocator", + "oxc_parser", + "oxc_prettier", + "oxc_span", "prettyplease", "proc-macro2", "quote", diff --git a/npm/oxc-types/src/generated/types.d.ts b/npm/oxc-types/src/generated/types.d.ts new file mode 100644 index 0000000000000..fc39b2601c302 --- /dev/null +++ b/npm/oxc-types/src/generated/types.d.ts @@ -0,0 +1,577 @@ +// To edit this generated file you have to edit `tasks/ast_tools/src/generators/typescript.rs` +// Auto-generated code, DO NOT EDIT DIRECTLY! + +type bool = boolean;type f64 = number;type str = string;type Atom = string;type u32 = number;type u64 = number; + +export type BooleanLiteral = {span: Span;value: bool;} + +export type NullLiteral = {span: Span;} + +export type NumericLiteral = {span: Span;value: f64;raw: str;base: NumberBase;} + +export type BigIntLiteral = {span: Span;raw: Atom;base: BigintBase;} + +export type RegExpLiteral = {span: Span;value: EmptyObject;regex: RegExp;} + +export type RegExp = {pattern: RegExpPattern;flags: RegExpFlags;} + +export type RegExpPattern = Raw | Invalid | Pattern + +export type EmptyObject = {} + +export type StringLiteral = {span: Span;value: Atom;} + +export type Program = {span: Span;source_type: SourceType;hashbang: (Hashbang) | null;directives: Array;body: Array;scope_id: (ScopeId) | null;} + +export type Expression = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type IdentifierName = {span: Span;name: Atom;} + +export type IdentifierReference = {span: Span;name: Atom;reference_id: (ReferenceId) | null;} + +export type BindingIdentifier = {span: Span;name: Atom;symbol_id: (SymbolId) | null;} + +export type LabelIdentifier = {span: Span;name: Atom;} + +export type ThisExpression = {span: Span;} + +export type ArrayExpression = {span: Span;elements: Array;trailing_comma: (Span) | null;} + +export type ArrayExpressionElement = SpreadElement | Elision | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type Elision = {span: Span;} + +export type ObjectExpression = {span: Span;properties: Array;trailing_comma: (Span) | null;} + +export type ObjectPropertyKind = ObjectProperty | SpreadProperty + +export type ObjectProperty = {span: Span;kind: PropertyKind;key: PropertyKey;value: Expression;init: (Expression) | null;method: bool;shorthand: bool;computed: bool;} + +export type PropertyKey = StaticIdentifier | PrivateIdentifier | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type PropertyKind = 'Init' | 'Get' | 'Set' + +export type TemplateLiteral = {span: Span;quasis: Array;expressions: Array;} + +export type TaggedTemplateExpression = {span: Span;tag: Expression;quasi: TemplateLiteral;type_parameters: (TSTypeParameterInstantiation) | null;} + +export type TemplateElement = {span: Span;tail: bool;value: TemplateElementValue;} + +export type TemplateElementValue = {raw: Atom;cooked: (Atom) | null;} + +export type MemberExpression = ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type ComputedMemberExpression = {span: Span;object: Expression;expression: Expression;optional: bool;} + +export type StaticMemberExpression = {span: Span;object: Expression;property: IdentifierName;optional: bool;} + +export type PrivateFieldExpression = {span: Span;object: Expression;field: PrivateIdentifier;optional: bool;} + +export type CallExpression = {span: Span;callee: Expression;type_parameters: (TSTypeParameterInstantiation) | null;arguments: Array;optional: bool;} + +export type NewExpression = {span: Span;callee: Expression;arguments: Array;type_parameters: (TSTypeParameterInstantiation) | null;} + +export type MetaProperty = {span: Span;meta: IdentifierName;property: IdentifierName;} + +export type SpreadElement = {span: Span;argument: Expression;} + +export type Argument = SpreadElement | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type UpdateExpression = {span: Span;operator: UpdateOperator;prefix: bool;argument: SimpleAssignmentTarget;} + +export type UnaryExpression = {span: Span;operator: UnaryOperator;argument: Expression;} + +export type BinaryExpression = {span: Span;left: Expression;operator: BinaryOperator;right: Expression;} + +export type PrivateInExpression = {span: Span;left: PrivateIdentifier;operator: BinaryOperator;right: Expression;} + +export type LogicalExpression = {span: Span;left: Expression;operator: LogicalOperator;right: Expression;} + +export type ConditionalExpression = {span: Span;test: Expression;consequent: Expression;alternate: Expression;} + +export type AssignmentExpression = {span: Span;operator: AssignmentOperator;left: AssignmentTarget;right: Expression;} + +export type AssignmentTarget = AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget + +export type SimpleAssignmentTarget = AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type AssignmentTargetPattern = ArrayAssignmentTarget | ObjectAssignmentTarget + +export type ArrayAssignmentTarget = {span: Span;elements: Array<(AssignmentTargetMaybeDefault) | null>;rest: (AssignmentTargetRest) | null;trailing_comma: (Span) | null;} + +export type ObjectAssignmentTarget = {span: Span;properties: Array;rest: (AssignmentTargetRest) | null;} + +export type AssignmentTargetRest = {span: Span;target: AssignmentTarget;} + +export type AssignmentTargetMaybeDefault = AssignmentTargetWithDefault | AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget + +export type AssignmentTargetWithDefault = {span: Span;binding: AssignmentTarget;init: Expression;} + +export type AssignmentTargetProperty = AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty + +export type AssignmentTargetPropertyIdentifier = {span: Span;binding: IdentifierReference;init: (Expression) | null;} + +export type AssignmentTargetPropertyProperty = {span: Span;name: PropertyKey;binding: AssignmentTargetMaybeDefault;} + +export type SequenceExpression = {span: Span;expressions: Array;} + +export type Super = {span: Span;} + +export type AwaitExpression = {span: Span;argument: Expression;} + +export type ChainExpression = {span: Span;expression: ChainElement;} + +export type ChainElement = CallExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type ParenthesizedExpression = {span: Span;expression: Expression;} + +export type Statement = BlockStatement | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | IfStatement | LabeledStatement | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | WithStatement | VariableDeclaration | FunctionDeclaration | ClassDeclaration | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration | ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration + +export type Directive = {span: Span;expression: StringLiteral;directive: Atom;} + +export type Hashbang = {span: Span;value: Atom;} + +export type BlockStatement = {span: Span;body: Array;scope_id: (ScopeId) | null;} + +export type Declaration = VariableDeclaration | FunctionDeclaration | ClassDeclaration | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration + +export type VariableDeclaration = {span: Span;kind: VariableDeclarationKind;declarations: Array;declare: bool;} + +export type VariableDeclarationKind = 'Var' | 'Const' | 'Let' | 'Using' | 'AwaitUsing' + +export type VariableDeclarator = {span: Span;kind: VariableDeclarationKind;id: BindingPattern;init: (Expression) | null;definite: bool;} + +export type EmptyStatement = {span: Span;} + +export type ExpressionStatement = {span: Span;expression: Expression;} + +export type IfStatement = {span: Span;test: Expression;consequent: Statement;alternate: (Statement) | null;} + +export type DoWhileStatement = {span: Span;body: Statement;test: Expression;} + +export type WhileStatement = {span: Span;test: Expression;body: Statement;} + +export type ForStatement = {span: Span;init: (ForStatementInit) | null;test: (Expression) | null;update: (Expression) | null;body: Statement;scope_id: (ScopeId) | null;} + +export type ForStatementInit = VariableDeclaration | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type ForInStatement = {span: Span;left: ForStatementLeft;right: Expression;body: Statement;scope_id: (ScopeId) | null;} + +export type ForStatementLeft = VariableDeclaration | AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget + +export type ForOfStatement = {span: Span;await: bool;left: ForStatementLeft;right: Expression;body: Statement;scope_id: (ScopeId) | null;} + +export type ContinueStatement = {span: Span;label: (LabelIdentifier) | null;} + +export type BreakStatement = {span: Span;label: (LabelIdentifier) | null;} + +export type ReturnStatement = {span: Span;argument: (Expression) | null;} + +export type WithStatement = {span: Span;object: Expression;body: Statement;} + +export type SwitchStatement = {span: Span;discriminant: Expression;cases: Array;scope_id: (ScopeId) | null;} + +export type SwitchCase = {span: Span;test: (Expression) | null;consequent: Array;} + +export type LabeledStatement = {span: Span;label: LabelIdentifier;body: Statement;} + +export type ThrowStatement = {span: Span;argument: Expression;} + +export type TryStatement = {span: Span;block: BlockStatement;handler: (CatchClause) | null;finalizer: (BlockStatement) | null;} + +export type CatchClause = {span: Span;param: (CatchParameter) | null;body: BlockStatement;scope_id: (ScopeId) | null;} + +export type CatchParameter = {span: Span;pattern: BindingPattern;} + +export type DebuggerStatement = {span: Span;} + +export type BindingPattern = {kind: BindingPatternKind;type_annotation: (TSTypeAnnotation) | null;optional: bool;} + +export type BindingPatternKind = BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern + +export type AssignmentPattern = {span: Span;left: BindingPattern;right: Expression;} + +export type ObjectPattern = {span: Span;properties: Array;rest: (BindingRestElement) | null;} + +export type BindingProperty = {span: Span;key: PropertyKey;value: BindingPattern;shorthand: bool;computed: bool;} + +export type ArrayPattern = {span: Span;elements: Array<(BindingPattern) | null>;rest: (BindingRestElement) | null;} + +export type BindingRestElement = {span: Span;argument: BindingPattern;} + +export type Function = {type: FunctionType;span: Span;id: (BindingIdentifier) | null;generator: bool;async: bool;declare: bool;type_parameters: (TSTypeParameterDeclaration) | null;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;body: (FunctionBody) | null;scope_id: (ScopeId) | null;} + +export type FunctionType = 'FunctionDeclaration' | 'FunctionExpression' | 'TSDeclareFunction' | 'TSEmptyBodyFunctionExpression' + +export type FormalParameters = {span: Span;kind: FormalParameterKind;items: Array;rest: (BindingRestElement) | null;} + +export type FormalParameter = {span: Span;decorators: Array;pattern: BindingPattern;accessibility: (TSAccessibility) | null;readonly: bool;override: bool;} + +export type FormalParameterKind = 'FormalParameter' | 'UniqueFormalParameters' | 'ArrowFormalParameters' | 'Signature' + +export type FunctionBody = {span: Span;directives: Array;statements: Array;} + +export type ArrowFunctionExpression = {span: Span;expression: bool;async: bool;type_parameters: (TSTypeParameterDeclaration) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;body: FunctionBody;scope_id: (ScopeId) | null;} + +export type YieldExpression = {span: Span;delegate: bool;argument: (Expression) | null;} + +export type Class = {type: ClassType;span: Span;decorators: Array;id: (BindingIdentifier) | null;type_parameters: (TSTypeParameterDeclaration) | null;super_class: (Expression) | null;super_type_parameters: (TSTypeParameterInstantiation) | null;implements: (Array) | null;body: ClassBody;abstract: bool;declare: bool;scope_id: (ScopeId) | null;} + +export type ClassType = 'ClassDeclaration' | 'ClassExpression' + +export type ClassBody = {span: Span;body: Array;} + +export type ClassElement = StaticBlock | MethodDefinition | PropertyDefinition | AccessorProperty | TSIndexSignature + +export type MethodDefinition = {type: MethodDefinitionType;span: Span;decorators: Array;key: PropertyKey;value: Function;kind: MethodDefinitionKind;computed: bool;static: bool;override: bool;optional: bool;accessibility: (TSAccessibility) | null;} + +export type MethodDefinitionType = 'MethodDefinition' | 'TSAbstractMethodDefinition' + +export type PropertyDefinition = {type: PropertyDefinitionType;span: Span;decorators: Array;key: PropertyKey;value: (Expression) | null;computed: bool;static: bool;declare: bool;override: bool;optional: bool;definite: bool;readonly: bool;type_annotation: (TSTypeAnnotation) | null;accessibility: (TSAccessibility) | null;} + +export type PropertyDefinitionType = 'PropertyDefinition' | 'TSAbstractPropertyDefinition' + +export type MethodDefinitionKind = 'Constructor' | 'Method' | 'Get' | 'Set' + +export type PrivateIdentifier = {span: Span;name: Atom;} + +export type StaticBlock = {span: Span;body: Array;scope_id: (ScopeId) | null;} + +export type ModuleDeclaration = ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration + +export type AccessorPropertyType = 'AccessorProperty' | 'TSAbstractAccessorProperty' + +export type AccessorProperty = {type: AccessorPropertyType;span: Span;decorators: Array;key: PropertyKey;value: (Expression) | null;computed: bool;static: bool;definite: bool;type_annotation: (TSTypeAnnotation) | null;accessibility: (TSAccessibility) | null;} + +export type ImportExpression = {span: Span;source: Expression;arguments: Array;} + +export type ImportDeclaration = {span: Span;specifiers: (Array) | null;source: StringLiteral;with_clause: (WithClause) | null;import_kind: ImportOrExportKind;} + +export type ImportDeclarationSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier + +export type ImportSpecifier = {span: Span;imported: ModuleExportName;local: BindingIdentifier;import_kind: ImportOrExportKind;} + +export type ImportDefaultSpecifier = {span: Span;local: BindingIdentifier;} + +export type ImportNamespaceSpecifier = {span: Span;local: BindingIdentifier;} + +export type WithClause = {span: Span;attributes_keyword: IdentifierName;with_entries: Array;} + +export type ImportAttribute = {span: Span;key: ImportAttributeKey;value: StringLiteral;} + +export type ImportAttributeKey = Identifier | StringLiteral + +export type ExportNamedDeclaration = {span: Span;declaration: (Declaration) | null;specifiers: Array;source: (StringLiteral) | null;export_kind: ImportOrExportKind;with_clause: (WithClause) | null;} + +export type ExportDefaultDeclaration = {span: Span;declaration: ExportDefaultDeclarationKind;exported: ModuleExportName;} + +export type ExportAllDeclaration = {span: Span;exported: (ModuleExportName) | null;source: StringLiteral;with_clause: (WithClause) | null;export_kind: ImportOrExportKind;} + +export type ExportSpecifier = {span: Span;local: ModuleExportName;exported: ModuleExportName;export_kind: ImportOrExportKind;} + +export type ExportDefaultDeclarationKind = FunctionDeclaration | ClassDeclaration | TSInterfaceDeclaration | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type ModuleExportName = IdentifierName | IdentifierReference | StringLiteral + +export type TSThisParameter = {span: Span;this_span: Span;type_annotation: (TSTypeAnnotation) | null;} + +export type TSEnumDeclaration = {span: Span;id: BindingIdentifier;members: Array;const: bool;declare: bool;scope_id: (ScopeId) | null;} + +export type TSEnumMember = {span: Span;id: TSEnumMemberName;initializer: (Expression) | null;} + +export type TSEnumMemberName = StaticIdentifier | StaticStringLiteral | StaticTemplateLiteral | StaticNumericLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type TSTypeAnnotation = {span: Span;type_annotation: TSType;} + +export type TSLiteralType = {span: Span;literal: TSLiteral;} + +export type TSLiteral = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | UnaryExpression + +export type TSType = TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSNamedTupleMember | TSQualifiedName | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperatorType | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TSParenthesizedType | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType + +export type TSConditionalType = {span: Span;check_type: TSType;extends_type: TSType;true_type: TSType;false_type: TSType;scope_id: (ScopeId) | null;} + +export type TSUnionType = {span: Span;types: Array;} + +export type TSIntersectionType = {span: Span;types: Array;} + +export type TSParenthesizedType = {span: Span;type_annotation: TSType;} + +export type TSTypeOperator = {span: Span;operator: TSTypeOperatorOperator;type_annotation: TSType;} + +export type TSTypeOperatorOperator = 'Keyof' | 'Unique' | 'Readonly' + +export type TSArrayType = {span: Span;element_type: TSType;} + +export type TSIndexedAccessType = {span: Span;object_type: TSType;index_type: TSType;} + +export type TSTupleType = {span: Span;element_types: Array;} + +export type TSNamedTupleMember = {span: Span;element_type: TSTupleElement;label: IdentifierName;optional: bool;} + +export type TSOptionalType = {span: Span;type_annotation: TSType;} + +export type TSRestType = {span: Span;type_annotation: TSType;} + +export type TSTupleElement = TSOptionalType | TSRestType | TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSNamedTupleMember | TSQualifiedName | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperatorType | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TSParenthesizedType | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType + +export type TSAnyKeyword = {span: Span;} + +export type TSStringKeyword = {span: Span;} + +export type TSBooleanKeyword = {span: Span;} + +export type TSNumberKeyword = {span: Span;} + +export type TSNeverKeyword = {span: Span;} + +export type TSIntrinsicKeyword = {span: Span;} + +export type TSUnknownKeyword = {span: Span;} + +export type TSNullKeyword = {span: Span;} + +export type TSUndefinedKeyword = {span: Span;} + +export type TSVoidKeyword = {span: Span;} + +export type TSSymbolKeyword = {span: Span;} + +export type TSThisType = {span: Span;} + +export type TSObjectKeyword = {span: Span;} + +export type TSBigIntKeyword = {span: Span;} + +export type TSTypeReference = {span: Span;type_name: TSTypeName;type_parameters: (TSTypeParameterInstantiation) | null;} + +export type TSTypeName = IdentifierReference | QualifiedName + +export type TSQualifiedName = {span: Span;left: TSTypeName;right: IdentifierName;} + +export type TSTypeParameterInstantiation = {span: Span;params: Array;} + +export type TSTypeParameter = {span: Span;name: BindingIdentifier;constraint: (TSType) | null;default: (TSType) | null;in: bool;out: bool;const: bool;} + +export type TSTypeParameterDeclaration = {span: Span;params: Array;} + +export type TSTypeAliasDeclaration = {span: Span;id: BindingIdentifier;type_parameters: (TSTypeParameterDeclaration) | null;type_annotation: TSType;declare: bool;scope_id: (ScopeId) | null;} + +export type TSAccessibility = 'Private' | 'Protected' | 'Public' + +export type TSClassImplements = {span: Span;expression: TSTypeName;type_parameters: (TSTypeParameterInstantiation) | null;} + +export type TSInterfaceDeclaration = {span: Span;id: BindingIdentifier;extends: (Array) | null;type_parameters: (TSTypeParameterDeclaration) | null;body: TSInterfaceBody;declare: bool;scope_id: (ScopeId) | null;} + +export type TSInterfaceBody = {span: Span;body: Array;} + +export type TSPropertySignature = {span: Span;computed: bool;optional: bool;readonly: bool;key: PropertyKey;type_annotation: (TSTypeAnnotation) | null;} + +export type TSSignature = TSIndexSignature | TSPropertySignature | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSMethodSignature + +export type TSIndexSignature = {span: Span;parameters: Array;type_annotation: TSTypeAnnotation;readonly: bool;} + +export type TSCallSignatureDeclaration = {span: Span;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;} + +export type TSMethodSignatureKind = 'Method' | 'Get' | 'Set' + +export type TSMethodSignature = {span: Span;key: PropertyKey;computed: bool;optional: bool;kind: TSMethodSignatureKind;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;scope_id: (ScopeId) | null;} + +export type TSConstructSignatureDeclaration = {span: Span;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;scope_id: (ScopeId) | null;} + +export type TSIndexSignatureName = {span: Span;name: Atom;type_annotation: TSTypeAnnotation;} + +export type TSInterfaceHeritage = {span: Span;expression: Expression;type_parameters: (TSTypeParameterInstantiation) | null;} + +export type TSTypePredicate = {span: Span;parameter_name: TSTypePredicateName;asserts: bool;type_annotation: (TSTypeAnnotation) | null;} + +export type TSTypePredicateName = Identifier | This + +export type TSModuleDeclaration = {span: Span;id: TSModuleDeclarationName;body: (TSModuleDeclarationBody) | null;kind: TSModuleDeclarationKind;declare: bool;scope_id: (ScopeId) | null;} + +export type TSModuleDeclarationKind = 'Global' | 'Module' | 'Namespace' + +export type TSModuleDeclarationName = Identifier | StringLiteral + +export type TSModuleDeclarationBody = TSModuleDeclaration | TSModuleBlock + +export type TSModuleBlock = {span: Span;directives: Array;body: Array;} + +export type TSTypeLiteral = {span: Span;members: Array;} + +export type TSInferType = {span: Span;type_parameter: TSTypeParameter;} + +export type TSTypeQuery = {span: Span;expr_name: TSTypeQueryExprName;type_parameters: (TSTypeParameterInstantiation) | null;} + +export type TSTypeQueryExprName = TSImportType | IdentifierReference | QualifiedName + +export type TSImportType = {span: Span;is_type_of: bool;parameter: TSType;qualifier: (TSTypeName) | null;attributes: (TSImportAttributes) | null;type_parameters: (TSTypeParameterInstantiation) | null;} + +export type TSImportAttributes = {span: Span;attributes_keyword: IdentifierName;elements: Array;} + +export type TSImportAttribute = {span: Span;name: TSImportAttributeName;value: Expression;} + +export type TSImportAttributeName = Identifier | StringLiteral + +export type TSFunctionType = {span: Span;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: TSTypeAnnotation;type_parameters: (TSTypeParameterDeclaration) | null;} + +export type TSConstructorType = {span: Span;abstract: bool;params: FormalParameters;return_type: TSTypeAnnotation;type_parameters: (TSTypeParameterDeclaration) | null;} + +export type TSMappedType = {span: Span;type_parameter: TSTypeParameter;name_type: (TSType) | null;type_annotation: (TSType) | null;optional: TSMappedTypeModifierOperator;readonly: TSMappedTypeModifierOperator;scope_id: (ScopeId) | null;} + +export type TSMappedTypeModifierOperator = 'True' | 'Plus' | 'Minus' | 'None' + +export type TSTemplateLiteralType = {span: Span;quasis: Array;types: Array;} + +export type TSAsExpression = {span: Span;expression: Expression;type_annotation: TSType;} + +export type TSSatisfiesExpression = {span: Span;expression: Expression;type_annotation: TSType;} + +export type TSTypeAssertion = {span: Span;expression: Expression;type_annotation: TSType;} + +export type TSImportEqualsDeclaration = {span: Span;id: BindingIdentifier;module_reference: TSModuleReference;import_kind: ImportOrExportKind;} + +export type TSModuleReference = ExternalModuleReference | IdentifierReference | QualifiedName + +export type TSExternalModuleReference = {span: Span;expression: StringLiteral;} + +export type TSNonNullExpression = {span: Span;expression: Expression;} + +export type Decorator = {span: Span;expression: Expression;} + +export type TSExportAssignment = {span: Span;expression: Expression;} + +export type TSNamespaceExportDeclaration = {span: Span;id: IdentifierName;} + +export type TSInstantiationExpression = {span: Span;expression: Expression;type_parameters: TSTypeParameterInstantiation;} + +export type ImportOrExportKind = 'Value' | 'Type' + +export type JSDocNullableType = {span: Span;type_annotation: TSType;postfix: bool;} + +export type JSDocNonNullableType = {span: Span;type_annotation: TSType;postfix: bool;} + +export type JSDocUnknownType = {span: Span;} + +export type JSXElement = {span: Span;opening_element: JSXOpeningElement;closing_element: (JSXClosingElement) | null;children: Array;} + +export type JSXOpeningElement = {span: Span;self_closing: bool;name: JSXElementName;attributes: Array;type_parameters: (TSTypeParameterInstantiation) | null;} + +export type JSXClosingElement = {span: Span;name: JSXElementName;} + +export type JSXFragment = {span: Span;opening_fragment: JSXOpeningFragment;closing_fragment: JSXClosingFragment;children: Array;} + +export type JSXOpeningFragment = {span: Span;} + +export type JSXClosingFragment = {span: Span;} + +export type JSXElementName = Identifier | IdentifierReference | NamespacedName | MemberExpression | ThisExpression + +export type JSXNamespacedName = {span: Span;namespace: JSXIdentifier;property: JSXIdentifier;} + +export type JSXMemberExpression = {span: Span;object: JSXMemberExpressionObject;property: JSXIdentifier;} + +export type JSXMemberExpressionObject = IdentifierReference | MemberExpression | ThisExpression + +export type JSXExpressionContainer = {span: Span;expression: JSXExpression;} + +export type JSXExpression = EmptyExpression | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression + +export type JSXEmptyExpression = {span: Span;} + +export type JSXAttributeItem = Attribute | SpreadAttribute + +export type JSXAttribute = {span: Span;name: JSXAttributeName;value: (JSXAttributeValue) | null;} + +export type JSXSpreadAttribute = {span: Span;argument: Expression;} + +export type JSXAttributeName = Identifier | NamespacedName + +export type JSXAttributeValue = StringLiteral | ExpressionContainer | Element | Fragment + +export type JSXIdentifier = {span: Span;name: Atom;} + +export type JSXChild = Text | Element | Fragment | ExpressionContainer | Spread + +export type JSXSpreadChild = {span: Span;expression: Expression;} + +export type JSXText = {span: Span;value: Atom;} + +export type NumberBase = 'Float' | 'Decimal' | 'Binary' | 'Octal' | 'Hex' + +export type BigintBase = 'Decimal' | 'Binary' | 'Octal' | 'Hex' + +export type AssignmentOperator = 'Assign' | 'Addition' | 'Subtraction' | 'Multiplication' | 'Division' | 'Remainder' | 'ShiftLeft' | 'ShiftRight' | 'ShiftRightZeroFill' | 'BitwiseOR' | 'BitwiseXOR' | 'BitwiseAnd' | 'LogicalAnd' | 'LogicalOr' | 'LogicalNullish' | 'Exponential' + +export type BinaryOperator = 'Equality' | 'Inequality' | 'StrictEquality' | 'StrictInequality' | 'LessThan' | 'LessEqualThan' | 'GreaterThan' | 'GreaterEqualThan' | 'ShiftLeft' | 'ShiftRight' | 'ShiftRightZeroFill' | 'Addition' | 'Subtraction' | 'Multiplication' | 'Division' | 'Remainder' | 'BitwiseOR' | 'BitwiseXOR' | 'BitwiseAnd' | 'In' | 'Instanceof' | 'Exponential' + +export type LogicalOperator = 'Or' | 'And' | 'Coalesce' + +export type UnaryOperator = 'UnaryNegation' | 'UnaryPlus' | 'LogicalNot' | 'BitwiseNot' | 'Typeof' | 'Void' | 'Delete' + +export type UpdateOperator = 'Increment' | 'Decrement' + +export type Span = {start: u32;end: u32;} + +export type SourceType = {language: Language;module_kind: ModuleKind;variant: LanguageVariant;} + +export type Language = 'JavaScript' | 'TypeScript' | 'TypeScriptDefinition' + +export type ModuleKind = 'Script' | 'Module' | 'Unambiguous' + +export type LanguageVariant = 'Standard' | 'Jsx' + +export type Pattern = {span: Span;body: Disjunction;} + +export type Disjunction = {span: Span;body: Array;} + +export type Alternative = {span: Span;body: Array;} + +export type Term = BoundaryAssertion | LookAroundAssertion | Quantifier | Character | Dot | CharacterClassEscape | UnicodePropertyEscape | CharacterClass | CapturingGroup | IgnoreGroup | IndexedReference | NamedReference + +export type BoundaryAssertion = {span: Span;kind: BoundaryAssertionKind;} + +export type BoundaryAssertionKind = 'Start' | 'End' | 'Boundary' | 'NegativeBoundary' + +export type LookAroundAssertion = {span: Span;kind: LookAroundAssertionKind;body: Disjunction;} + +export type LookAroundAssertionKind = 'Lookahead' | 'NegativeLookahead' | 'Lookbehind' | 'NegativeLookbehind' + +export type Quantifier = {span: Span;min: u64;max: (u64) | null;greedy: bool;body: Term;} + +export type Character = {span: Span;kind: CharacterKind;value: u32;} + +export type CharacterKind = 'ControlLetter' | 'HexadecimalEscape' | 'Identifier' | 'Null' | 'Octal1' | 'Octal2' | 'Octal3' | 'SingleEscape' | 'Symbol' | 'UnicodeEscape' + +export type CharacterClassEscape = {span: Span;kind: CharacterClassEscapeKind;} + +export type CharacterClassEscapeKind = 'D' | 'NegativeD' | 'S' | 'NegativeS' | 'W' | 'NegativeW' + +export type UnicodePropertyEscape = {span: Span;negative: bool;strings: bool;name: Atom;value: (Atom) | null;} + +export type Dot = {span: Span;} + +export type CharacterClass = {span: Span;negative: bool;strings: bool;kind: CharacterClassContentsKind;body: Array;} + +export type CharacterClassContentsKind = 'Union' | 'Intersection' | 'Subtraction' + +export type CharacterClassContents = CharacterClassRange | CharacterClassEscape | UnicodePropertyEscape | Character | NestedCharacterClass | ClassStringDisjunction + +export type CharacterClassRange = {span: Span;min: Character;max: Character;} + +export type ClassStringDisjunction = {span: Span;strings: bool;body: Array;} + +export type ClassString = {span: Span;strings: bool;body: Array;} + +export type CapturingGroup = {span: Span;name: (Atom) | null;body: Disjunction;} + +export type IgnoreGroup = {span: Span;modifiers: (Modifiers) | null;body: Disjunction;} + +export type Modifiers = {span: Span;enabling: (Modifier) | null;disabling: (Modifier) | null;} + +export type Modifier = {ignore_case: bool;multiline: bool;sticky: bool;} + +export type IndexedReference = {span: Span;index: u32;} + +export type NamedReference = {span: Span;name: Atom;} + diff --git a/tasks/ast_tools/Cargo.toml b/tasks/ast_tools/Cargo.toml index 427ac0533ac7d..23924e64ff1ce 100644 --- a/tasks/ast_tools/Cargo.toml +++ b/tasks/ast_tools/Cargo.toml @@ -18,6 +18,10 @@ bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"] convert_case = { workspace = true } itertools = { workspace = true } lazy_static = { workspace = true } +oxc_allocator.workspace = true +oxc_parser.workspace = true +oxc_prettier.workspace = true +oxc_span.workspace = true prettyplease = { workspace = true } proc-macro2 = { workspace = true } quote = { workspace = true } diff --git a/tasks/ast_tools/src/codegen.rs b/tasks/ast_tools/src/codegen.rs index 582c278115a4a..8232459898d61 100644 --- a/tasks/ast_tools/src/codegen.rs +++ b/tasks/ast_tools/src/codegen.rs @@ -57,7 +57,10 @@ impl From<(PathBuf, TokenStream)> for SideEffect { impl From for SideEffect { fn from(output: GeneratorOutput) -> Self { - Self::from((output.0, output.1)) + match output { + GeneratorOutput::Rust(path, stream) => Self::from((path, stream)), + GeneratorOutput::Raw(path, content) => Self(path, content.into()), + } } } diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index 0518af22910ed..72ff3a521f41f 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -170,14 +170,4 @@ fn serialize_enum(def: &EnumDef) -> TokenStream { } } } - // if def.markers.estree.untagged { - // let match_branches = def.variants.iter().map(|var| { - // let var_ident= var.ident(); - // var.fields - // quote! { - // #ident::#var_ident() - // } - // }) - // } - // def.markers.estree. } diff --git a/tasks/ast_tools/src/generators/assert_layouts.rs b/tasks/ast_tools/src/generators/assert_layouts.rs index 6e58c7a176f92..2a8c042fec5c0 100644 --- a/tasks/ast_tools/src/generators/assert_layouts.rs +++ b/tasks/ast_tools/src/generators/assert_layouts.rs @@ -28,7 +28,7 @@ impl Generator for AssertLayouts { let header = generated_header!(); - GeneratorOutput( + GeneratorOutput::Rust( output(crate::AST_CRATE, "assert_layouts.rs"), quote! { #header diff --git a/tasks/ast_tools/src/generators/ast_builder.rs b/tasks/ast_tools/src/generators/ast_builder.rs index d3ec9bcd8dc68..b31004547a81f 100644 --- a/tasks/ast_tools/src/generators/ast_builder.rs +++ b/tasks/ast_tools/src/generators/ast_builder.rs @@ -34,7 +34,7 @@ impl Generator for AstBuilderGenerator { let header = generated_header!(); - GeneratorOutput( + GeneratorOutput::Rust( output(crate::AST_CRATE, "ast_builder.rs"), quote! { #header diff --git a/tasks/ast_tools/src/generators/ast_kind.rs b/tasks/ast_tools/src/generators/ast_kind.rs index 088e43053fc6f..77be365818be8 100644 --- a/tasks/ast_tools/src/generators/ast_kind.rs +++ b/tasks/ast_tools/src/generators/ast_kind.rs @@ -175,7 +175,7 @@ impl Generator for AstKindGenerator { let header = generated_header!(); - GeneratorOutput( + GeneratorOutput::Rust( output(crate::AST_CRATE, "ast_kind.rs"), quote! { #header diff --git a/tasks/ast_tools/src/generators/mod.rs b/tasks/ast_tools/src/generators/mod.rs index e16f356d06f41..066b1db2b0e26 100644 --- a/tasks/ast_tools/src/generators/mod.rs +++ b/tasks/ast_tools/src/generators/mod.rs @@ -7,11 +7,13 @@ use crate::codegen::LateCtx; mod assert_layouts; mod ast_builder; mod ast_kind; +mod typescript; mod visit; pub use assert_layouts::AssertLayouts; pub use ast_builder::AstBuilderGenerator; pub use ast_kind::AstKindGenerator; +pub use typescript::TypescriptGenerator; pub use visit::{VisitGenerator, VisitMutGenerator}; /// Inserts a newline in the `TokenStream`. @@ -27,7 +29,10 @@ pub trait Generator { } #[derive(Debug, Clone)] -pub struct GeneratorOutput(/* output path */ pub PathBuf, pub TokenStream); +pub enum GeneratorOutput { + Rust(/* output path */ PathBuf, TokenStream), + Raw(/* output path */ PathBuf, String), +} macro_rules! define_generator { ($vis:vis struct $ident:ident $($lifetime:lifetime)? $($rest:tt)*) => { diff --git a/tasks/ast_tools/src/generators/typescript.rs b/tasks/ast_tools/src/generators/typescript.rs new file mode 100644 index 0000000000000..d405d39c69ec9 --- /dev/null +++ b/tasks/ast_tools/src/generators/typescript.rs @@ -0,0 +1,94 @@ +use itertools::Itertools; +use oxc_allocator::Allocator; +use oxc_parser::{ParseOptions, Parser}; +use oxc_prettier::{Prettier, PrettierOptions, TrailingComma}; +use oxc_span::SourceType; + +use super::define_generator; +use crate::{ + codegen::LateCtx, + output, + schema::{EnumDef, GetIdent, StructDef, TypeDef, TypeName}, + Generator, GeneratorOutput, +}; + +define_generator! { + pub struct TypescriptGenerator; +} + +impl Generator for TypescriptGenerator { + fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput { + let file = file!().replace('\\', "/"); + let mut contents = format!( + "\ + // To edit this generated file you have to edit `{file}`\n\ + // Auto-generated code, DO NOT EDIT DIRECTLY!\n\n\ + type bool = boolean;type f64 = number;type str = string;type Atom = string;type u32 = number;type u64 = number;\n\n" + ); + + for def in ctx.schema() { + let type_def = match def { + TypeDef::Struct(it) => generate_struct(it), + TypeDef::Enum(it) => generate_enum(it), + }; + + let ident = def.ident(); + contents.push_str(&format!("export type {ident} = {type_def}\n\n",)); + } + + GeneratorOutput::Raw(output(crate::TYPESCRIPT_PACKAGE, "types.d.ts"), contents) + } +} + +fn generate_enum(def: &EnumDef) -> String { + if def.markers.estree.untagged { + def.all_variants().map(|v| v.ident().to_string()).join(" | ") + } else { + def.all_variants().map(|v| format!("'{}'", v.ident().to_string())).join(" | ") + } +} + +fn generate_struct(def: &StructDef) -> String { + let mut type_def = "{".to_string(); + for field in &def.fields { + let name = field.ident().expect("expected named field!").to_string(); + let name = name.strip_prefix("r#").map(ToString::to_string).unwrap_or(name); + let ty = type_to_string(field.typ.name()); + type_def.push_str(&format!("{name}: {ty};")); + } + type_def.push('}'); + type_def +} + +fn type_to_string(ty: &TypeName) -> String { + match ty { + TypeName::Ident(ident) => ident.to_string(), + TypeName::Vec(type_name) => format!("Array<{}>", type_to_string(type_name)), + TypeName::Box(type_name) | TypeName::Ref(type_name) | TypeName::Complex(type_name) => { + type_to_string(type_name) + } + TypeName::Opt(type_name) => format!("({}) | null", type_to_string(type_name)), + } +} + +/// Unusable until oxc_prettier supports comments +#[allow(dead_code)] +fn format_typescript(source_text: &str) -> String { + let allocator = Allocator::default(); + let source_type = SourceType::ts(); + let ret = Parser::new(&allocator, source_text, source_type) + .with_options(ParseOptions { preserve_parens: false, ..ParseOptions::default() }) + .parse(); + Prettier::new( + &allocator, + source_text, + ret.trivias, + PrettierOptions { + semi: true, + trailing_comma: TrailingComma::All, + single_quote: true, + ..PrettierOptions::default() + }, + ) + .build(&ret.program) +} diff --git a/tasks/ast_tools/src/generators/visit.rs b/tasks/ast_tools/src/generators/visit.rs index b017f04ad835e..b30270bcb0efe 100644 --- a/tasks/ast_tools/src/generators/visit.rs +++ b/tasks/ast_tools/src/generators/visit.rs @@ -28,13 +28,13 @@ define_generator! { impl Generator for VisitGenerator { fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput { - GeneratorOutput(output(crate::AST_CRATE, "visit.rs"), generate_visit::(ctx)) + GeneratorOutput::Rust(output(crate::AST_CRATE, "visit.rs"), generate_visit::(ctx)) } } impl Generator for VisitMutGenerator { fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput { - GeneratorOutput(output(crate::AST_CRATE, "visit_mut.rs"), generate_visit::(ctx)) + GeneratorOutput::Rust(output(crate::AST_CRATE, "visit_mut.rs"), generate_visit::(ctx)) } } diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index 8a5dd4b0eab48..50ffbc0f2ef2e 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -24,7 +24,7 @@ use derives::{ use fmt::cargo_fmt; use generators::{ AssertLayouts, AstBuilderGenerator, AstKindGenerator, Generator, GeneratorOutput, - VisitGenerator, VisitMutGenerator, + TypescriptGenerator, VisitGenerator, VisitMutGenerator, }; use passes::{CalcLayout, Linker}; use util::{write_all_to, NormalizeError}; @@ -42,6 +42,7 @@ static SOURCE_PATHS: &[&str] = &[ ]; const AST_CRATE: &str = "crates/oxc_ast"; +const TYPESCRIPT_PACKAGE: &str = "npm/oxc-types"; type Result = std::result::Result; type TypeId = usize; @@ -83,6 +84,7 @@ fn main() -> std::result::Result<(), Box> { .generate(AstBuilderGenerator) .generate(VisitGenerator) .generate(VisitMutGenerator) + .generate(TypescriptGenerator) .run()?; if !cli_options.dry_run { From c859d86dbc231221bc073613781525c54545ae82 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Tue, 15 Oct 2024 13:01:11 -0700 Subject: [PATCH 12/28] handle some macro attributes --- .../oxc_span/src/generated/derive_estree.rs | 17 + crates/oxc_span/src/span/types.rs | 6 +- npm/oxc-types/src/generated/types.d.ts | 476 +++++++++--------- tasks/ast_tools/src/derives/estree.rs | 33 +- tasks/ast_tools/src/generators/typescript.rs | 67 ++- tasks/ast_tools/src/schema/mod.rs | 1 + tasks/ast_tools/src/schema/serialize.rs | 32 ++ 7 files changed, 350 insertions(+), 282 deletions(-) create mode 100644 tasks/ast_tools/src/schema/serialize.rs diff --git a/crates/oxc_span/src/generated/derive_estree.rs b/crates/oxc_span/src/generated/derive_estree.rs index eb1622bb49c9a..a19467d5d7157 100644 --- a/crates/oxc_span/src/generated/derive_estree.rs +++ b/crates/oxc_span/src/generated/derive_estree.rs @@ -7,6 +7,23 @@ use serde::{ser::SerializeMap, Serialize, Serializer}; #[allow(clippy::wildcard_imports)] use crate::source_type::*; +#[allow(clippy::wildcard_imports)] +use crate::span::types::*; + +impl Serialize for Span { + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Span")?; + map.serialize_entry("start", &self.start)?; + map.serialize_entry("end", &self.end)?; + map.end() + } +} + impl Serialize for SourceType { #[allow(clippy::match_same_arms, unused_mut)] fn serialize(&self, serializer: S) -> Result diff --git a/crates/oxc_span/src/span/types.rs b/crates/oxc_span/src/span/types.rs index b470f04f75d34..f44e429903025 100644 --- a/crates/oxc_span/src/span/types.rs +++ b/crates/oxc_span/src/span/types.rs @@ -2,8 +2,9 @@ #![allow(non_snake_case)] use oxc_ast_macros::ast; +use oxc_estree::ESTree; #[cfg(feature = "serialize")] -use ::{serde::Serialize, tsify::Tsify}; +use tsify::Tsify; /// Newtype for working with text ranges /// @@ -28,8 +29,9 @@ use ::{serde::Serialize, tsify::Tsify}; /// assert_eq!(first.finish(), second.finish()); /// ``` #[ast] +#[generate_derive(ESTree)] #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[cfg_attr(feature = "serialize", derive(Tsify))] #[non_exhaustive] // Disallow struct expression constructor `Span {}` pub struct Span { pub start: u32, diff --git a/npm/oxc-types/src/generated/types.d.ts b/npm/oxc-types/src/generated/types.d.ts index fc39b2601c302..81d0003f80909 100644 --- a/npm/oxc-types/src/generated/types.d.ts +++ b/npm/oxc-types/src/generated/types.d.ts @@ -1,17 +1,15 @@ // To edit this generated file you have to edit `tasks/ast_tools/src/generators/typescript.rs` // Auto-generated code, DO NOT EDIT DIRECTLY! -type bool = boolean;type f64 = number;type str = string;type Atom = string;type u32 = number;type u64 = number; +export type BooleanLiteral = {type: 'BooleanLiteral';span: Span;value: boolean;} -export type BooleanLiteral = {span: Span;value: bool;} +export type NullLiteral = {type: 'NullLiteral';span: Span;} -export type NullLiteral = {span: Span;} +export type NumericLiteral = {type: 'NumericLiteral';span: Span;value: number;raw: string;} -export type NumericLiteral = {span: Span;value: f64;raw: str;base: NumberBase;} +export type BigIntLiteral = {type: 'BigIntLiteral';span: Span;raw: string;} -export type BigIntLiteral = {span: Span;raw: Atom;base: BigintBase;} - -export type RegExpLiteral = {span: Span;value: EmptyObject;regex: RegExp;} +export type RegExpLiteral = {type: 'RegExpLiteral';span: Span;value: EmptyObject;regex: RegExp;} export type RegExp = {pattern: RegExpPattern;flags: RegExpFlags;} @@ -19,77 +17,77 @@ export type RegExpPattern = Raw | Invalid | Pattern export type EmptyObject = {} -export type StringLiteral = {span: Span;value: Atom;} +export type StringLiteral = {type: 'StringLiteral';span: Span;value: string;} -export type Program = {span: Span;source_type: SourceType;hashbang: (Hashbang) | null;directives: Array;body: Array;scope_id: (ScopeId) | null;} +export type Program = {type: 'Program';span: Span;source_type: SourceType;hashbang: (Hashbang) | null;directives: Array;body: Array;} export type Expression = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type IdentifierName = {span: Span;name: Atom;} +export type IdentifierName = {type: 'Identifier';span: Span;name: string;} -export type IdentifierReference = {span: Span;name: Atom;reference_id: (ReferenceId) | null;} +export type IdentifierReference = {type: 'Identifier';span: Span;name: string;} -export type BindingIdentifier = {span: Span;name: Atom;symbol_id: (SymbolId) | null;} +export type BindingIdentifier = {type: 'Identifier';span: Span;name: string;} -export type LabelIdentifier = {span: Span;name: Atom;} +export type LabelIdentifier = {type: 'Identifier';span: Span;name: string;} -export type ThisExpression = {span: Span;} +export type ThisExpression = {type: 'ThisExpression';span: Span;} -export type ArrayExpression = {span: Span;elements: Array;trailing_comma: (Span) | null;} +export type ArrayExpression = {type: 'ArrayExpression';span: Span;elements: Array;} export type ArrayExpressionElement = SpreadElement | Elision | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type Elision = {span: Span;} +export type Elision = {type: 'Elision';span: Span;} -export type ObjectExpression = {span: Span;properties: Array;trailing_comma: (Span) | null;} +export type ObjectExpression = {type: 'ObjectExpression';span: Span;properties: Array;} export type ObjectPropertyKind = ObjectProperty | SpreadProperty -export type ObjectProperty = {span: Span;kind: PropertyKind;key: PropertyKey;value: Expression;init: (Expression) | null;method: bool;shorthand: bool;computed: bool;} +export type ObjectProperty = {type: 'ObjectProperty';span: Span;kind: PropertyKind;key: PropertyKey;value: Expression;init: (Expression) | null;method: boolean;shorthand: boolean;computed: boolean;} export type PropertyKey = StaticIdentifier | PrivateIdentifier | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type PropertyKind = 'Init' | 'Get' | 'Set' +export type PropertyKind = 'init' | 'get' | 'set' -export type TemplateLiteral = {span: Span;quasis: Array;expressions: Array;} +export type TemplateLiteral = {type: 'TemplateLiteral';span: Span;quasis: Array;expressions: Array;} -export type TaggedTemplateExpression = {span: Span;tag: Expression;quasi: TemplateLiteral;type_parameters: (TSTypeParameterInstantiation) | null;} +export type TaggedTemplateExpression = {type: 'TaggedTemplateExpression';span: Span;tag: Expression;quasi: TemplateLiteral;type_parameters: (TSTypeParameterInstantiation) | null;} -export type TemplateElement = {span: Span;tail: bool;value: TemplateElementValue;} +export type TemplateElement = {type: 'TemplateElement';span: Span;tail: boolean;value: TemplateElementValue;} -export type TemplateElementValue = {raw: Atom;cooked: (Atom) | null;} +export type TemplateElementValue = {raw: string;cooked: (string) | null;} export type MemberExpression = ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type ComputedMemberExpression = {span: Span;object: Expression;expression: Expression;optional: bool;} +export type ComputedMemberExpression = {type: 'ComputedMemberExpression';span: Span;object: Expression;expression: Expression;optional: boolean;} -export type StaticMemberExpression = {span: Span;object: Expression;property: IdentifierName;optional: bool;} +export type StaticMemberExpression = {type: 'StaticMemberExpression';span: Span;object: Expression;property: Identifier;optional: boolean;} -export type PrivateFieldExpression = {span: Span;object: Expression;field: PrivateIdentifier;optional: bool;} +export type PrivateFieldExpression = {type: 'PrivateFieldExpression';span: Span;object: Expression;field: PrivateIdentifier;optional: boolean;} -export type CallExpression = {span: Span;callee: Expression;type_parameters: (TSTypeParameterInstantiation) | null;arguments: Array;optional: bool;} +export type CallExpression = {type: 'CallExpression';span: Span;callee: Expression;type_parameters: (TSTypeParameterInstantiation) | null;arguments: Array;optional: boolean;} -export type NewExpression = {span: Span;callee: Expression;arguments: Array;type_parameters: (TSTypeParameterInstantiation) | null;} +export type NewExpression = {type: 'NewExpression';span: Span;callee: Expression;arguments: Array;type_parameters: (TSTypeParameterInstantiation) | null;} -export type MetaProperty = {span: Span;meta: IdentifierName;property: IdentifierName;} +export type MetaProperty = {type: 'MetaProperty';span: Span;meta: Identifier;property: Identifier;} -export type SpreadElement = {span: Span;argument: Expression;} +export type SpreadElement = {type: 'SpreadElement';span: Span;argument: Expression;} export type Argument = SpreadElement | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type UpdateExpression = {span: Span;operator: UpdateOperator;prefix: bool;argument: SimpleAssignmentTarget;} +export type UpdateExpression = {type: 'UpdateExpression';span: Span;operator: UpdateOperator;prefix: boolean;argument: SimpleAssignmentTarget;} -export type UnaryExpression = {span: Span;operator: UnaryOperator;argument: Expression;} +export type UnaryExpression = {type: 'UnaryExpression';span: Span;operator: UnaryOperator;argument: Expression;} -export type BinaryExpression = {span: Span;left: Expression;operator: BinaryOperator;right: Expression;} +export type BinaryExpression = {type: 'BinaryExpression';span: Span;left: Expression;operator: BinaryOperator;right: Expression;} -export type PrivateInExpression = {span: Span;left: PrivateIdentifier;operator: BinaryOperator;right: Expression;} +export type PrivateInExpression = {type: 'PrivateInExpression';span: Span;left: PrivateIdentifier;operator: BinaryOperator;right: Expression;} -export type LogicalExpression = {span: Span;left: Expression;operator: LogicalOperator;right: Expression;} +export type LogicalExpression = {type: 'LogicalExpression';span: Span;left: Expression;operator: LogicalOperator;right: Expression;} -export type ConditionalExpression = {span: Span;test: Expression;consequent: Expression;alternate: Expression;} +export type ConditionalExpression = {type: 'ConditionalExpression';span: Span;test: Expression;consequent: Expression;alternate: Expression;} -export type AssignmentExpression = {span: Span;operator: AssignmentOperator;left: AssignmentTarget;right: Expression;} +export type AssignmentExpression = {type: 'AssignmentExpression';span: Span;operator: AssignmentOperator;left: AssignmentTarget;right: Expression;} export type AssignmentTarget = AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget @@ -97,481 +95,481 @@ export type SimpleAssignmentTarget = AssignmentTargetIdentifier | TSAsExpression export type AssignmentTargetPattern = ArrayAssignmentTarget | ObjectAssignmentTarget -export type ArrayAssignmentTarget = {span: Span;elements: Array<(AssignmentTargetMaybeDefault) | null>;rest: (AssignmentTargetRest) | null;trailing_comma: (Span) | null;} +export type ArrayAssignmentTarget = {type: 'ArrayAssignmentTarget';span: Span;elements: Array<(AssignmentTargetMaybeDefault) | null>;} -export type ObjectAssignmentTarget = {span: Span;properties: Array;rest: (AssignmentTargetRest) | null;} +export type ObjectAssignmentTarget = {type: 'ObjectAssignmentTarget';span: Span;properties: Array;} -export type AssignmentTargetRest = {span: Span;target: AssignmentTarget;} +export type AssignmentTargetRest = {type: 'RestElement';span: Span;target: AssignmentTarget;} export type AssignmentTargetMaybeDefault = AssignmentTargetWithDefault | AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget -export type AssignmentTargetWithDefault = {span: Span;binding: AssignmentTarget;init: Expression;} +export type AssignmentTargetWithDefault = {type: 'AssignmentTargetWithDefault';span: Span;binding: AssignmentTarget;init: Expression;} export type AssignmentTargetProperty = AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty -export type AssignmentTargetPropertyIdentifier = {span: Span;binding: IdentifierReference;init: (Expression) | null;} +export type AssignmentTargetPropertyIdentifier = {type: 'AssignmentTargetPropertyIdentifier';span: Span;binding: Identifier;init: (Expression) | null;} -export type AssignmentTargetPropertyProperty = {span: Span;name: PropertyKey;binding: AssignmentTargetMaybeDefault;} +export type AssignmentTargetPropertyProperty = {type: 'AssignmentTargetPropertyProperty';span: Span;name: PropertyKey;binding: AssignmentTargetMaybeDefault;} -export type SequenceExpression = {span: Span;expressions: Array;} +export type SequenceExpression = {type: 'SequenceExpression';span: Span;expressions: Array;} -export type Super = {span: Span;} +export type Super = {type: 'Super';span: Span;} -export type AwaitExpression = {span: Span;argument: Expression;} +export type AwaitExpression = {type: 'AwaitExpression';span: Span;argument: Expression;} -export type ChainExpression = {span: Span;expression: ChainElement;} +export type ChainExpression = {type: 'ChainExpression';span: Span;expression: ChainElement;} export type ChainElement = CallExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type ParenthesizedExpression = {span: Span;expression: Expression;} +export type ParenthesizedExpression = {type: 'ParenthesizedExpression';span: Span;expression: Expression;} export type Statement = BlockStatement | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | IfStatement | LabeledStatement | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | WithStatement | VariableDeclaration | FunctionDeclaration | ClassDeclaration | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration | ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration -export type Directive = {span: Span;expression: StringLiteral;directive: Atom;} +export type Directive = {type: 'Directive';span: Span;expression: StringLiteral;directive: string;} -export type Hashbang = {span: Span;value: Atom;} +export type Hashbang = {type: 'Hashbang';span: Span;value: string;} -export type BlockStatement = {span: Span;body: Array;scope_id: (ScopeId) | null;} +export type BlockStatement = {type: 'BlockStatement';span: Span;body: Array;} export type Declaration = VariableDeclaration | FunctionDeclaration | ClassDeclaration | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration -export type VariableDeclaration = {span: Span;kind: VariableDeclarationKind;declarations: Array;declare: bool;} +export type VariableDeclaration = {type: 'VariableDeclaration';span: Span;kind: VariableDeclarationKind;declarations: Array;declare: boolean;} -export type VariableDeclarationKind = 'Var' | 'Const' | 'Let' | 'Using' | 'AwaitUsing' +export type VariableDeclarationKind = 'var' | 'const' | 'let' | 'using' | 'await using' -export type VariableDeclarator = {span: Span;kind: VariableDeclarationKind;id: BindingPattern;init: (Expression) | null;definite: bool;} +export type VariableDeclarator = {type: 'VariableDeclarator';span: Span;id: BindingPattern;init: (Expression) | null;definite: boolean;} -export type EmptyStatement = {span: Span;} +export type EmptyStatement = {type: 'EmptyStatement';span: Span;} -export type ExpressionStatement = {span: Span;expression: Expression;} +export type ExpressionStatement = {type: 'ExpressionStatement';span: Span;expression: Expression;} -export type IfStatement = {span: Span;test: Expression;consequent: Statement;alternate: (Statement) | null;} +export type IfStatement = {type: 'IfStatement';span: Span;test: Expression;consequent: Statement;alternate: (Statement) | null;} -export type DoWhileStatement = {span: Span;body: Statement;test: Expression;} +export type DoWhileStatement = {type: 'DoWhileStatement';span: Span;body: Statement;test: Expression;} -export type WhileStatement = {span: Span;test: Expression;body: Statement;} +export type WhileStatement = {type: 'WhileStatement';span: Span;test: Expression;body: Statement;} -export type ForStatement = {span: Span;init: (ForStatementInit) | null;test: (Expression) | null;update: (Expression) | null;body: Statement;scope_id: (ScopeId) | null;} +export type ForStatement = {type: 'ForStatement';span: Span;init: (ForStatementInit) | null;test: (Expression) | null;update: (Expression) | null;body: Statement;} export type ForStatementInit = VariableDeclaration | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type ForInStatement = {span: Span;left: ForStatementLeft;right: Expression;body: Statement;scope_id: (ScopeId) | null;} +export type ForInStatement = {type: 'ForInStatement';span: Span;left: ForStatementLeft;right: Expression;body: Statement;} export type ForStatementLeft = VariableDeclaration | AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget -export type ForOfStatement = {span: Span;await: bool;left: ForStatementLeft;right: Expression;body: Statement;scope_id: (ScopeId) | null;} +export type ForOfStatement = {type: 'ForOfStatement';span: Span;await: boolean;left: ForStatementLeft;right: Expression;body: Statement;} -export type ContinueStatement = {span: Span;label: (LabelIdentifier) | null;} +export type ContinueStatement = {type: 'ContinueStatement';span: Span;label: (Identifier) | null;} -export type BreakStatement = {span: Span;label: (LabelIdentifier) | null;} +export type BreakStatement = {type: 'BreakStatement';span: Span;label: (Identifier) | null;} -export type ReturnStatement = {span: Span;argument: (Expression) | null;} +export type ReturnStatement = {type: 'ReturnStatement';span: Span;argument: (Expression) | null;} -export type WithStatement = {span: Span;object: Expression;body: Statement;} +export type WithStatement = {type: 'WithStatement';span: Span;object: Expression;body: Statement;} -export type SwitchStatement = {span: Span;discriminant: Expression;cases: Array;scope_id: (ScopeId) | null;} +export type SwitchStatement = {type: 'SwitchStatement';span: Span;discriminant: Expression;cases: Array;} -export type SwitchCase = {span: Span;test: (Expression) | null;consequent: Array;} +export type SwitchCase = {type: 'SwitchCase';span: Span;test: (Expression) | null;consequent: Array;} -export type LabeledStatement = {span: Span;label: LabelIdentifier;body: Statement;} +export type LabeledStatement = {type: 'LabeledStatement';span: Span;label: Identifier;body: Statement;} -export type ThrowStatement = {span: Span;argument: Expression;} +export type ThrowStatement = {type: 'ThrowStatement';span: Span;argument: Expression;} -export type TryStatement = {span: Span;block: BlockStatement;handler: (CatchClause) | null;finalizer: (BlockStatement) | null;} +export type TryStatement = {type: 'TryStatement';span: Span;block: BlockStatement;handler: (CatchClause) | null;finalizer: (BlockStatement) | null;} -export type CatchClause = {span: Span;param: (CatchParameter) | null;body: BlockStatement;scope_id: (ScopeId) | null;} +export type CatchClause = {type: 'CatchClause';span: Span;param: (CatchParameter) | null;body: BlockStatement;} -export type CatchParameter = {span: Span;pattern: BindingPattern;} +export type CatchParameter = {type: 'CatchParameter';span: Span;pattern: BindingPattern;} -export type DebuggerStatement = {span: Span;} +export type DebuggerStatement = {type: 'DebuggerStatement';span: Span;} -export type BindingPattern = {kind: BindingPatternKind;type_annotation: (TSTypeAnnotation) | null;optional: bool;} +export type BindingPattern = {kind: BindingPatternKind;type_annotation: (TSTypeAnnotation) | null;optional: boolean;} -export type BindingPatternKind = BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern +export type BindingPatternKind = Identifier | ObjectPattern | ArrayPattern | AssignmentPattern -export type AssignmentPattern = {span: Span;left: BindingPattern;right: Expression;} +export type AssignmentPattern = {type: 'AssignmentPattern';span: Span;left: BindingPattern;right: Expression;} -export type ObjectPattern = {span: Span;properties: Array;rest: (BindingRestElement) | null;} +export type ObjectPattern = {type: 'ObjectPattern';span: Span;properties: Array;} -export type BindingProperty = {span: Span;key: PropertyKey;value: BindingPattern;shorthand: bool;computed: bool;} +export type BindingProperty = {type: 'BindingProperty';span: Span;key: PropertyKey;value: BindingPattern;shorthand: boolean;computed: boolean;} -export type ArrayPattern = {span: Span;elements: Array<(BindingPattern) | null>;rest: (BindingRestElement) | null;} +export type ArrayPattern = {type: 'ArrayPattern';span: Span;elements: Array<(BindingPattern) | null>;} -export type BindingRestElement = {span: Span;argument: BindingPattern;} +export type BindingRestElement = {type: 'RestElement';span: Span;argument: BindingPattern;} -export type Function = {type: FunctionType;span: Span;id: (BindingIdentifier) | null;generator: bool;async: bool;declare: bool;type_parameters: (TSTypeParameterDeclaration) | null;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;body: (FunctionBody) | null;scope_id: (ScopeId) | null;} +export type Function = {type: FunctionType;span: Span;id: (Identifier) | null;generator: boolean;async: boolean;declare: boolean;type_parameters: (TSTypeParameterDeclaration) | null;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;body: (FunctionBody) | null;} export type FunctionType = 'FunctionDeclaration' | 'FunctionExpression' | 'TSDeclareFunction' | 'TSEmptyBodyFunctionExpression' -export type FormalParameters = {span: Span;kind: FormalParameterKind;items: Array;rest: (BindingRestElement) | null;} +export type FormalParameters = {type: 'FormalParameters';span: Span;kind: FormalParameterKind;items: Array;} -export type FormalParameter = {span: Span;decorators: Array;pattern: BindingPattern;accessibility: (TSAccessibility) | null;readonly: bool;override: bool;} +export type FormalParameter = {type: 'FormalParameter';span: Span;decorators: Array;pattern: BindingPattern;accessibility: (TSAccessibility) | null;readonly: boolean;override: boolean;} export type FormalParameterKind = 'FormalParameter' | 'UniqueFormalParameters' | 'ArrowFormalParameters' | 'Signature' -export type FunctionBody = {span: Span;directives: Array;statements: Array;} +export type FunctionBody = {type: 'FunctionBody';span: Span;directives: Array;statements: Array;} -export type ArrowFunctionExpression = {span: Span;expression: bool;async: bool;type_parameters: (TSTypeParameterDeclaration) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;body: FunctionBody;scope_id: (ScopeId) | null;} +export type ArrowFunctionExpression = {type: 'ArrowFunctionExpression';span: Span;expression: boolean;async: boolean;type_parameters: (TSTypeParameterDeclaration) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;body: FunctionBody;} -export type YieldExpression = {span: Span;delegate: bool;argument: (Expression) | null;} +export type YieldExpression = {type: 'YieldExpression';span: Span;delegate: boolean;argument: (Expression) | null;} -export type Class = {type: ClassType;span: Span;decorators: Array;id: (BindingIdentifier) | null;type_parameters: (TSTypeParameterDeclaration) | null;super_class: (Expression) | null;super_type_parameters: (TSTypeParameterInstantiation) | null;implements: (Array) | null;body: ClassBody;abstract: bool;declare: bool;scope_id: (ScopeId) | null;} +export type Class = {type: ClassType;span: Span;decorators: Array;id: (Identifier) | null;type_parameters: (TSTypeParameterDeclaration) | null;super_class: (Expression) | null;super_type_parameters: (TSTypeParameterInstantiation) | null;implements: (Array) | null;body: ClassBody;abstract: boolean;declare: boolean;} export type ClassType = 'ClassDeclaration' | 'ClassExpression' -export type ClassBody = {span: Span;body: Array;} +export type ClassBody = {type: 'ClassBody';span: Span;body: Array;} export type ClassElement = StaticBlock | MethodDefinition | PropertyDefinition | AccessorProperty | TSIndexSignature -export type MethodDefinition = {type: MethodDefinitionType;span: Span;decorators: Array;key: PropertyKey;value: Function;kind: MethodDefinitionKind;computed: bool;static: bool;override: bool;optional: bool;accessibility: (TSAccessibility) | null;} +export type MethodDefinition = {type: MethodDefinitionType;span: Span;decorators: Array;key: PropertyKey;value: Function;kind: MethodDefinitionKind;computed: boolean;static: boolean;override: boolean;optional: boolean;accessibility: (TSAccessibility) | null;} export type MethodDefinitionType = 'MethodDefinition' | 'TSAbstractMethodDefinition' -export type PropertyDefinition = {type: PropertyDefinitionType;span: Span;decorators: Array;key: PropertyKey;value: (Expression) | null;computed: bool;static: bool;declare: bool;override: bool;optional: bool;definite: bool;readonly: bool;type_annotation: (TSTypeAnnotation) | null;accessibility: (TSAccessibility) | null;} +export type PropertyDefinition = {type: PropertyDefinitionType;span: Span;decorators: Array;key: PropertyKey;value: (Expression) | null;computed: boolean;static: boolean;declare: boolean;override: boolean;optional: boolean;definite: boolean;readonly: boolean;type_annotation: (TSTypeAnnotation) | null;accessibility: (TSAccessibility) | null;} export type PropertyDefinitionType = 'PropertyDefinition' | 'TSAbstractPropertyDefinition' -export type MethodDefinitionKind = 'Constructor' | 'Method' | 'Get' | 'Set' +export type MethodDefinitionKind = 'constructor' | 'method' | 'get' | 'set' -export type PrivateIdentifier = {span: Span;name: Atom;} +export type PrivateIdentifier = {type: 'PrivateIdentifier';span: Span;name: string;} -export type StaticBlock = {span: Span;body: Array;scope_id: (ScopeId) | null;} +export type StaticBlock = {type: 'StaticBlock';span: Span;body: Array;} export type ModuleDeclaration = ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration export type AccessorPropertyType = 'AccessorProperty' | 'TSAbstractAccessorProperty' -export type AccessorProperty = {type: AccessorPropertyType;span: Span;decorators: Array;key: PropertyKey;value: (Expression) | null;computed: bool;static: bool;definite: bool;type_annotation: (TSTypeAnnotation) | null;accessibility: (TSAccessibility) | null;} +export type AccessorProperty = {type: AccessorPropertyType;span: Span;decorators: Array;key: PropertyKey;value: (Expression) | null;computed: boolean;static: boolean;definite: boolean;type_annotation: (TSTypeAnnotation) | null;accessibility: (TSAccessibility) | null;} -export type ImportExpression = {span: Span;source: Expression;arguments: Array;} +export type ImportExpression = {type: 'ImportExpression';span: Span;source: Expression;arguments: Array;} -export type ImportDeclaration = {span: Span;specifiers: (Array) | null;source: StringLiteral;with_clause: (WithClause) | null;import_kind: ImportOrExportKind;} +export type ImportDeclaration = {type: 'ImportDeclaration';span: Span;specifiers: (Array) | null;source: StringLiteral;with_clause: (WithClause) | null;import_kind: ImportOrExportKind;} export type ImportDeclarationSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier -export type ImportSpecifier = {span: Span;imported: ModuleExportName;local: BindingIdentifier;import_kind: ImportOrExportKind;} +export type ImportSpecifier = {type: 'ImportSpecifier';span: Span;imported: ModuleExportName;local: Identifier;import_kind: ImportOrExportKind;} -export type ImportDefaultSpecifier = {span: Span;local: BindingIdentifier;} +export type ImportDefaultSpecifier = {type: 'ImportDefaultSpecifier';span: Span;local: Identifier;} -export type ImportNamespaceSpecifier = {span: Span;local: BindingIdentifier;} +export type ImportNamespaceSpecifier = {type: 'ImportNamespaceSpecifier';span: Span;local: Identifier;} -export type WithClause = {span: Span;attributes_keyword: IdentifierName;with_entries: Array;} +export type WithClause = {type: 'WithClause';span: Span;attributes_keyword: Identifier;with_entries: Array;} -export type ImportAttribute = {span: Span;key: ImportAttributeKey;value: StringLiteral;} +export type ImportAttribute = {type: 'ImportAttribute';span: Span;key: ImportAttributeKey;value: StringLiteral;} export type ImportAttributeKey = Identifier | StringLiteral -export type ExportNamedDeclaration = {span: Span;declaration: (Declaration) | null;specifiers: Array;source: (StringLiteral) | null;export_kind: ImportOrExportKind;with_clause: (WithClause) | null;} +export type ExportNamedDeclaration = {type: 'ExportNamedDeclaration';span: Span;declaration: (Declaration) | null;specifiers: Array;source: (StringLiteral) | null;export_kind: ImportOrExportKind;with_clause: (WithClause) | null;} -export type ExportDefaultDeclaration = {span: Span;declaration: ExportDefaultDeclarationKind;exported: ModuleExportName;} +export type ExportDefaultDeclaration = {type: 'ExportDefaultDeclaration';span: Span;declaration: ExportDefaultDeclarationKind;exported: ModuleExportName;} -export type ExportAllDeclaration = {span: Span;exported: (ModuleExportName) | null;source: StringLiteral;with_clause: (WithClause) | null;export_kind: ImportOrExportKind;} +export type ExportAllDeclaration = {type: 'ExportAllDeclaration';span: Span;exported: (ModuleExportName) | null;source: StringLiteral;with_clause: (WithClause) | null;export_kind: ImportOrExportKind;} -export type ExportSpecifier = {span: Span;local: ModuleExportName;exported: ModuleExportName;export_kind: ImportOrExportKind;} +export type ExportSpecifier = {type: 'ExportSpecifier';span: Span;local: ModuleExportName;exported: ModuleExportName;export_kind: ImportOrExportKind;} export type ExportDefaultDeclarationKind = FunctionDeclaration | ClassDeclaration | TSInterfaceDeclaration | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type ModuleExportName = IdentifierName | IdentifierReference | StringLiteral +export type ModuleExportName = Identifier | Identifier | StringLiteral -export type TSThisParameter = {span: Span;this_span: Span;type_annotation: (TSTypeAnnotation) | null;} +export type TSThisParameter = {type: 'TSThisParameter';span: Span;this_span: Span;type_annotation: (TSTypeAnnotation) | null;} -export type TSEnumDeclaration = {span: Span;id: BindingIdentifier;members: Array;const: bool;declare: bool;scope_id: (ScopeId) | null;} +export type TSEnumDeclaration = {type: 'TSEnumDeclaration';span: Span;id: Identifier;members: Array;const: boolean;declare: boolean;} -export type TSEnumMember = {span: Span;id: TSEnumMemberName;initializer: (Expression) | null;} +export type TSEnumMember = {type: 'TSEnumMember';span: Span;id: TSEnumMemberName;initializer: (Expression) | null;} export type TSEnumMemberName = StaticIdentifier | StaticStringLiteral | StaticTemplateLiteral | StaticNumericLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type TSTypeAnnotation = {span: Span;type_annotation: TSType;} +export type TSTypeAnnotation = {type: 'TSTypeAnnotation';span: Span;type_annotation: TSType;} -export type TSLiteralType = {span: Span;literal: TSLiteral;} +export type TSLiteralType = {type: 'TSLiteralType';span: Span;literal: TSLiteral;} export type TSLiteral = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | UnaryExpression export type TSType = TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSNamedTupleMember | TSQualifiedName | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperatorType | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TSParenthesizedType | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType -export type TSConditionalType = {span: Span;check_type: TSType;extends_type: TSType;true_type: TSType;false_type: TSType;scope_id: (ScopeId) | null;} +export type TSConditionalType = {type: 'TSConditionalType';span: Span;check_type: TSType;extends_type: TSType;true_type: TSType;false_type: TSType;} -export type TSUnionType = {span: Span;types: Array;} +export type TSUnionType = {type: 'TSUnionType';span: Span;types: Array;} -export type TSIntersectionType = {span: Span;types: Array;} +export type TSIntersectionType = {type: 'TSIntersectionType';span: Span;types: Array;} -export type TSParenthesizedType = {span: Span;type_annotation: TSType;} +export type TSParenthesizedType = {type: 'TSParenthesizedType';span: Span;type_annotation: TSType;} -export type TSTypeOperator = {span: Span;operator: TSTypeOperatorOperator;type_annotation: TSType;} +export type TSTypeOperator = {type: 'TSTypeOperator';span: Span;operator: TSTypeOperatorOperator;type_annotation: TSType;} -export type TSTypeOperatorOperator = 'Keyof' | 'Unique' | 'Readonly' +export type TSTypeOperatorOperator = 'keyof' | 'unique' | 'readonly' -export type TSArrayType = {span: Span;element_type: TSType;} +export type TSArrayType = {type: 'TSArrayType';span: Span;element_type: TSType;} -export type TSIndexedAccessType = {span: Span;object_type: TSType;index_type: TSType;} +export type TSIndexedAccessType = {type: 'TSIndexedAccessType';span: Span;object_type: TSType;index_type: TSType;} -export type TSTupleType = {span: Span;element_types: Array;} +export type TSTupleType = {type: 'TSTupleType';span: Span;element_types: Array;} -export type TSNamedTupleMember = {span: Span;element_type: TSTupleElement;label: IdentifierName;optional: bool;} +export type TSNamedTupleMember = {type: 'TSNamedTupleMember';span: Span;element_type: TSTupleElement;label: Identifier;optional: boolean;} -export type TSOptionalType = {span: Span;type_annotation: TSType;} +export type TSOptionalType = {type: 'TSOptionalType';span: Span;type_annotation: TSType;} -export type TSRestType = {span: Span;type_annotation: TSType;} +export type TSRestType = {type: 'TSRestType';span: Span;type_annotation: TSType;} export type TSTupleElement = TSOptionalType | TSRestType | TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSNamedTupleMember | TSQualifiedName | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperatorType | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TSParenthesizedType | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType -export type TSAnyKeyword = {span: Span;} +export type TSAnyKeyword = {type: 'TSAnyKeyword';span: Span;} -export type TSStringKeyword = {span: Span;} +export type TSStringKeyword = {type: 'TSStringKeyword';span: Span;} -export type TSBooleanKeyword = {span: Span;} +export type TSBooleanKeyword = {type: 'TSBooleanKeyword';span: Span;} -export type TSNumberKeyword = {span: Span;} +export type TSNumberKeyword = {type: 'TSNumberKeyword';span: Span;} -export type TSNeverKeyword = {span: Span;} +export type TSNeverKeyword = {type: 'TSNeverKeyword';span: Span;} -export type TSIntrinsicKeyword = {span: Span;} +export type TSIntrinsicKeyword = {type: 'TSIntrinsicKeyword';span: Span;} -export type TSUnknownKeyword = {span: Span;} +export type TSUnknownKeyword = {type: 'TSUnknownKeyword';span: Span;} -export type TSNullKeyword = {span: Span;} +export type TSNullKeyword = {type: 'TSNullKeyword';span: Span;} -export type TSUndefinedKeyword = {span: Span;} +export type TSUndefinedKeyword = {type: 'TSUndefinedKeyword';span: Span;} -export type TSVoidKeyword = {span: Span;} +export type TSVoidKeyword = {type: 'TSVoidKeyword';span: Span;} -export type TSSymbolKeyword = {span: Span;} +export type TSSymbolKeyword = {type: 'TSSymbolKeyword';span: Span;} -export type TSThisType = {span: Span;} +export type TSThisType = {type: 'TSThisType';span: Span;} -export type TSObjectKeyword = {span: Span;} +export type TSObjectKeyword = {type: 'TSObjectKeyword';span: Span;} -export type TSBigIntKeyword = {span: Span;} +export type TSBigIntKeyword = {type: 'TSBigIntKeyword';span: Span;} -export type TSTypeReference = {span: Span;type_name: TSTypeName;type_parameters: (TSTypeParameterInstantiation) | null;} +export type TSTypeReference = {type: 'TSTypeReference';span: Span;type_name: TSTypeName;type_parameters: (TSTypeParameterInstantiation) | null;} -export type TSTypeName = IdentifierReference | QualifiedName +export type TSTypeName = Identifier | QualifiedName -export type TSQualifiedName = {span: Span;left: TSTypeName;right: IdentifierName;} +export type TSQualifiedName = {type: 'TSQualifiedName';span: Span;left: TSTypeName;right: Identifier;} -export type TSTypeParameterInstantiation = {span: Span;params: Array;} +export type TSTypeParameterInstantiation = {type: 'TSTypeParameterInstantiation';span: Span;params: Array;} -export type TSTypeParameter = {span: Span;name: BindingIdentifier;constraint: (TSType) | null;default: (TSType) | null;in: bool;out: bool;const: bool;} +export type TSTypeParameter = {type: 'TSTypeParameter';span: Span;name: Identifier;constraint: (TSType) | null;default: (TSType) | null;in: boolean;out: boolean;const: boolean;} -export type TSTypeParameterDeclaration = {span: Span;params: Array;} +export type TSTypeParameterDeclaration = {type: 'TSTypeParameterDeclaration';span: Span;params: Array;} -export type TSTypeAliasDeclaration = {span: Span;id: BindingIdentifier;type_parameters: (TSTypeParameterDeclaration) | null;type_annotation: TSType;declare: bool;scope_id: (ScopeId) | null;} +export type TSTypeAliasDeclaration = {type: 'TSTypeAliasDeclaration';span: Span;id: Identifier;type_parameters: (TSTypeParameterDeclaration) | null;type_annotation: TSType;declare: boolean;} -export type TSAccessibility = 'Private' | 'Protected' | 'Public' +export type TSAccessibility = 'private' | 'protected' | 'public' -export type TSClassImplements = {span: Span;expression: TSTypeName;type_parameters: (TSTypeParameterInstantiation) | null;} +export type TSClassImplements = {type: 'TSClassImplements';span: Span;expression: TSTypeName;type_parameters: (TSTypeParameterInstantiation) | null;} -export type TSInterfaceDeclaration = {span: Span;id: BindingIdentifier;extends: (Array) | null;type_parameters: (TSTypeParameterDeclaration) | null;body: TSInterfaceBody;declare: bool;scope_id: (ScopeId) | null;} +export type TSInterfaceDeclaration = {type: 'TSInterfaceDeclaration';span: Span;id: Identifier;extends: (Array) | null;type_parameters: (TSTypeParameterDeclaration) | null;body: TSInterfaceBody;declare: boolean;} -export type TSInterfaceBody = {span: Span;body: Array;} +export type TSInterfaceBody = {type: 'TSInterfaceBody';span: Span;body: Array;} -export type TSPropertySignature = {span: Span;computed: bool;optional: bool;readonly: bool;key: PropertyKey;type_annotation: (TSTypeAnnotation) | null;} +export type TSPropertySignature = {type: 'TSPropertySignature';span: Span;computed: boolean;optional: boolean;readonly: boolean;key: PropertyKey;type_annotation: (TSTypeAnnotation) | null;} export type TSSignature = TSIndexSignature | TSPropertySignature | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSMethodSignature -export type TSIndexSignature = {span: Span;parameters: Array;type_annotation: TSTypeAnnotation;readonly: bool;} +export type TSIndexSignature = {type: 'TSIndexSignature';span: Span;parameters: Array;type_annotation: TSTypeAnnotation;readonly: boolean;} -export type TSCallSignatureDeclaration = {span: Span;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;} +export type TSCallSignatureDeclaration = {type: 'TSCallSignatureDeclaration';span: Span;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;} -export type TSMethodSignatureKind = 'Method' | 'Get' | 'Set' +export type TSMethodSignatureKind = 'method' | 'get' | 'set' -export type TSMethodSignature = {span: Span;key: PropertyKey;computed: bool;optional: bool;kind: TSMethodSignatureKind;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;scope_id: (ScopeId) | null;} +export type TSMethodSignature = {type: 'TSMethodSignature';span: Span;key: PropertyKey;computed: boolean;optional: boolean;kind: TSMethodSignatureKind;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;} -export type TSConstructSignatureDeclaration = {span: Span;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;scope_id: (ScopeId) | null;} +export type TSConstructSignatureDeclaration = {type: 'TSConstructSignatureDeclaration';span: Span;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;} -export type TSIndexSignatureName = {span: Span;name: Atom;type_annotation: TSTypeAnnotation;} +export type TSIndexSignatureName = {type: 'Identifier';span: Span;name: string;type_annotation: TSTypeAnnotation;} -export type TSInterfaceHeritage = {span: Span;expression: Expression;type_parameters: (TSTypeParameterInstantiation) | null;} +export type TSInterfaceHeritage = {type: 'TSInterfaceHeritage';span: Span;expression: Expression;type_parameters: (TSTypeParameterInstantiation) | null;} -export type TSTypePredicate = {span: Span;parameter_name: TSTypePredicateName;asserts: bool;type_annotation: (TSTypeAnnotation) | null;} +export type TSTypePredicate = {type: 'TSTypePredicate';span: Span;parameter_name: TSTypePredicateName;asserts: boolean;type_annotation: (TSTypeAnnotation) | null;} export type TSTypePredicateName = Identifier | This -export type TSModuleDeclaration = {span: Span;id: TSModuleDeclarationName;body: (TSModuleDeclarationBody) | null;kind: TSModuleDeclarationKind;declare: bool;scope_id: (ScopeId) | null;} +export type TSModuleDeclaration = {type: 'TSModuleDeclaration';span: Span;id: TSModuleDeclarationName;body: (TSModuleDeclarationBody) | null;kind: TSModuleDeclarationKind;declare: boolean;} -export type TSModuleDeclarationKind = 'Global' | 'Module' | 'Namespace' +export type TSModuleDeclarationKind = 'global' | 'module' | 'namespace' export type TSModuleDeclarationName = Identifier | StringLiteral export type TSModuleDeclarationBody = TSModuleDeclaration | TSModuleBlock -export type TSModuleBlock = {span: Span;directives: Array;body: Array;} +export type TSModuleBlock = {type: 'TSModuleBlock';span: Span;body: Array;} -export type TSTypeLiteral = {span: Span;members: Array;} +export type TSTypeLiteral = {type: 'TSTypeLiteral';span: Span;members: Array;} -export type TSInferType = {span: Span;type_parameter: TSTypeParameter;} +export type TSInferType = {type: 'TSInferType';span: Span;type_parameter: TSTypeParameter;} -export type TSTypeQuery = {span: Span;expr_name: TSTypeQueryExprName;type_parameters: (TSTypeParameterInstantiation) | null;} +export type TSTypeQuery = {type: 'TSTypeQuery';span: Span;expr_name: TSTypeQueryExprName;type_parameters: (TSTypeParameterInstantiation) | null;} -export type TSTypeQueryExprName = TSImportType | IdentifierReference | QualifiedName +export type TSTypeQueryExprName = TSImportType | Identifier | QualifiedName -export type TSImportType = {span: Span;is_type_of: bool;parameter: TSType;qualifier: (TSTypeName) | null;attributes: (TSImportAttributes) | null;type_parameters: (TSTypeParameterInstantiation) | null;} +export type TSImportType = {type: 'TSImportType';span: Span;is_type_of: boolean;parameter: TSType;qualifier: (TSTypeName) | null;attributes: (TSImportAttributes) | null;type_parameters: (TSTypeParameterInstantiation) | null;} -export type TSImportAttributes = {span: Span;attributes_keyword: IdentifierName;elements: Array;} +export type TSImportAttributes = {type: 'TSImportAttributes';span: Span;attributes_keyword: Identifier;elements: Array;} -export type TSImportAttribute = {span: Span;name: TSImportAttributeName;value: Expression;} +export type TSImportAttribute = {type: 'TSImportAttribute';span: Span;name: TSImportAttributeName;value: Expression;} export type TSImportAttributeName = Identifier | StringLiteral -export type TSFunctionType = {span: Span;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: TSTypeAnnotation;type_parameters: (TSTypeParameterDeclaration) | null;} +export type TSFunctionType = {type: 'TSFunctionType';span: Span;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: TSTypeAnnotation;type_parameters: (TSTypeParameterDeclaration) | null;} -export type TSConstructorType = {span: Span;abstract: bool;params: FormalParameters;return_type: TSTypeAnnotation;type_parameters: (TSTypeParameterDeclaration) | null;} +export type TSConstructorType = {type: 'TSConstructorType';span: Span;abstract: boolean;params: FormalParameters;return_type: TSTypeAnnotation;type_parameters: (TSTypeParameterDeclaration) | null;} -export type TSMappedType = {span: Span;type_parameter: TSTypeParameter;name_type: (TSType) | null;type_annotation: (TSType) | null;optional: TSMappedTypeModifierOperator;readonly: TSMappedTypeModifierOperator;scope_id: (ScopeId) | null;} +export type TSMappedType = {type: 'TSMappedType';span: Span;type_parameter: TSTypeParameter;name_type: (TSType) | null;type_annotation: (TSType) | null;optional: TSMappedTypeModifierOperator;readonly: TSMappedTypeModifierOperator;} -export type TSMappedTypeModifierOperator = 'True' | 'Plus' | 'Minus' | 'None' +export type TSMappedTypeModifierOperator = 'true' | '+' | '-' | 'none' -export type TSTemplateLiteralType = {span: Span;quasis: Array;types: Array;} +export type TSTemplateLiteralType = {type: 'TSTemplateLiteralType';span: Span;quasis: Array;types: Array;} -export type TSAsExpression = {span: Span;expression: Expression;type_annotation: TSType;} +export type TSAsExpression = {type: 'TSAsExpression';span: Span;expression: Expression;type_annotation: TSType;} -export type TSSatisfiesExpression = {span: Span;expression: Expression;type_annotation: TSType;} +export type TSSatisfiesExpression = {type: 'TSSatisfiesExpression';span: Span;expression: Expression;type_annotation: TSType;} -export type TSTypeAssertion = {span: Span;expression: Expression;type_annotation: TSType;} +export type TSTypeAssertion = {type: 'TSTypeAssertion';span: Span;expression: Expression;type_annotation: TSType;} -export type TSImportEqualsDeclaration = {span: Span;id: BindingIdentifier;module_reference: TSModuleReference;import_kind: ImportOrExportKind;} +export type TSImportEqualsDeclaration = {type: 'TSImportEqualsDeclaration';span: Span;id: Identifier;module_reference: TSModuleReference;import_kind: ImportOrExportKind;} -export type TSModuleReference = ExternalModuleReference | IdentifierReference | QualifiedName +export type TSModuleReference = ExternalModuleReference | Identifier | QualifiedName -export type TSExternalModuleReference = {span: Span;expression: StringLiteral;} +export type TSExternalModuleReference = {type: 'TSExternalModuleReference';span: Span;expression: StringLiteral;} -export type TSNonNullExpression = {span: Span;expression: Expression;} +export type TSNonNullExpression = {type: 'TSNonNullExpression';span: Span;expression: Expression;} -export type Decorator = {span: Span;expression: Expression;} +export type Decorator = {type: 'Decorator';span: Span;expression: Expression;} -export type TSExportAssignment = {span: Span;expression: Expression;} +export type TSExportAssignment = {type: 'TSExportAssignment';span: Span;expression: Expression;} -export type TSNamespaceExportDeclaration = {span: Span;id: IdentifierName;} +export type TSNamespaceExportDeclaration = {type: 'TSNamespaceExportDeclaration';span: Span;id: Identifier;} -export type TSInstantiationExpression = {span: Span;expression: Expression;type_parameters: TSTypeParameterInstantiation;} +export type TSInstantiationExpression = {type: 'TSInstantiationExpression';span: Span;expression: Expression;type_parameters: TSTypeParameterInstantiation;} -export type ImportOrExportKind = 'Value' | 'Type' +export type ImportOrExportKind = 'value' | 'type' -export type JSDocNullableType = {span: Span;type_annotation: TSType;postfix: bool;} +export type JSDocNullableType = {type: 'JSDocNullableType';span: Span;type_annotation: TSType;postfix: boolean;} -export type JSDocNonNullableType = {span: Span;type_annotation: TSType;postfix: bool;} +export type JSDocNonNullableType = {type: 'JSDocNonNullableType';span: Span;type_annotation: TSType;postfix: boolean;} -export type JSDocUnknownType = {span: Span;} +export type JSDocUnknownType = {type: 'JSDocUnknownType';span: Span;} -export type JSXElement = {span: Span;opening_element: JSXOpeningElement;closing_element: (JSXClosingElement) | null;children: Array;} +export type JSXElement = {type: 'JSXElement';span: Span;opening_element: JSXOpeningElement;closing_element: (JSXClosingElement) | null;children: Array;} -export type JSXOpeningElement = {span: Span;self_closing: bool;name: JSXElementName;attributes: Array;type_parameters: (TSTypeParameterInstantiation) | null;} +export type JSXOpeningElement = {type: 'JSXOpeningElement';span: Span;self_closing: boolean;name: JSXElementName;attributes: Array;type_parameters: (TSTypeParameterInstantiation) | null;} -export type JSXClosingElement = {span: Span;name: JSXElementName;} +export type JSXClosingElement = {type: 'JSXClosingElement';span: Span;name: JSXElementName;} -export type JSXFragment = {span: Span;opening_fragment: JSXOpeningFragment;closing_fragment: JSXClosingFragment;children: Array;} +export type JSXFragment = {type: 'JSXFragment';span: Span;opening_fragment: JSXOpeningFragment;closing_fragment: JSXClosingFragment;children: Array;} -export type JSXOpeningFragment = {span: Span;} +export type JSXOpeningFragment = {type: 'JSXOpeningFragment';span: Span;} -export type JSXClosingFragment = {span: Span;} +export type JSXClosingFragment = {type: 'JSXClosingFragment';span: Span;} -export type JSXElementName = Identifier | IdentifierReference | NamespacedName | MemberExpression | ThisExpression +export type JSXElementName = Identifier | Identifier | NamespacedName | MemberExpression | ThisExpression -export type JSXNamespacedName = {span: Span;namespace: JSXIdentifier;property: JSXIdentifier;} +export type JSXNamespacedName = {type: 'JSXNamespacedName';span: Span;namespace: JSXIdentifier;property: JSXIdentifier;} -export type JSXMemberExpression = {span: Span;object: JSXMemberExpressionObject;property: JSXIdentifier;} +export type JSXMemberExpression = {type: 'JSXMemberExpression';span: Span;object: JSXMemberExpressionObject;property: JSXIdentifier;} -export type JSXMemberExpressionObject = IdentifierReference | MemberExpression | ThisExpression +export type JSXMemberExpressionObject = Identifier | MemberExpression | ThisExpression -export type JSXExpressionContainer = {span: Span;expression: JSXExpression;} +export type JSXExpressionContainer = {type: 'JSXExpressionContainer';span: Span;expression: JSXExpression;} export type JSXExpression = EmptyExpression | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression -export type JSXEmptyExpression = {span: Span;} +export type JSXEmptyExpression = {type: 'JSXEmptyExpression';span: Span;} export type JSXAttributeItem = Attribute | SpreadAttribute -export type JSXAttribute = {span: Span;name: JSXAttributeName;value: (JSXAttributeValue) | null;} +export type JSXAttribute = {type: 'JSXAttribute';span: Span;name: JSXAttributeName;value: (JSXAttributeValue) | null;} -export type JSXSpreadAttribute = {span: Span;argument: Expression;} +export type JSXSpreadAttribute = {type: 'JSXSpreadAttribute';span: Span;argument: Expression;} export type JSXAttributeName = Identifier | NamespacedName export type JSXAttributeValue = StringLiteral | ExpressionContainer | Element | Fragment -export type JSXIdentifier = {span: Span;name: Atom;} +export type JSXIdentifier = {type: 'JSXIdentifier';span: Span;name: string;} export type JSXChild = Text | Element | Fragment | ExpressionContainer | Spread -export type JSXSpreadChild = {span: Span;expression: Expression;} +export type JSXSpreadChild = {type: 'JSXSpreadChild';span: Span;expression: Expression;} -export type JSXText = {span: Span;value: Atom;} +export type JSXText = {type: 'JSXText';span: Span;value: string;} export type NumberBase = 'Float' | 'Decimal' | 'Binary' | 'Octal' | 'Hex' export type BigintBase = 'Decimal' | 'Binary' | 'Octal' | 'Hex' -export type AssignmentOperator = 'Assign' | 'Addition' | 'Subtraction' | 'Multiplication' | 'Division' | 'Remainder' | 'ShiftLeft' | 'ShiftRight' | 'ShiftRightZeroFill' | 'BitwiseOR' | 'BitwiseXOR' | 'BitwiseAnd' | 'LogicalAnd' | 'LogicalOr' | 'LogicalNullish' | 'Exponential' +export type AssignmentOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&=' | '&&=' | '||=' | '??=' | '**=' -export type BinaryOperator = 'Equality' | 'Inequality' | 'StrictEquality' | 'StrictInequality' | 'LessThan' | 'LessEqualThan' | 'GreaterThan' | 'GreaterEqualThan' | 'ShiftLeft' | 'ShiftRight' | 'ShiftRightZeroFill' | 'Addition' | 'Subtraction' | 'Multiplication' | 'Division' | 'Remainder' | 'BitwiseOR' | 'BitwiseXOR' | 'BitwiseAnd' | 'In' | 'Instanceof' | 'Exponential' +export type BinaryOperator = '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '|' | '^' | '&' | 'in' | 'instanceof' | '**' -export type LogicalOperator = 'Or' | 'And' | 'Coalesce' +export type LogicalOperator = '||' | '&&' | '??' -export type UnaryOperator = 'UnaryNegation' | 'UnaryPlus' | 'LogicalNot' | 'BitwiseNot' | 'Typeof' | 'Void' | 'Delete' +export type UnaryOperator = '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete' -export type UpdateOperator = 'Increment' | 'Decrement' +export type UpdateOperator = '++' | '--' -export type Span = {start: u32;end: u32;} +export type Span = {type: 'Span';start: number;end: number;} export type SourceType = {language: Language;module_kind: ModuleKind;variant: LanguageVariant;} -export type Language = 'JavaScript' | 'TypeScript' | 'TypeScriptDefinition' +export type Language = 'javascript' | 'typescript' | 'typescriptDefinition' -export type ModuleKind = 'Script' | 'Module' | 'Unambiguous' +export type ModuleKind = 'script' | 'module' | 'unambiguous' -export type LanguageVariant = 'Standard' | 'Jsx' +export type LanguageVariant = 'standard' | 'jsx' -export type Pattern = {span: Span;body: Disjunction;} +export type Pattern = {type: 'Pattern';span: Span;body: Disjunction;} -export type Disjunction = {span: Span;body: Array;} +export type Disjunction = {type: 'Disjunction';span: Span;body: Array;} -export type Alternative = {span: Span;body: Array;} +export type Alternative = {type: 'Alternative';span: Span;body: Array;} export type Term = BoundaryAssertion | LookAroundAssertion | Quantifier | Character | Dot | CharacterClassEscape | UnicodePropertyEscape | CharacterClass | CapturingGroup | IgnoreGroup | IndexedReference | NamedReference -export type BoundaryAssertion = {span: Span;kind: BoundaryAssertionKind;} +export type BoundaryAssertion = {type: 'BoundaryAssertion';span: Span;kind: BoundaryAssertionKind;} -export type BoundaryAssertionKind = 'Start' | 'End' | 'Boundary' | 'NegativeBoundary' +export type BoundaryAssertionKind = 'start' | 'end' | 'boundary' | 'negativeBoundary' -export type LookAroundAssertion = {span: Span;kind: LookAroundAssertionKind;body: Disjunction;} +export type LookAroundAssertion = {type: 'LookAroundAssertion';span: Span;kind: LookAroundAssertionKind;body: Disjunction;} -export type LookAroundAssertionKind = 'Lookahead' | 'NegativeLookahead' | 'Lookbehind' | 'NegativeLookbehind' +export type LookAroundAssertionKind = 'lookahead' | 'negativeLookahead' | 'lookbehind' | 'negativeLookbehind' -export type Quantifier = {span: Span;min: u64;max: (u64) | null;greedy: bool;body: Term;} +export type Quantifier = {type: 'Quantifier';span: Span;min: number;max: (number) | null;greedy: boolean;body: Term;} -export type Character = {span: Span;kind: CharacterKind;value: u32;} +export type Character = {type: 'Character';span: Span;kind: CharacterKind;value: number;} -export type CharacterKind = 'ControlLetter' | 'HexadecimalEscape' | 'Identifier' | 'Null' | 'Octal1' | 'Octal2' | 'Octal3' | 'SingleEscape' | 'Symbol' | 'UnicodeEscape' +export type CharacterKind = 'controlLetter' | 'hexadecimalEscape' | 'identifier' | 'null' | 'octal1' | 'octal2' | 'octal3' | 'singleEscape' | 'symbol' | 'unicodeEscape' -export type CharacterClassEscape = {span: Span;kind: CharacterClassEscapeKind;} +export type CharacterClassEscape = {type: 'CharacterClassEscape';span: Span;kind: CharacterClassEscapeKind;} -export type CharacterClassEscapeKind = 'D' | 'NegativeD' | 'S' | 'NegativeS' | 'W' | 'NegativeW' +export type CharacterClassEscapeKind = 'd' | 'negativeD' | 's' | 'negativeS' | 'w' | 'negativeW' -export type UnicodePropertyEscape = {span: Span;negative: bool;strings: bool;name: Atom;value: (Atom) | null;} +export type UnicodePropertyEscape = {type: 'UnicodePropertyEscape';span: Span;negative: boolean;strings: boolean;name: string;value: (string) | null;} -export type Dot = {span: Span;} +export type Dot = {type: 'Dot';span: Span;} -export type CharacterClass = {span: Span;negative: bool;strings: bool;kind: CharacterClassContentsKind;body: Array;} +export type CharacterClass = {type: 'CharacterClass';span: Span;negative: boolean;strings: boolean;kind: CharacterClassContentsKind;body: Array;} -export type CharacterClassContentsKind = 'Union' | 'Intersection' | 'Subtraction' +export type CharacterClassContentsKind = 'union' | 'intersection' | 'subtraction' export type CharacterClassContents = CharacterClassRange | CharacterClassEscape | UnicodePropertyEscape | Character | NestedCharacterClass | ClassStringDisjunction -export type CharacterClassRange = {span: Span;min: Character;max: Character;} +export type CharacterClassRange = {type: 'CharacterClassRange';span: Span;min: Character;max: Character;} -export type ClassStringDisjunction = {span: Span;strings: bool;body: Array;} +export type ClassStringDisjunction = {type: 'ClassStringDisjunction';span: Span;strings: boolean;body: Array;} -export type ClassString = {span: Span;strings: bool;body: Array;} +export type ClassString = {type: 'ClassString';span: Span;strings: boolean;body: Array;} -export type CapturingGroup = {span: Span;name: (Atom) | null;body: Disjunction;} +export type CapturingGroup = {type: 'CapturingGroup';span: Span;name: (string) | null;body: Disjunction;} -export type IgnoreGroup = {span: Span;modifiers: (Modifiers) | null;body: Disjunction;} +export type IgnoreGroup = {type: 'IgnoreGroup';span: Span;modifiers: (Modifiers) | null;body: Disjunction;} -export type Modifiers = {span: Span;enabling: (Modifier) | null;disabling: (Modifier) | null;} +export type Modifiers = {type: 'Modifiers';span: Span;enabling: (Modifier) | null;disabling: (Modifier) | null;} -export type Modifier = {ignore_case: bool;multiline: bool;sticky: bool;} +export type Modifier = {type: 'Modifier';ignore_case: boolean;multiline: boolean;sticky: boolean;} -export type IndexedReference = {span: Span;index: u32;} +export type IndexedReference = {type: 'IndexedReference';span: Span;index: number;} -export type NamedReference = {span: Span;name: Atom;} +export type NamedReference = {type: 'NamedReference';span: Span;name: string;} diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index 72ff3a521f41f..345fae8036b5c 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -5,8 +5,10 @@ use quote::quote; use super::{define_derive, Derive, DeriveOutput}; use crate::{ codegen::LateCtx, - markers::ESTreeStructAttribute, - schema::{EnumDef, GetGenerics, GetIdent, TypeDef}, + schema::{ + serialize::{enum_variant_name, get_type_tag}, + EnumDef, GetGenerics, GetIdent, StructDef, TypeDef, + }, }; define_derive! { @@ -59,23 +61,11 @@ impl Derive for DeriveESTree { } } -fn serialize_struct(def: &crate::schema::StructDef) -> TokenStream { +fn serialize_struct(def: &StructDef) -> TokenStream { let ident = def.ident(); // If type_tag is Some, we serialize it manually. If None, either one of // the fields is named r#type, or the struct does not need a "type" field. - let type_tag = match def.markers.estree { - Some(ESTreeStructAttribute::NoType) => None, - Some(ESTreeStructAttribute::Type(ref type_name)) => Some(type_name.clone()), - None => { - let has_type_field = - def.fields.iter().any(|f| matches!(f.name.as_deref(), Some("type"))); - if has_type_field { - None - } else { - Some(ident.to_string()) - } - } - }; + let type_tag = get_type_tag(def); let mut fields = vec![]; if let Some(ref ty) = type_tag { @@ -144,16 +134,7 @@ fn serialize_enum(def: &EnumDef) -> TokenStream { let var_ident = var.ident(); let enum_name = ident.to_string(); let discriminant = u32::from(var.discriminant); - let serialized_to = match var.markers.derive_attributes.estree.rename.as_ref() { - Some(rename) => rename.to_string(), - None => match def.markers.estree.rename_all.as_deref() { - Some("camelCase") => var_ident.to_string().to_case(Case::Camel), - Some(case) => { - panic!("Unsupported rename_all: {case} (on {ident})") - } - None => var_ident.to_string(), - }, - }; + let serialized_to = enum_variant_name(var, def); assert!( var.fields.is_empty(), "Tagged enums must not have inner fields (on {ident}::{var_ident})" diff --git a/tasks/ast_tools/src/generators/typescript.rs b/tasks/ast_tools/src/generators/typescript.rs index d405d39c69ec9..5b3059a122582 100644 --- a/tasks/ast_tools/src/generators/typescript.rs +++ b/tasks/ast_tools/src/generators/typescript.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use itertools::Itertools; use oxc_allocator::Allocator; use oxc_parser::{ParseOptions, Parser}; @@ -8,7 +10,10 @@ use super::define_generator; use crate::{ codegen::LateCtx, output, - schema::{EnumDef, GetIdent, StructDef, TypeDef, TypeName}, + schema::{ + serialize::{enum_variant_name, get_type_tag}, + EnumDef, GetIdent, StructDef, TypeDef, TypeName, + }, Generator, GeneratorOutput, }; @@ -22,14 +27,27 @@ impl Generator for TypescriptGenerator { let mut contents = format!( "\ // To edit this generated file you have to edit `{file}`\n\ - // Auto-generated code, DO NOT EDIT DIRECTLY!\n\n\ - type bool = boolean;type f64 = number;type str = string;type Atom = string;type u32 = number;type u64 = number;\n\n" + // Auto-generated code, DO NOT EDIT DIRECTLY!\n\n" ); + let type_map: HashMap = ctx + .schema() + .into_iter() + .filter_map(|def| { + let TypeDef::Struct(def) = def else { + return None; + }; + let Some(type_tag) = get_type_tag(def) else { + return None; + }; + Some((def.ident().to_string(), type_tag)) + }) + .collect(); + for def in ctx.schema() { let type_def = match def { - TypeDef::Struct(it) => generate_struct(it), - TypeDef::Enum(it) => generate_enum(it), + TypeDef::Struct(it) => generate_struct(it, &type_map), + TypeDef::Enum(it) => generate_enum(it, &type_map), }; let ident = def.ident(); @@ -40,34 +58,53 @@ impl Generator for TypescriptGenerator { } } -fn generate_enum(def: &EnumDef) -> String { +fn generate_enum(def: &EnumDef, type_map: &HashMap) -> String { if def.markers.estree.untagged { - def.all_variants().map(|v| v.ident().to_string()).join(" | ") + def.all_variants() + .map(|var| { + let ident = var.ident().to_string(); + type_map.get(&ident).map_or_else(|| ident, |v| v.to_string()) + }) + .join(" | ") } else { - def.all_variants().map(|v| format!("'{}'", v.ident().to_string())).join(" | ") + def.all_variants().map(|var| format!("'{}'", enum_variant_name(var, def))).join(" | ") } } -fn generate_struct(def: &StructDef) -> String { +fn generate_struct(def: &StructDef, type_map: &HashMap) -> String { let mut type_def = "{".to_string(); + let type_tag = type_map.get(&def.ident().to_string()); + if let Some(type_tag) = type_tag { + type_def.push_str(&format!("type: '{type_tag}';")); + } for field in &def.fields { + if field.markers.derive_attributes.estree.skip { + continue; + } let name = field.ident().expect("expected named field!").to_string(); let name = name.strip_prefix("r#").map(ToString::to_string).unwrap_or(name); - let ty = type_to_string(field.typ.name()); + let ty = type_to_string(field.typ.name(), type_map); type_def.push_str(&format!("{name}: {ty};")); } type_def.push('}'); type_def } -fn type_to_string(ty: &TypeName) -> String { +fn type_to_string(ty: &TypeName, type_map: &HashMap) -> String { match ty { - TypeName::Ident(ident) => ident.to_string(), - TypeName::Vec(type_name) => format!("Array<{}>", type_to_string(type_name)), + TypeName::Ident(ident) => match ident.as_str() { + "f64" | "f32" | "usize" | "u64" | "u32" | "u16" | "u8" | "i64" | "i32" | "i16" + | "i8" => "number", + "bool" => "boolean", + "str" | "String" | "Atom" => "string", + ty => type_map.get(ty).map_or(ty, |v| v.as_str()), + } + .to_string(), + TypeName::Vec(type_name) => format!("Array<{}>", type_to_string(type_name, type_map)), TypeName::Box(type_name) | TypeName::Ref(type_name) | TypeName::Complex(type_name) => { - type_to_string(type_name) + type_to_string(type_name, type_map) } - TypeName::Opt(type_name) => format!("({}) | null", type_to_string(type_name)), + TypeName::Opt(type_name) => format!("({}) | null", type_to_string(type_name, type_map)), } } diff --git a/tasks/ast_tools/src/schema/mod.rs b/tasks/ast_tools/src/schema/mod.rs index 9fb2888ec316f..fc7df13766558 100644 --- a/tasks/ast_tools/src/schema/mod.rs +++ b/tasks/ast_tools/src/schema/mod.rs @@ -17,6 +17,7 @@ use crate::{ mod defs; mod get_generics; mod get_ident; +pub mod serialize; mod to_type; pub use defs::*; pub use get_generics::GetGenerics; diff --git a/tasks/ast_tools/src/schema/serialize.rs b/tasks/ast_tools/src/schema/serialize.rs new file mode 100644 index 0000000000000..bb6532477003f --- /dev/null +++ b/tasks/ast_tools/src/schema/serialize.rs @@ -0,0 +1,32 @@ +use super::{EnumDef, StructDef, VariantDef}; +use crate::{markers::ESTreeStructAttribute, schema::GetIdent}; +use convert_case::{Case, Casing}; + +pub fn enum_variant_name(var: &VariantDef, enm: &EnumDef) -> String { + match var.markers.derive_attributes.estree.rename.as_ref() { + Some(rename) => rename.to_string(), + None => match enm.markers.estree.rename_all.as_deref() { + Some("camelCase") => var.ident().to_string().to_case(Case::Camel), + Some(case) => { + panic!("Unsupported rename_all: {case} (on {})", enm.ident()) + } + None => var.ident().to_string(), + }, + } +} + +pub fn get_type_tag(def: &StructDef) -> Option { + match def.markers.estree { + Some(ESTreeStructAttribute::NoType) => None, + Some(ESTreeStructAttribute::Type(ref type_name)) => Some(type_name.clone()), + None => { + let has_type_field = + def.fields.iter().any(|f| matches!(f.name.as_deref(), Some("type"))); + if has_type_field { + None + } else { + Some(def.ident().to_string()) + } + } + } +} From 624682414c2857abe28b70030f2b8d5c0afea6c4 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Tue, 15 Oct 2024 18:04:41 -0700 Subject: [PATCH 13/28] flatten fields --- crates/oxc_ast/src/ast/ts.rs | 10 - crates/oxc_ast/src/ast_impl/js.rs | 17 - crates/oxc_ast/src/serialize.rs | 11 + crates/oxc_span/src/atom.rs | 6 - crates/oxc_span/src/compact_str.rs | 6 - npm/oxc-types/src/generated/types.d.ts | 2639 ++++++++++++++---- tasks/ast_tools/src/generators/typescript.rs | 94 +- tasks/ast_tools/src/markers.rs | 29 + 8 files changed, 2156 insertions(+), 656 deletions(-) diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index e0ad5dead0b49..5afdb79af9775 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -22,16 +22,6 @@ use tsify::Tsify; use super::{inherit_variants, js::*, jsx::*, literal::*}; -#[cfg(feature = "serialize")] -#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = r#" -export interface TSIndexSignatureName extends Span { - type: "Identifier", - name: Atom, - typeAnnotation: TSTypeAnnotation, -} -"#; - /// TypeScript `this` parameter /// /// ## Example diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index c11746f21b938..b2e9a094ff8c9 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -11,23 +11,6 @@ use oxc_syntax::{ use crate::ast::*; -#[cfg(feature = "serialize")] -#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = r#" -export interface BindingIdentifier extends Span { type: "Identifier", name: Atom } -export interface IdentifierReference extends Span { type: "Identifier", name: Atom } -export interface IdentifierName extends Span { type: "Identifier", name: Atom } -export interface LabelIdentifier extends Span { type: "Identifier", name: Atom } -export interface AssignmentTargetRest extends Span { type: "RestElement", argument: AssignmentTarget } -export interface BindingRestElement extends Span { type: "RestElement", argument: BindingPattern } -export interface FormalParameterRest extends Span { - type: "RestElement", - argument: BindingPatternKind, - typeAnnotation?: TSTypeAnnotation, - optional: boolean, -} -"#; - impl<'a> Program<'a> { pub fn new( span: Span, diff --git a/crates/oxc_ast/src/serialize.rs b/crates/oxc_ast/src/serialize.rs index 12b3b4fcfa8f3..f713fe88d4663 100644 --- a/crates/oxc_ast/src/serialize.rs +++ b/crates/oxc_ast/src/serialize.rs @@ -156,6 +156,17 @@ impl<'a> Serialize for FormalParameters<'a> { } } +#[cfg(feature = "serialize")] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = r#" +export interface FormalParameterRest extends Span { + type: "RestElement", + argument: BindingPatternKind, + typeAnnotation?: TSTypeAnnotation, + optional: boolean, +} +"#; + #[derive(Serialize)] #[serde(tag = "type", rename = "FormalParameters")] struct SerFormalParameters<'a, 'b> { diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index 4c7f2a1c12d90..16c5cb10e6b81 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -10,12 +10,6 @@ use serde::Serialize; use crate::{cmp::ContentEq, hash::ContentHash, CompactStr}; -#[cfg(feature = "serialize")] -#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = r#" -export type Atom = string; -"#; - /// An inlinable string for oxc_allocator. /// /// Use [CompactStr] with [Atom::to_compact_str] or [Atom::into_compact_str] for diff --git a/crates/oxc_span/src/compact_str.rs b/crates/oxc_span/src/compact_str.rs index 3cd38cffecbf2..1378d62e69cf2 100644 --- a/crates/oxc_span/src/compact_str.rs +++ b/crates/oxc_span/src/compact_str.rs @@ -10,12 +10,6 @@ use serde::{Serialize, Serializer}; use crate::Span; -#[cfg(feature = "serialize")] -#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = r#" -export type CompactStr = string; -"#; - /// Maximum length for inline string, which can be created with [`CompactStr::new_const`]. pub const MAX_INLINE_LEN: usize = 16; diff --git a/npm/oxc-types/src/generated/types.d.ts b/npm/oxc-types/src/generated/types.d.ts index 81d0003f80909..63436409a10b1 100644 --- a/npm/oxc-types/src/generated/types.d.ts +++ b/npm/oxc-types/src/generated/types.d.ts @@ -1,575 +1,2070 @@ // To edit this generated file you have to edit `tasks/ast_tools/src/generators/typescript.rs` // Auto-generated code, DO NOT EDIT DIRECTLY! -export type BooleanLiteral = {type: 'BooleanLiteral';span: Span;value: boolean;} - -export type NullLiteral = {type: 'NullLiteral';span: Span;} - -export type NumericLiteral = {type: 'NumericLiteral';span: Span;value: number;raw: string;} - -export type BigIntLiteral = {type: 'BigIntLiteral';span: Span;raw: string;} - -export type RegExpLiteral = {type: 'RegExpLiteral';span: Span;value: EmptyObject;regex: RegExp;} - -export type RegExp = {pattern: RegExpPattern;flags: RegExpFlags;} - -export type RegExpPattern = Raw | Invalid | Pattern - -export type EmptyObject = {} - -export type StringLiteral = {type: 'StringLiteral';span: Span;value: string;} - -export type Program = {type: 'Program';span: Span;source_type: SourceType;hashbang: (Hashbang) | null;directives: Array;body: Array;} - -export type Expression = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type IdentifierName = {type: 'Identifier';span: Span;name: string;} - -export type IdentifierReference = {type: 'Identifier';span: Span;name: string;} - -export type BindingIdentifier = {type: 'Identifier';span: Span;name: string;} - -export type LabelIdentifier = {type: 'Identifier';span: Span;name: string;} - -export type ThisExpression = {type: 'ThisExpression';span: Span;} - -export type ArrayExpression = {type: 'ArrayExpression';span: Span;elements: Array;} - -export type ArrayExpressionElement = SpreadElement | Elision | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type Elision = {type: 'Elision';span: Span;} - -export type ObjectExpression = {type: 'ObjectExpression';span: Span;properties: Array;} - -export type ObjectPropertyKind = ObjectProperty | SpreadProperty - -export type ObjectProperty = {type: 'ObjectProperty';span: Span;kind: PropertyKind;key: PropertyKey;value: Expression;init: (Expression) | null;method: boolean;shorthand: boolean;computed: boolean;} - -export type PropertyKey = StaticIdentifier | PrivateIdentifier | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type PropertyKind = 'init' | 'get' | 'set' - -export type TemplateLiteral = {type: 'TemplateLiteral';span: Span;quasis: Array;expressions: Array;} - -export type TaggedTemplateExpression = {type: 'TaggedTemplateExpression';span: Span;tag: Expression;quasi: TemplateLiteral;type_parameters: (TSTypeParameterInstantiation) | null;} - -export type TemplateElement = {type: 'TemplateElement';span: Span;tail: boolean;value: TemplateElementValue;} - -export type TemplateElementValue = {raw: string;cooked: (string) | null;} - -export type MemberExpression = ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type ComputedMemberExpression = {type: 'ComputedMemberExpression';span: Span;object: Expression;expression: Expression;optional: boolean;} - -export type StaticMemberExpression = {type: 'StaticMemberExpression';span: Span;object: Expression;property: Identifier;optional: boolean;} - -export type PrivateFieldExpression = {type: 'PrivateFieldExpression';span: Span;object: Expression;field: PrivateIdentifier;optional: boolean;} - -export type CallExpression = {type: 'CallExpression';span: Span;callee: Expression;type_parameters: (TSTypeParameterInstantiation) | null;arguments: Array;optional: boolean;} - -export type NewExpression = {type: 'NewExpression';span: Span;callee: Expression;arguments: Array;type_parameters: (TSTypeParameterInstantiation) | null;} - -export type MetaProperty = {type: 'MetaProperty';span: Span;meta: Identifier;property: Identifier;} - -export type SpreadElement = {type: 'SpreadElement';span: Span;argument: Expression;} - -export type Argument = SpreadElement | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type UpdateExpression = {type: 'UpdateExpression';span: Span;operator: UpdateOperator;prefix: boolean;argument: SimpleAssignmentTarget;} - -export type UnaryExpression = {type: 'UnaryExpression';span: Span;operator: UnaryOperator;argument: Expression;} - -export type BinaryExpression = {type: 'BinaryExpression';span: Span;left: Expression;operator: BinaryOperator;right: Expression;} - -export type PrivateInExpression = {type: 'PrivateInExpression';span: Span;left: PrivateIdentifier;operator: BinaryOperator;right: Expression;} - -export type LogicalExpression = {type: 'LogicalExpression';span: Span;left: Expression;operator: LogicalOperator;right: Expression;} - -export type ConditionalExpression = {type: 'ConditionalExpression';span: Span;test: Expression;consequent: Expression;alternate: Expression;} - -export type AssignmentExpression = {type: 'AssignmentExpression';span: Span;operator: AssignmentOperator;left: AssignmentTarget;right: Expression;} - -export type AssignmentTarget = AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget - -export type SimpleAssignmentTarget = AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type AssignmentTargetPattern = ArrayAssignmentTarget | ObjectAssignmentTarget - -export type ArrayAssignmentTarget = {type: 'ArrayAssignmentTarget';span: Span;elements: Array<(AssignmentTargetMaybeDefault) | null>;} - -export type ObjectAssignmentTarget = {type: 'ObjectAssignmentTarget';span: Span;properties: Array;} - -export type AssignmentTargetRest = {type: 'RestElement';span: Span;target: AssignmentTarget;} - -export type AssignmentTargetMaybeDefault = AssignmentTargetWithDefault | AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget - -export type AssignmentTargetWithDefault = {type: 'AssignmentTargetWithDefault';span: Span;binding: AssignmentTarget;init: Expression;} - -export type AssignmentTargetProperty = AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty - -export type AssignmentTargetPropertyIdentifier = {type: 'AssignmentTargetPropertyIdentifier';span: Span;binding: Identifier;init: (Expression) | null;} - -export type AssignmentTargetPropertyProperty = {type: 'AssignmentTargetPropertyProperty';span: Span;name: PropertyKey;binding: AssignmentTargetMaybeDefault;} - -export type SequenceExpression = {type: 'SequenceExpression';span: Span;expressions: Array;} - -export type Super = {type: 'Super';span: Span;} - -export type AwaitExpression = {type: 'AwaitExpression';span: Span;argument: Expression;} - -export type ChainExpression = {type: 'ChainExpression';span: Span;expression: ChainElement;} - -export type ChainElement = CallExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type ParenthesizedExpression = {type: 'ParenthesizedExpression';span: Span;expression: Expression;} - -export type Statement = BlockStatement | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | IfStatement | LabeledStatement | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | WithStatement | VariableDeclaration | FunctionDeclaration | ClassDeclaration | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration | ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration - -export type Directive = {type: 'Directive';span: Span;expression: StringLiteral;directive: string;} - -export type Hashbang = {type: 'Hashbang';span: Span;value: string;} - -export type BlockStatement = {type: 'BlockStatement';span: Span;body: Array;} - -export type Declaration = VariableDeclaration | FunctionDeclaration | ClassDeclaration | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration - -export type VariableDeclaration = {type: 'VariableDeclaration';span: Span;kind: VariableDeclarationKind;declarations: Array;declare: boolean;} - -export type VariableDeclarationKind = 'var' | 'const' | 'let' | 'using' | 'await using' - -export type VariableDeclarator = {type: 'VariableDeclarator';span: Span;id: BindingPattern;init: (Expression) | null;definite: boolean;} - -export type EmptyStatement = {type: 'EmptyStatement';span: Span;} - -export type ExpressionStatement = {type: 'ExpressionStatement';span: Span;expression: Expression;} - -export type IfStatement = {type: 'IfStatement';span: Span;test: Expression;consequent: Statement;alternate: (Statement) | null;} - -export type DoWhileStatement = {type: 'DoWhileStatement';span: Span;body: Statement;test: Expression;} - -export type WhileStatement = {type: 'WhileStatement';span: Span;test: Expression;body: Statement;} - -export type ForStatement = {type: 'ForStatement';span: Span;init: (ForStatementInit) | null;test: (Expression) | null;update: (Expression) | null;body: Statement;} - -export type ForStatementInit = VariableDeclaration | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type ForInStatement = {type: 'ForInStatement';span: Span;left: ForStatementLeft;right: Expression;body: Statement;} - -export type ForStatementLeft = VariableDeclaration | AssignmentTargetIdentifier | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget - -export type ForOfStatement = {type: 'ForOfStatement';span: Span;await: boolean;left: ForStatementLeft;right: Expression;body: Statement;} - -export type ContinueStatement = {type: 'ContinueStatement';span: Span;label: (Identifier) | null;} - -export type BreakStatement = {type: 'BreakStatement';span: Span;label: (Identifier) | null;} - -export type ReturnStatement = {type: 'ReturnStatement';span: Span;argument: (Expression) | null;} - -export type WithStatement = {type: 'WithStatement';span: Span;object: Expression;body: Statement;} - -export type SwitchStatement = {type: 'SwitchStatement';span: Span;discriminant: Expression;cases: Array;} - -export type SwitchCase = {type: 'SwitchCase';span: Span;test: (Expression) | null;consequent: Array;} - -export type LabeledStatement = {type: 'LabeledStatement';span: Span;label: Identifier;body: Statement;} - -export type ThrowStatement = {type: 'ThrowStatement';span: Span;argument: Expression;} - -export type TryStatement = {type: 'TryStatement';span: Span;block: BlockStatement;handler: (CatchClause) | null;finalizer: (BlockStatement) | null;} - -export type CatchClause = {type: 'CatchClause';span: Span;param: (CatchParameter) | null;body: BlockStatement;} - -export type CatchParameter = {type: 'CatchParameter';span: Span;pattern: BindingPattern;} - -export type DebuggerStatement = {type: 'DebuggerStatement';span: Span;} - -export type BindingPattern = {kind: BindingPatternKind;type_annotation: (TSTypeAnnotation) | null;optional: boolean;} - -export type BindingPatternKind = Identifier | ObjectPattern | ArrayPattern | AssignmentPattern - -export type AssignmentPattern = {type: 'AssignmentPattern';span: Span;left: BindingPattern;right: Expression;} - -export type ObjectPattern = {type: 'ObjectPattern';span: Span;properties: Array;} - -export type BindingProperty = {type: 'BindingProperty';span: Span;key: PropertyKey;value: BindingPattern;shorthand: boolean;computed: boolean;} - -export type ArrayPattern = {type: 'ArrayPattern';span: Span;elements: Array<(BindingPattern) | null>;} - -export type BindingRestElement = {type: 'RestElement';span: Span;argument: BindingPattern;} - -export type Function = {type: FunctionType;span: Span;id: (Identifier) | null;generator: boolean;async: boolean;declare: boolean;type_parameters: (TSTypeParameterDeclaration) | null;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;body: (FunctionBody) | null;} - -export type FunctionType = 'FunctionDeclaration' | 'FunctionExpression' | 'TSDeclareFunction' | 'TSEmptyBodyFunctionExpression' - -export type FormalParameters = {type: 'FormalParameters';span: Span;kind: FormalParameterKind;items: Array;} - -export type FormalParameter = {type: 'FormalParameter';span: Span;decorators: Array;pattern: BindingPattern;accessibility: (TSAccessibility) | null;readonly: boolean;override: boolean;} - -export type FormalParameterKind = 'FormalParameter' | 'UniqueFormalParameters' | 'ArrowFormalParameters' | 'Signature' - -export type FunctionBody = {type: 'FunctionBody';span: Span;directives: Array;statements: Array;} - -export type ArrowFunctionExpression = {type: 'ArrowFunctionExpression';span: Span;expression: boolean;async: boolean;type_parameters: (TSTypeParameterDeclaration) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;body: FunctionBody;} - -export type YieldExpression = {type: 'YieldExpression';span: Span;delegate: boolean;argument: (Expression) | null;} - -export type Class = {type: ClassType;span: Span;decorators: Array;id: (Identifier) | null;type_parameters: (TSTypeParameterDeclaration) | null;super_class: (Expression) | null;super_type_parameters: (TSTypeParameterInstantiation) | null;implements: (Array) | null;body: ClassBody;abstract: boolean;declare: boolean;} - -export type ClassType = 'ClassDeclaration' | 'ClassExpression' - -export type ClassBody = {type: 'ClassBody';span: Span;body: Array;} - -export type ClassElement = StaticBlock | MethodDefinition | PropertyDefinition | AccessorProperty | TSIndexSignature - -export type MethodDefinition = {type: MethodDefinitionType;span: Span;decorators: Array;key: PropertyKey;value: Function;kind: MethodDefinitionKind;computed: boolean;static: boolean;override: boolean;optional: boolean;accessibility: (TSAccessibility) | null;} - -export type MethodDefinitionType = 'MethodDefinition' | 'TSAbstractMethodDefinition' - -export type PropertyDefinition = {type: PropertyDefinitionType;span: Span;decorators: Array;key: PropertyKey;value: (Expression) | null;computed: boolean;static: boolean;declare: boolean;override: boolean;optional: boolean;definite: boolean;readonly: boolean;type_annotation: (TSTypeAnnotation) | null;accessibility: (TSAccessibility) | null;} - -export type PropertyDefinitionType = 'PropertyDefinition' | 'TSAbstractPropertyDefinition' - -export type MethodDefinitionKind = 'constructor' | 'method' | 'get' | 'set' - -export type PrivateIdentifier = {type: 'PrivateIdentifier';span: Span;name: string;} - -export type StaticBlock = {type: 'StaticBlock';span: Span;body: Array;} - -export type ModuleDeclaration = ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration - -export type AccessorPropertyType = 'AccessorProperty' | 'TSAbstractAccessorProperty' - -export type AccessorProperty = {type: AccessorPropertyType;span: Span;decorators: Array;key: PropertyKey;value: (Expression) | null;computed: boolean;static: boolean;definite: boolean;type_annotation: (TSTypeAnnotation) | null;accessibility: (TSAccessibility) | null;} - -export type ImportExpression = {type: 'ImportExpression';span: Span;source: Expression;arguments: Array;} - -export type ImportDeclaration = {type: 'ImportDeclaration';span: Span;specifiers: (Array) | null;source: StringLiteral;with_clause: (WithClause) | null;import_kind: ImportOrExportKind;} - -export type ImportDeclarationSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier - -export type ImportSpecifier = {type: 'ImportSpecifier';span: Span;imported: ModuleExportName;local: Identifier;import_kind: ImportOrExportKind;} - -export type ImportDefaultSpecifier = {type: 'ImportDefaultSpecifier';span: Span;local: Identifier;} - -export type ImportNamespaceSpecifier = {type: 'ImportNamespaceSpecifier';span: Span;local: Identifier;} - -export type WithClause = {type: 'WithClause';span: Span;attributes_keyword: Identifier;with_entries: Array;} - -export type ImportAttribute = {type: 'ImportAttribute';span: Span;key: ImportAttributeKey;value: StringLiteral;} - -export type ImportAttributeKey = Identifier | StringLiteral - -export type ExportNamedDeclaration = {type: 'ExportNamedDeclaration';span: Span;declaration: (Declaration) | null;specifiers: Array;source: (StringLiteral) | null;export_kind: ImportOrExportKind;with_clause: (WithClause) | null;} - -export type ExportDefaultDeclaration = {type: 'ExportDefaultDeclaration';span: Span;declaration: ExportDefaultDeclarationKind;exported: ModuleExportName;} - -export type ExportAllDeclaration = {type: 'ExportAllDeclaration';span: Span;exported: (ModuleExportName) | null;source: StringLiteral;with_clause: (WithClause) | null;export_kind: ImportOrExportKind;} - -export type ExportSpecifier = {type: 'ExportSpecifier';span: Span;local: ModuleExportName;exported: ModuleExportName;export_kind: ImportOrExportKind;} - -export type ExportDefaultDeclarationKind = FunctionDeclaration | ClassDeclaration | TSInterfaceDeclaration | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type ModuleExportName = Identifier | Identifier | StringLiteral - -export type TSThisParameter = {type: 'TSThisParameter';span: Span;this_span: Span;type_annotation: (TSTypeAnnotation) | null;} - -export type TSEnumDeclaration = {type: 'TSEnumDeclaration';span: Span;id: Identifier;members: Array;const: boolean;declare: boolean;} - -export type TSEnumMember = {type: 'TSEnumMember';span: Span;id: TSEnumMemberName;initializer: (Expression) | null;} - -export type TSEnumMemberName = StaticIdentifier | StaticStringLiteral | StaticTemplateLiteral | StaticNumericLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type TSTypeAnnotation = {type: 'TSTypeAnnotation';span: Span;type_annotation: TSType;} - -export type TSLiteralType = {type: 'TSLiteralType';span: Span;literal: TSLiteral;} - -export type TSLiteral = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | UnaryExpression - -export type TSType = TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSNamedTupleMember | TSQualifiedName | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperatorType | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TSParenthesizedType | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType - -export type TSConditionalType = {type: 'TSConditionalType';span: Span;check_type: TSType;extends_type: TSType;true_type: TSType;false_type: TSType;} - -export type TSUnionType = {type: 'TSUnionType';span: Span;types: Array;} - -export type TSIntersectionType = {type: 'TSIntersectionType';span: Span;types: Array;} - -export type TSParenthesizedType = {type: 'TSParenthesizedType';span: Span;type_annotation: TSType;} - -export type TSTypeOperator = {type: 'TSTypeOperator';span: Span;operator: TSTypeOperatorOperator;type_annotation: TSType;} - -export type TSTypeOperatorOperator = 'keyof' | 'unique' | 'readonly' - -export type TSArrayType = {type: 'TSArrayType';span: Span;element_type: TSType;} - -export type TSIndexedAccessType = {type: 'TSIndexedAccessType';span: Span;object_type: TSType;index_type: TSType;} - -export type TSTupleType = {type: 'TSTupleType';span: Span;element_types: Array;} - -export type TSNamedTupleMember = {type: 'TSNamedTupleMember';span: Span;element_type: TSTupleElement;label: Identifier;optional: boolean;} - -export type TSOptionalType = {type: 'TSOptionalType';span: Span;type_annotation: TSType;} - -export type TSRestType = {type: 'TSRestType';span: Span;type_annotation: TSType;} - -export type TSTupleElement = TSOptionalType | TSRestType | TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSNamedTupleMember | TSQualifiedName | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperatorType | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TSParenthesizedType | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType - -export type TSAnyKeyword = {type: 'TSAnyKeyword';span: Span;} - -export type TSStringKeyword = {type: 'TSStringKeyword';span: Span;} - -export type TSBooleanKeyword = {type: 'TSBooleanKeyword';span: Span;} - -export type TSNumberKeyword = {type: 'TSNumberKeyword';span: Span;} - -export type TSNeverKeyword = {type: 'TSNeverKeyword';span: Span;} - -export type TSIntrinsicKeyword = {type: 'TSIntrinsicKeyword';span: Span;} - -export type TSUnknownKeyword = {type: 'TSUnknownKeyword';span: Span;} - -export type TSNullKeyword = {type: 'TSNullKeyword';span: Span;} - -export type TSUndefinedKeyword = {type: 'TSUndefinedKeyword';span: Span;} - -export type TSVoidKeyword = {type: 'TSVoidKeyword';span: Span;} - -export type TSSymbolKeyword = {type: 'TSSymbolKeyword';span: Span;} - -export type TSThisType = {type: 'TSThisType';span: Span;} - -export type TSObjectKeyword = {type: 'TSObjectKeyword';span: Span;} - -export type TSBigIntKeyword = {type: 'TSBigIntKeyword';span: Span;} - -export type TSTypeReference = {type: 'TSTypeReference';span: Span;type_name: TSTypeName;type_parameters: (TSTypeParameterInstantiation) | null;} - -export type TSTypeName = Identifier | QualifiedName - -export type TSQualifiedName = {type: 'TSQualifiedName';span: Span;left: TSTypeName;right: Identifier;} - -export type TSTypeParameterInstantiation = {type: 'TSTypeParameterInstantiation';span: Span;params: Array;} - -export type TSTypeParameter = {type: 'TSTypeParameter';span: Span;name: Identifier;constraint: (TSType) | null;default: (TSType) | null;in: boolean;out: boolean;const: boolean;} - -export type TSTypeParameterDeclaration = {type: 'TSTypeParameterDeclaration';span: Span;params: Array;} - -export type TSTypeAliasDeclaration = {type: 'TSTypeAliasDeclaration';span: Span;id: Identifier;type_parameters: (TSTypeParameterDeclaration) | null;type_annotation: TSType;declare: boolean;} - -export type TSAccessibility = 'private' | 'protected' | 'public' - -export type TSClassImplements = {type: 'TSClassImplements';span: Span;expression: TSTypeName;type_parameters: (TSTypeParameterInstantiation) | null;} - -export type TSInterfaceDeclaration = {type: 'TSInterfaceDeclaration';span: Span;id: Identifier;extends: (Array) | null;type_parameters: (TSTypeParameterDeclaration) | null;body: TSInterfaceBody;declare: boolean;} - -export type TSInterfaceBody = {type: 'TSInterfaceBody';span: Span;body: Array;} - -export type TSPropertySignature = {type: 'TSPropertySignature';span: Span;computed: boolean;optional: boolean;readonly: boolean;key: PropertyKey;type_annotation: (TSTypeAnnotation) | null;} - -export type TSSignature = TSIndexSignature | TSPropertySignature | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSMethodSignature - -export type TSIndexSignature = {type: 'TSIndexSignature';span: Span;parameters: Array;type_annotation: TSTypeAnnotation;readonly: boolean;} - -export type TSCallSignatureDeclaration = {type: 'TSCallSignatureDeclaration';span: Span;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;} - -export type TSMethodSignatureKind = 'method' | 'get' | 'set' - -export type TSMethodSignature = {type: 'TSMethodSignature';span: Span;key: PropertyKey;computed: boolean;optional: boolean;kind: TSMethodSignatureKind;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;} - -export type TSConstructSignatureDeclaration = {type: 'TSConstructSignatureDeclaration';span: Span;params: FormalParameters;return_type: (TSTypeAnnotation) | null;type_parameters: (TSTypeParameterDeclaration) | null;} - -export type TSIndexSignatureName = {type: 'Identifier';span: Span;name: string;type_annotation: TSTypeAnnotation;} - -export type TSInterfaceHeritage = {type: 'TSInterfaceHeritage';span: Span;expression: Expression;type_parameters: (TSTypeParameterInstantiation) | null;} - -export type TSTypePredicate = {type: 'TSTypePredicate';span: Span;parameter_name: TSTypePredicateName;asserts: boolean;type_annotation: (TSTypeAnnotation) | null;} - -export type TSTypePredicateName = Identifier | This - -export type TSModuleDeclaration = {type: 'TSModuleDeclaration';span: Span;id: TSModuleDeclarationName;body: (TSModuleDeclarationBody) | null;kind: TSModuleDeclarationKind;declare: boolean;} - -export type TSModuleDeclarationKind = 'global' | 'module' | 'namespace' - -export type TSModuleDeclarationName = Identifier | StringLiteral - -export type TSModuleDeclarationBody = TSModuleDeclaration | TSModuleBlock - -export type TSModuleBlock = {type: 'TSModuleBlock';span: Span;body: Array;} - -export type TSTypeLiteral = {type: 'TSTypeLiteral';span: Span;members: Array;} - -export type TSInferType = {type: 'TSInferType';span: Span;type_parameter: TSTypeParameter;} - -export type TSTypeQuery = {type: 'TSTypeQuery';span: Span;expr_name: TSTypeQueryExprName;type_parameters: (TSTypeParameterInstantiation) | null;} - -export type TSTypeQueryExprName = TSImportType | Identifier | QualifiedName - -export type TSImportType = {type: 'TSImportType';span: Span;is_type_of: boolean;parameter: TSType;qualifier: (TSTypeName) | null;attributes: (TSImportAttributes) | null;type_parameters: (TSTypeParameterInstantiation) | null;} - -export type TSImportAttributes = {type: 'TSImportAttributes';span: Span;attributes_keyword: Identifier;elements: Array;} - -export type TSImportAttribute = {type: 'TSImportAttribute';span: Span;name: TSImportAttributeName;value: Expression;} - -export type TSImportAttributeName = Identifier | StringLiteral - -export type TSFunctionType = {type: 'TSFunctionType';span: Span;this_param: (TSThisParameter) | null;params: FormalParameters;return_type: TSTypeAnnotation;type_parameters: (TSTypeParameterDeclaration) | null;} - -export type TSConstructorType = {type: 'TSConstructorType';span: Span;abstract: boolean;params: FormalParameters;return_type: TSTypeAnnotation;type_parameters: (TSTypeParameterDeclaration) | null;} - -export type TSMappedType = {type: 'TSMappedType';span: Span;type_parameter: TSTypeParameter;name_type: (TSType) | null;type_annotation: (TSType) | null;optional: TSMappedTypeModifierOperator;readonly: TSMappedTypeModifierOperator;} - -export type TSMappedTypeModifierOperator = 'true' | '+' | '-' | 'none' - -export type TSTemplateLiteralType = {type: 'TSTemplateLiteralType';span: Span;quasis: Array;types: Array;} - -export type TSAsExpression = {type: 'TSAsExpression';span: Span;expression: Expression;type_annotation: TSType;} - -export type TSSatisfiesExpression = {type: 'TSSatisfiesExpression';span: Span;expression: Expression;type_annotation: TSType;} - -export type TSTypeAssertion = {type: 'TSTypeAssertion';span: Span;expression: Expression;type_annotation: TSType;} - -export type TSImportEqualsDeclaration = {type: 'TSImportEqualsDeclaration';span: Span;id: Identifier;module_reference: TSModuleReference;import_kind: ImportOrExportKind;} - -export type TSModuleReference = ExternalModuleReference | Identifier | QualifiedName - -export type TSExternalModuleReference = {type: 'TSExternalModuleReference';span: Span;expression: StringLiteral;} - -export type TSNonNullExpression = {type: 'TSNonNullExpression';span: Span;expression: Expression;} - -export type Decorator = {type: 'Decorator';span: Span;expression: Expression;} - -export type TSExportAssignment = {type: 'TSExportAssignment';span: Span;expression: Expression;} - -export type TSNamespaceExportDeclaration = {type: 'TSNamespaceExportDeclaration';span: Span;id: Identifier;} - -export type TSInstantiationExpression = {type: 'TSInstantiationExpression';span: Span;expression: Expression;type_parameters: TSTypeParameterInstantiation;} - -export type ImportOrExportKind = 'value' | 'type' - -export type JSDocNullableType = {type: 'JSDocNullableType';span: Span;type_annotation: TSType;postfix: boolean;} - -export type JSDocNonNullableType = {type: 'JSDocNonNullableType';span: Span;type_annotation: TSType;postfix: boolean;} - -export type JSDocUnknownType = {type: 'JSDocUnknownType';span: Span;} - -export type JSXElement = {type: 'JSXElement';span: Span;opening_element: JSXOpeningElement;closing_element: (JSXClosingElement) | null;children: Array;} - -export type JSXOpeningElement = {type: 'JSXOpeningElement';span: Span;self_closing: boolean;name: JSXElementName;attributes: Array;type_parameters: (TSTypeParameterInstantiation) | null;} - -export type JSXClosingElement = {type: 'JSXClosingElement';span: Span;name: JSXElementName;} - -export type JSXFragment = {type: 'JSXFragment';span: Span;opening_fragment: JSXOpeningFragment;closing_fragment: JSXClosingFragment;children: Array;} - -export type JSXOpeningFragment = {type: 'JSXOpeningFragment';span: Span;} - -export type JSXClosingFragment = {type: 'JSXClosingFragment';span: Span;} - -export type JSXElementName = Identifier | Identifier | NamespacedName | MemberExpression | ThisExpression - -export type JSXNamespacedName = {type: 'JSXNamespacedName';span: Span;namespace: JSXIdentifier;property: JSXIdentifier;} - -export type JSXMemberExpression = {type: 'JSXMemberExpression';span: Span;object: JSXMemberExpressionObject;property: JSXIdentifier;} - -export type JSXMemberExpressionObject = Identifier | MemberExpression | ThisExpression - -export type JSXExpressionContainer = {type: 'JSXExpressionContainer';span: Span;expression: JSXExpression;} - -export type JSXExpression = EmptyExpression | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | Identifier | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | ClassExpression | ConditionalExpression | FunctionExpression | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression - -export type JSXEmptyExpression = {type: 'JSXEmptyExpression';span: Span;} - -export type JSXAttributeItem = Attribute | SpreadAttribute - -export type JSXAttribute = {type: 'JSXAttribute';span: Span;name: JSXAttributeName;value: (JSXAttributeValue) | null;} - -export type JSXSpreadAttribute = {type: 'JSXSpreadAttribute';span: Span;argument: Expression;} - -export type JSXAttributeName = Identifier | NamespacedName - -export type JSXAttributeValue = StringLiteral | ExpressionContainer | Element | Fragment - -export type JSXIdentifier = {type: 'JSXIdentifier';span: Span;name: string;} - -export type JSXChild = Text | Element | Fragment | ExpressionContainer | Spread - -export type JSXSpreadChild = {type: 'JSXSpreadChild';span: Span;expression: Expression;} - -export type JSXText = {type: 'JSXText';span: Span;value: string;} - -export type NumberBase = 'Float' | 'Decimal' | 'Binary' | 'Octal' | 'Hex' - -export type BigintBase = 'Decimal' | 'Binary' | 'Octal' | 'Hex' - -export type AssignmentOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&=' | '&&=' | '||=' | '??=' | '**=' - -export type BinaryOperator = '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '|' | '^' | '&' | 'in' | 'instanceof' | '**' - -export type LogicalOperator = '||' | '&&' | '??' - -export type UnaryOperator = '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete' - -export type UpdateOperator = '++' | '--' - -export type Span = {type: 'Span';start: number;end: number;} - -export type SourceType = {language: Language;module_kind: ModuleKind;variant: LanguageVariant;} - -export type Language = 'javascript' | 'typescript' | 'typescriptDefinition' - -export type ModuleKind = 'script' | 'module' | 'unambiguous' - -export type LanguageVariant = 'standard' | 'jsx' - -export type Pattern = {type: 'Pattern';span: Span;body: Disjunction;} - -export type Disjunction = {type: 'Disjunction';span: Span;body: Array;} - -export type Alternative = {type: 'Alternative';span: Span;body: Array;} - -export type Term = BoundaryAssertion | LookAroundAssertion | Quantifier | Character | Dot | CharacterClassEscape | UnicodePropertyEscape | CharacterClass | CapturingGroup | IgnoreGroup | IndexedReference | NamedReference - -export type BoundaryAssertion = {type: 'BoundaryAssertion';span: Span;kind: BoundaryAssertionKind;} - -export type BoundaryAssertionKind = 'start' | 'end' | 'boundary' | 'negativeBoundary' - -export type LookAroundAssertion = {type: 'LookAroundAssertion';span: Span;kind: LookAroundAssertionKind;body: Disjunction;} - -export type LookAroundAssertionKind = 'lookahead' | 'negativeLookahead' | 'lookbehind' | 'negativeLookbehind' - -export type Quantifier = {type: 'Quantifier';span: Span;min: number;max: (number) | null;greedy: boolean;body: Term;} - -export type Character = {type: 'Character';span: Span;kind: CharacterKind;value: number;} - -export type CharacterKind = 'controlLetter' | 'hexadecimalEscape' | 'identifier' | 'null' | 'octal1' | 'octal2' | 'octal3' | 'singleEscape' | 'symbol' | 'unicodeEscape' - -export type CharacterClassEscape = {type: 'CharacterClassEscape';span: Span;kind: CharacterClassEscapeKind;} - -export type CharacterClassEscapeKind = 'd' | 'negativeD' | 's' | 'negativeS' | 'w' | 'negativeW' - -export type UnicodePropertyEscape = {type: 'UnicodePropertyEscape';span: Span;negative: boolean;strings: boolean;name: string;value: (string) | null;} - -export type Dot = {type: 'Dot';span: Span;} - -export type CharacterClass = {type: 'CharacterClass';span: Span;negative: boolean;strings: boolean;kind: CharacterClassContentsKind;body: Array;} - -export type CharacterClassContentsKind = 'union' | 'intersection' | 'subtraction' - -export type CharacterClassContents = CharacterClassRange | CharacterClassEscape | UnicodePropertyEscape | Character | NestedCharacterClass | ClassStringDisjunction - -export type CharacterClassRange = {type: 'CharacterClassRange';span: Span;min: Character;max: Character;} - -export type ClassStringDisjunction = {type: 'ClassStringDisjunction';span: Span;strings: boolean;body: Array;} - -export type ClassString = {type: 'ClassString';span: Span;strings: boolean;body: Array;} - -export type CapturingGroup = {type: 'CapturingGroup';span: Span;name: (string) | null;body: Disjunction;} - -export type IgnoreGroup = {type: 'IgnoreGroup';span: Span;modifiers: (Modifiers) | null;body: Disjunction;} - -export type Modifiers = {type: 'Modifiers';span: Span;enabling: (Modifier) | null;disabling: (Modifier) | null;} - -export type Modifier = {type: 'Modifier';ignore_case: boolean;multiline: boolean;sticky: boolean;} - -export type IndexedReference = {type: 'IndexedReference';span: Span;index: number;} - -export type NamedReference = {type: 'NamedReference';span: Span;name: string;} - +export type BooleanLiteral = { + type: "BooleanLiteral"; + value: boolean; +} & Span; + +export type NullLiteral = { + type: "NullLiteral"; +} & Span; + +export type NumericLiteral = { + type: "NumericLiteral"; + value: number; + raw: string; +} & Span; + +export type BigIntLiteral = { + type: "BigIntLiteral"; + raw: string; +} & Span; + +export type RegExpLiteral = { + type: "RegExpLiteral"; + value: EmptyObject; + regex: RegExp; +} & Span; + +export type RegExp = { + pattern: RegExpPattern; + flags: RegExpFlags; +}; + +export type RegExpPattern = string | string | Pattern; + +export type EmptyObject = {}; + +export type StringLiteral = { + type: "StringLiteral"; + value: string; +} & Span; + +export type Program = { + type: "Program"; + sourceType: SourceType; + hashbang: Hashbang | null; + directives: Array; + body: Array; +} & Span; + +export type Expression = + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type IdentifierName = { + type: "Identifier"; + name: string; +} & Span; + +export type IdentifierReference = { + type: "Identifier"; + name: string; +} & Span; + +export type BindingIdentifier = { + type: "Identifier"; + name: string; +} & Span; + +export type LabelIdentifier = { + type: "Identifier"; + name: string; +} & Span; + +export type ThisExpression = { + type: "ThisExpression"; +} & Span; + +export type ArrayExpression = { + type: "ArrayExpression"; + elements: Array; +} & Span; + +export type ArrayExpressionElement = + | SpreadElement + | Elision + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type ObjectExpression = { + type: "ObjectExpression"; + properties: Array; +} & Span; + +export type ObjectPropertyKind = ObjectProperty | SpreadElement; + +export type ObjectProperty = { + type: "ObjectProperty"; + kind: PropertyKind; + key: PropertyKey; + value: Expression; + init: Expression | null; + method: boolean; + shorthand: boolean; + computed: boolean; +} & Span; + +export type PropertyKey = + | IdentifierName + | PrivateIdentifier + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type PropertyKind = "init" | "get" | "set"; + +export type TemplateLiteral = { + type: "TemplateLiteral"; + quasis: Array; + expressions: Array; +} & Span; + +export type TaggedTemplateExpression = { + type: "TaggedTemplateExpression"; + tag: Expression; + quasi: TemplateLiteral; + typeParameters: TSTypeParameterInstantiation | null; +} & Span; + +export type TemplateElement = { + type: "TemplateElement"; + tail: boolean; + value: TemplateElementValue; +} & Span; + +export type TemplateElementValue = { + raw: string; + cooked: string | null; +}; + +export type MemberExpression = + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type ComputedMemberExpression = { + type: "ComputedMemberExpression"; + object: Expression; + expression: Expression; + optional: boolean; +} & Span; + +export type StaticMemberExpression = { + type: "StaticMemberExpression"; + object: Expression; + property: IdentifierName; + optional: boolean; +} & Span; + +export type PrivateFieldExpression = { + type: "PrivateFieldExpression"; + object: Expression; + field: PrivateIdentifier; + optional: boolean; +} & Span; + +export type CallExpression = { + type: "CallExpression"; + callee: Expression; + typeParameters: TSTypeParameterInstantiation | null; + arguments: Array; + optional: boolean; +} & Span; + +export type NewExpression = { + type: "NewExpression"; + callee: Expression; + arguments: Array; + typeParameters: TSTypeParameterInstantiation | null; +} & Span; + +export type MetaProperty = { + type: "MetaProperty"; + meta: IdentifierName; + property: IdentifierName; +} & Span; + +export type SpreadElement = { + type: "SpreadElement"; + argument: Expression; +} & Span; + +export type Argument = + | SpreadElement + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type UpdateExpression = { + type: "UpdateExpression"; + operator: UpdateOperator; + prefix: boolean; + argument: SimpleAssignmentTarget; +} & Span; + +export type UnaryExpression = { + type: "UnaryExpression"; + operator: UnaryOperator; + argument: Expression; +} & Span; + +export type BinaryExpression = { + type: "BinaryExpression"; + left: Expression; + operator: BinaryOperator; + right: Expression; +} & Span; + +export type PrivateInExpression = { + type: "PrivateInExpression"; + left: PrivateIdentifier; + operator: BinaryOperator; + right: Expression; +} & Span; + +export type LogicalExpression = { + type: "LogicalExpression"; + left: Expression; + operator: LogicalOperator; + right: Expression; +} & Span; + +export type ConditionalExpression = { + type: "ConditionalExpression"; + test: Expression; + consequent: Expression; + alternate: Expression; +} & Span; + +export type AssignmentExpression = { + type: "AssignmentExpression"; + operator: AssignmentOperator; + left: AssignmentTarget; + right: Expression; +} & Span; + +export type AssignmentTarget = + | IdentifierReference + | TSAsExpression + | TSSatisfiesExpression + | TSNonNullExpression + | TSTypeAssertion + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression + | ArrayAssignmentTarget + | ObjectAssignmentTarget; + +export type SimpleAssignmentTarget = + | IdentifierReference + | TSAsExpression + | TSSatisfiesExpression + | TSNonNullExpression + | TSTypeAssertion + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type AssignmentTargetPattern = + | ArrayAssignmentTarget + | ObjectAssignmentTarget; + +export type AssignmentTargetRest = { + type: "RestElement"; + argument: AssignmentTarget; +} & Span; + +export type AssignmentTargetMaybeDefault = + | AssignmentTargetWithDefault + | IdentifierReference + | TSAsExpression + | TSSatisfiesExpression + | TSNonNullExpression + | TSTypeAssertion + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression + | ArrayAssignmentTarget + | ObjectAssignmentTarget; + +export type AssignmentTargetWithDefault = { + type: "AssignmentTargetWithDefault"; + binding: AssignmentTarget; + init: Expression; +} & Span; + +export type AssignmentTargetProperty = + | AssignmentTargetPropertyIdentifier + | AssignmentTargetPropertyProperty; + +export type AssignmentTargetPropertyIdentifier = { + type: "AssignmentTargetPropertyIdentifier"; + binding: IdentifierReference; + init: Expression | null; +} & Span; + +export type AssignmentTargetPropertyProperty = { + type: "AssignmentTargetPropertyProperty"; + name: PropertyKey; + binding: AssignmentTargetMaybeDefault; +} & Span; + +export type SequenceExpression = { + type: "SequenceExpression"; + expressions: Array; +} & Span; + +export type Super = { + type: "Super"; +} & Span; + +export type AwaitExpression = { + type: "AwaitExpression"; + argument: Expression; +} & Span; + +export type ChainExpression = { + type: "ChainExpression"; + expression: ChainElement; +} & Span; + +export type ChainElement = + | CallExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type ParenthesizedExpression = { + type: "ParenthesizedExpression"; + expression: Expression; +} & Span; + +export type Statement = + | BlockStatement + | BreakStatement + | ContinueStatement + | DebuggerStatement + | DoWhileStatement + | EmptyStatement + | ExpressionStatement + | ForInStatement + | ForOfStatement + | ForStatement + | IfStatement + | LabeledStatement + | ReturnStatement + | SwitchStatement + | ThrowStatement + | TryStatement + | WhileStatement + | WithStatement + | VariableDeclaration + | Function + | Class + | TSTypeAliasDeclaration + | TSInterfaceDeclaration + | TSEnumDeclaration + | TSModuleDeclaration + | TSImportEqualsDeclaration + | ImportDeclaration + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | TSExportAssignment + | TSNamespaceExportDeclaration; + +export type Directive = { + type: "Directive"; + expression: StringLiteral; + directive: string; +} & Span; + +export type Hashbang = { + type: "Hashbang"; + value: string; +} & Span; + +export type BlockStatement = { + type: "BlockStatement"; + body: Array; +} & Span; + +export type Declaration = + | VariableDeclaration + | Function + | Class + | TSTypeAliasDeclaration + | TSInterfaceDeclaration + | TSEnumDeclaration + | TSModuleDeclaration + | TSImportEqualsDeclaration; + +export type VariableDeclaration = { + type: "VariableDeclaration"; + kind: VariableDeclarationKind; + declarations: Array; + declare: boolean; +} & Span; + +export type VariableDeclarationKind = + | "var" + | "const" + | "let" + | "using" + | "await using"; + +export type VariableDeclarator = { + type: "VariableDeclarator"; + id: BindingPattern; + init: Expression | null; + definite: boolean; +} & Span; + +export type EmptyStatement = { + type: "EmptyStatement"; +} & Span; + +export type ExpressionStatement = { + type: "ExpressionStatement"; + expression: Expression; +} & Span; + +export type IfStatement = { + type: "IfStatement"; + test: Expression; + consequent: Statement; + alternate: Statement | null; +} & Span; + +export type DoWhileStatement = { + type: "DoWhileStatement"; + body: Statement; + test: Expression; +} & Span; + +export type WhileStatement = { + type: "WhileStatement"; + test: Expression; + body: Statement; +} & Span; + +export type ForStatement = { + type: "ForStatement"; + init: ForStatementInit | null; + test: Expression | null; + update: Expression | null; + body: Statement; +} & Span; + +export type ForStatementInit = + | VariableDeclaration + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type ForInStatement = { + type: "ForInStatement"; + left: ForStatementLeft; + right: Expression; + body: Statement; +} & Span; + +export type ForStatementLeft = + | VariableDeclaration + | IdentifierReference + | TSAsExpression + | TSSatisfiesExpression + | TSNonNullExpression + | TSTypeAssertion + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression + | ArrayAssignmentTarget + | ObjectAssignmentTarget; + +export type ForOfStatement = { + type: "ForOfStatement"; + await: boolean; + left: ForStatementLeft; + right: Expression; + body: Statement; +} & Span; + +export type ContinueStatement = { + type: "ContinueStatement"; + label: LabelIdentifier | null; +} & Span; + +export type BreakStatement = { + type: "BreakStatement"; + label: LabelIdentifier | null; +} & Span; + +export type ReturnStatement = { + type: "ReturnStatement"; + argument: Expression | null; +} & Span; + +export type WithStatement = { + type: "WithStatement"; + object: Expression; + body: Statement; +} & Span; + +export type SwitchStatement = { + type: "SwitchStatement"; + discriminant: Expression; + cases: Array; +} & Span; + +export type SwitchCase = { + type: "SwitchCase"; + test: Expression | null; + consequent: Array; +} & Span; + +export type LabeledStatement = { + type: "LabeledStatement"; + label: LabelIdentifier; + body: Statement; +} & Span; + +export type ThrowStatement = { + type: "ThrowStatement"; + argument: Expression; +} & Span; + +export type TryStatement = { + type: "TryStatement"; + block: BlockStatement; + handler: CatchClause | null; + finalizer: BlockStatement | null; +} & Span; + +export type CatchClause = { + type: "CatchClause"; + param: CatchParameter | null; + body: BlockStatement; +} & Span; + +export type CatchParameter = { + type: "CatchParameter"; + pattern: BindingPattern; +} & Span; + +export type DebuggerStatement = { + type: "DebuggerStatement"; +} & Span; + +export type BindingPattern = { + typeAnnotation: TSTypeAnnotation | null; + optional: boolean; +} & (BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern); + +export type BindingPatternKind = + | BindingIdentifier + | ObjectPattern + | ArrayPattern + | AssignmentPattern; + +export type AssignmentPattern = { + type: "AssignmentPattern"; + left: BindingPattern; + right: Expression; +} & Span; + +export type BindingProperty = { + type: "BindingProperty"; + key: PropertyKey; + value: BindingPattern; + shorthand: boolean; + computed: boolean; +} & Span; + +export type BindingRestElement = { + type: "RestElement"; + argument: BindingPattern; +} & Span; + +export type Function = { + type: FunctionType; + id: BindingIdentifier | null; + generator: boolean; + async: boolean; + declare: boolean; + typeParameters: TSTypeParameterDeclaration | null; + thisParam: TSThisParameter | null; + params: FormalParameters; + returnType: TSTypeAnnotation | null; + body: FunctionBody | null; +} & Span; + +export type FunctionType = + | "FunctionDeclaration" + | "FunctionExpression" + | "TSDeclareFunction" + | "TSEmptyBodyFunctionExpression"; + +export type FormalParameter = { + type: "FormalParameter"; + decorators: Array; + pattern: BindingPattern; + accessibility: TSAccessibility | null; + readonly: boolean; + override: boolean; +} & Span; + +export type FormalParameterKind = + | "FormalParameter" + | "UniqueFormalParameters" + | "ArrowFormalParameters" + | "Signature"; + +export type FunctionBody = { + type: "FunctionBody"; + directives: Array; + statements: Array; +} & Span; + +export type ArrowFunctionExpression = { + type: "ArrowFunctionExpression"; + expression: boolean; + async: boolean; + typeParameters: TSTypeParameterDeclaration | null; + params: FormalParameters; + returnType: TSTypeAnnotation | null; + body: FunctionBody; +} & Span; + +export type YieldExpression = { + type: "YieldExpression"; + delegate: boolean; + argument: Expression | null; +} & Span; + +export type Class = { + type: ClassType; + decorators: Array; + id: BindingIdentifier | null; + typeParameters: TSTypeParameterDeclaration | null; + superClass: Expression | null; + superTypeParameters: TSTypeParameterInstantiation | null; + implements: Array | null; + body: ClassBody; + abstract: boolean; + declare: boolean; +} & Span; + +export type ClassType = "ClassDeclaration" | "ClassExpression"; + +export type ClassBody = { + type: "ClassBody"; + body: Array; +} & Span; + +export type ClassElement = + | StaticBlock + | MethodDefinition + | PropertyDefinition + | AccessorProperty + | TSIndexSignature; + +export type MethodDefinition = { + type: MethodDefinitionType; + decorators: Array; + key: PropertyKey; + value: Function; + kind: MethodDefinitionKind; + computed: boolean; + static: boolean; + override: boolean; + optional: boolean; + accessibility: TSAccessibility | null; +} & Span; + +export type MethodDefinitionType = + | "MethodDefinition" + | "TSAbstractMethodDefinition"; + +export type PropertyDefinition = { + type: PropertyDefinitionType; + decorators: Array; + key: PropertyKey; + value: Expression | null; + computed: boolean; + static: boolean; + declare: boolean; + override: boolean; + optional: boolean; + definite: boolean; + readonly: boolean; + typeAnnotation: TSTypeAnnotation | null; + accessibility: TSAccessibility | null; +} & Span; + +export type PropertyDefinitionType = + | "PropertyDefinition" + | "TSAbstractPropertyDefinition"; + +export type MethodDefinitionKind = "constructor" | "method" | "get" | "set"; + +export type PrivateIdentifier = { + type: "PrivateIdentifier"; + name: string; +} & Span; + +export type StaticBlock = { + type: "StaticBlock"; + body: Array; +} & Span; + +export type ModuleDeclaration = + | ImportDeclaration + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | TSExportAssignment + | TSNamespaceExportDeclaration; + +export type AccessorPropertyType = + | "AccessorProperty" + | "TSAbstractAccessorProperty"; + +export type AccessorProperty = { + type: AccessorPropertyType; + decorators: Array; + key: PropertyKey; + value: Expression | null; + computed: boolean; + static: boolean; + definite: boolean; + typeAnnotation: TSTypeAnnotation | null; + accessibility: TSAccessibility | null; +} & Span; + +export type ImportExpression = { + type: "ImportExpression"; + source: Expression; + arguments: Array; +} & Span; + +export type ImportDeclaration = { + type: "ImportDeclaration"; + specifiers: Array | null; + source: StringLiteral; + withClause: WithClause | null; + importKind: ImportOrExportKind; +} & Span; + +export type ImportDeclarationSpecifier = + | ImportSpecifier + | ImportDefaultSpecifier + | ImportNamespaceSpecifier; + +export type ImportSpecifier = { + type: "ImportSpecifier"; + imported: ModuleExportName; + local: BindingIdentifier; + importKind: ImportOrExportKind; +} & Span; + +export type ImportDefaultSpecifier = { + type: "ImportDefaultSpecifier"; + local: BindingIdentifier; +} & Span; + +export type ImportNamespaceSpecifier = { + type: "ImportNamespaceSpecifier"; + local: BindingIdentifier; +} & Span; + +export type WithClause = { + type: "WithClause"; + attributesKeyword: IdentifierName; + withEntries: Array; +} & Span; + +export type ImportAttribute = { + type: "ImportAttribute"; + key: ImportAttributeKey; + value: StringLiteral; +} & Span; + +export type ImportAttributeKey = IdentifierName | StringLiteral; + +export type ExportNamedDeclaration = { + type: "ExportNamedDeclaration"; + declaration: Declaration | null; + specifiers: Array; + source: StringLiteral | null; + exportKind: ImportOrExportKind; + withClause: WithClause | null; +} & Span; + +export type ExportDefaultDeclaration = { + type: "ExportDefaultDeclaration"; + declaration: ExportDefaultDeclarationKind; + exported: ModuleExportName; +} & Span; + +export type ExportAllDeclaration = { + type: "ExportAllDeclaration"; + exported: ModuleExportName | null; + source: StringLiteral; + withClause: WithClause | null; + exportKind: ImportOrExportKind; +} & Span; + +export type ExportSpecifier = { + type: "ExportSpecifier"; + local: ModuleExportName; + exported: ModuleExportName; + exportKind: ImportOrExportKind; +} & Span; + +export type ExportDefaultDeclarationKind = + | Function + | Class + | TSInterfaceDeclaration + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type ModuleExportName = + | IdentifierName + | IdentifierReference + | StringLiteral; + +export type TSThisParameter = { + type: "TSThisParameter"; + thisSpan: Span; + typeAnnotation: TSTypeAnnotation | null; +} & Span; + +export type TSEnumDeclaration = { + type: "TSEnumDeclaration"; + id: BindingIdentifier; + members: Array; + const: boolean; + declare: boolean; +} & Span; + +export type TSEnumMember = { + type: "TSEnumMember"; + id: TSEnumMemberName; + initializer: Expression | null; +} & Span; + +export type TSEnumMemberName = + | IdentifierName + | StringLiteral + | TemplateLiteral + | NumericLiteral + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type TSTypeAnnotation = { + type: "TSTypeAnnotation"; + typeAnnotation: TSType; +} & Span; + +export type TSLiteralType = { + type: "TSLiteralType"; + literal: TSLiteral; +} & Span; + +export type TSLiteral = + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | UnaryExpression; + +export type TSType = + | TSAnyKeyword + | TSBigIntKeyword + | TSBooleanKeyword + | TSIntrinsicKeyword + | TSNeverKeyword + | TSNullKeyword + | TSNumberKeyword + | TSObjectKeyword + | TSStringKeyword + | TSSymbolKeyword + | TSUndefinedKeyword + | TSUnknownKeyword + | TSVoidKeyword + | TSArrayType + | TSConditionalType + | TSConstructorType + | TSFunctionType + | TSImportType + | TSIndexedAccessType + | TSInferType + | TSIntersectionType + | TSLiteralType + | TSMappedType + | TSNamedTupleMember + | TSQualifiedName + | TSTemplateLiteralType + | TSThisType + | TSTupleType + | TSTypeLiteral + | TSTypeOperator + | TSTypePredicate + | TSTypeQuery + | TSTypeReference + | TSUnionType + | TSParenthesizedType + | JSDocNullableType + | JSDocNonNullableType + | JSDocUnknownType; + +export type TSConditionalType = { + type: "TSConditionalType"; + checkType: TSType; + extendsType: TSType; + trueType: TSType; + falseType: TSType; +} & Span; + +export type TSUnionType = { + type: "TSUnionType"; + types: Array; +} & Span; + +export type TSIntersectionType = { + type: "TSIntersectionType"; + types: Array; +} & Span; + +export type TSParenthesizedType = { + type: "TSParenthesizedType"; + typeAnnotation: TSType; +} & Span; + +export type TSTypeOperator = { + type: "TSTypeOperator"; + operator: TSTypeOperatorOperator; + typeAnnotation: TSType; +} & Span; + +export type TSTypeOperatorOperator = "keyof" | "unique" | "readonly"; + +export type TSArrayType = { + type: "TSArrayType"; + elementType: TSType; +} & Span; + +export type TSIndexedAccessType = { + type: "TSIndexedAccessType"; + objectType: TSType; + indexType: TSType; +} & Span; + +export type TSTupleType = { + type: "TSTupleType"; + elementTypes: Array; +} & Span; + +export type TSNamedTupleMember = { + type: "TSNamedTupleMember"; + elementType: TSTupleElement; + label: IdentifierName; + optional: boolean; +} & Span; + +export type TSOptionalType = { + type: "TSOptionalType"; + typeAnnotation: TSType; +} & Span; + +export type TSRestType = { + type: "TSRestType"; + typeAnnotation: TSType; +} & Span; + +export type TSTupleElement = + | TSOptionalType + | TSRestType + | TSAnyKeyword + | TSBigIntKeyword + | TSBooleanKeyword + | TSIntrinsicKeyword + | TSNeverKeyword + | TSNullKeyword + | TSNumberKeyword + | TSObjectKeyword + | TSStringKeyword + | TSSymbolKeyword + | TSUndefinedKeyword + | TSUnknownKeyword + | TSVoidKeyword + | TSArrayType + | TSConditionalType + | TSConstructorType + | TSFunctionType + | TSImportType + | TSIndexedAccessType + | TSInferType + | TSIntersectionType + | TSLiteralType + | TSMappedType + | TSNamedTupleMember + | TSQualifiedName + | TSTemplateLiteralType + | TSThisType + | TSTupleType + | TSTypeLiteral + | TSTypeOperator + | TSTypePredicate + | TSTypeQuery + | TSTypeReference + | TSUnionType + | TSParenthesizedType + | JSDocNullableType + | JSDocNonNullableType + | JSDocUnknownType; + +export type TSAnyKeyword = { + type: "TSAnyKeyword"; +} & Span; + +export type TSStringKeyword = { + type: "TSStringKeyword"; +} & Span; + +export type TSBooleanKeyword = { + type: "TSBooleanKeyword"; +} & Span; + +export type TSNumberKeyword = { + type: "TSNumberKeyword"; +} & Span; + +export type TSNeverKeyword = { + type: "TSNeverKeyword"; +} & Span; + +export type TSIntrinsicKeyword = { + type: "TSIntrinsicKeyword"; +} & Span; + +export type TSUnknownKeyword = { + type: "TSUnknownKeyword"; +} & Span; + +export type TSNullKeyword = { + type: "TSNullKeyword"; +} & Span; + +export type TSUndefinedKeyword = { + type: "TSUndefinedKeyword"; +} & Span; + +export type TSVoidKeyword = { + type: "TSVoidKeyword"; +} & Span; + +export type TSSymbolKeyword = { + type: "TSSymbolKeyword"; +} & Span; + +export type TSThisType = { + type: "TSThisType"; +} & Span; + +export type TSObjectKeyword = { + type: "TSObjectKeyword"; +} & Span; + +export type TSBigIntKeyword = { + type: "TSBigIntKeyword"; +} & Span; + +export type TSTypeReference = { + type: "TSTypeReference"; + typeName: TSTypeName; + typeParameters: TSTypeParameterInstantiation | null; +} & Span; + +export type TSTypeName = IdentifierReference | TSQualifiedName; + +export type TSQualifiedName = { + type: "TSQualifiedName"; + left: TSTypeName; + right: IdentifierName; +} & Span; + +export type TSTypeParameterInstantiation = { + type: "TSTypeParameterInstantiation"; + params: Array; +} & Span; + +export type TSTypeParameter = { + type: "TSTypeParameter"; + name: BindingIdentifier; + constraint: TSType | null; + default: TSType | null; + in: boolean; + out: boolean; + const: boolean; +} & Span; + +export type TSTypeParameterDeclaration = { + type: "TSTypeParameterDeclaration"; + params: Array; +} & Span; + +export type TSTypeAliasDeclaration = { + type: "TSTypeAliasDeclaration"; + id: BindingIdentifier; + typeParameters: TSTypeParameterDeclaration | null; + typeAnnotation: TSType; + declare: boolean; +} & Span; + +export type TSAccessibility = "private" | "protected" | "public"; + +export type TSClassImplements = { + type: "TSClassImplements"; + expression: TSTypeName; + typeParameters: TSTypeParameterInstantiation | null; +} & Span; + +export type TSInterfaceDeclaration = { + type: "TSInterfaceDeclaration"; + id: BindingIdentifier; + extends: Array | null; + typeParameters: TSTypeParameterDeclaration | null; + body: TSInterfaceBody; + declare: boolean; +} & Span; + +export type TSInterfaceBody = { + type: "TSInterfaceBody"; + body: Array; +} & Span; + +export type TSPropertySignature = { + type: "TSPropertySignature"; + computed: boolean; + optional: boolean; + readonly: boolean; + key: PropertyKey; + typeAnnotation: TSTypeAnnotation | null; +} & Span; + +export type TSSignature = + | TSIndexSignature + | TSPropertySignature + | TSCallSignatureDeclaration + | TSConstructSignatureDeclaration + | TSMethodSignature; + +export type TSIndexSignature = { + type: "TSIndexSignature"; + parameters: Array; + typeAnnotation: TSTypeAnnotation; + readonly: boolean; +} & Span; + +export type TSCallSignatureDeclaration = { + type: "TSCallSignatureDeclaration"; + thisParam: TSThisParameter | null; + params: FormalParameters; + returnType: TSTypeAnnotation | null; + typeParameters: TSTypeParameterDeclaration | null; +} & Span; + +export type TSMethodSignatureKind = "method" | "get" | "set"; + +export type TSMethodSignature = { + type: "TSMethodSignature"; + key: PropertyKey; + computed: boolean; + optional: boolean; + kind: TSMethodSignatureKind; + thisParam: TSThisParameter | null; + params: FormalParameters; + returnType: TSTypeAnnotation | null; + typeParameters: TSTypeParameterDeclaration | null; +} & Span; + +export type TSConstructSignatureDeclaration = { + type: "TSConstructSignatureDeclaration"; + params: FormalParameters; + returnType: TSTypeAnnotation | null; + typeParameters: TSTypeParameterDeclaration | null; +} & Span; + +export type TSIndexSignatureName = { + type: "Identifier"; + name: string; + typeAnnotation: TSTypeAnnotation; +} & Span; + +export type TSInterfaceHeritage = { + type: "TSInterfaceHeritage"; + expression: Expression; + typeParameters: TSTypeParameterInstantiation | null; +} & Span; + +export type TSTypePredicate = { + type: "TSTypePredicate"; + parameterName: TSTypePredicateName; + asserts: boolean; + typeAnnotation: TSTypeAnnotation | null; +} & Span; + +export type TSTypePredicateName = IdentifierName | TSThisType; + +export type TSModuleDeclaration = { + type: "TSModuleDeclaration"; + id: TSModuleDeclarationName; + body: TSModuleDeclarationBody | null; + kind: TSModuleDeclarationKind; + declare: boolean; +} & Span; + +export type TSModuleDeclarationKind = "global" | "module" | "namespace"; + +export type TSModuleDeclarationName = BindingIdentifier | StringLiteral; + +export type TSModuleDeclarationBody = TSModuleDeclaration | TSModuleBlock; + +export type TSTypeLiteral = { + type: "TSTypeLiteral"; + members: Array; +} & Span; + +export type TSInferType = { + type: "TSInferType"; + typeParameter: TSTypeParameter; +} & Span; + +export type TSTypeQuery = { + type: "TSTypeQuery"; + exprName: TSTypeQueryExprName; + typeParameters: TSTypeParameterInstantiation | null; +} & Span; + +export type TSTypeQueryExprName = + | TSImportType + | IdentifierReference + | TSQualifiedName; + +export type TSImportType = { + type: "TSImportType"; + isTypeOf: boolean; + parameter: TSType; + qualifier: TSTypeName | null; + attributes: TSImportAttributes | null; + typeParameters: TSTypeParameterInstantiation | null; +} & Span; + +export type TSImportAttributes = { + type: "TSImportAttributes"; + attributesKeyword: IdentifierName; + elements: Array; +} & Span; + +export type TSImportAttribute = { + type: "TSImportAttribute"; + name: TSImportAttributeName; + value: Expression; +} & Span; + +export type TSImportAttributeName = IdentifierName | StringLiteral; + +export type TSFunctionType = { + type: "TSFunctionType"; + thisParam: TSThisParameter | null; + params: FormalParameters; + returnType: TSTypeAnnotation; + typeParameters: TSTypeParameterDeclaration | null; +} & Span; + +export type TSConstructorType = { + type: "TSConstructorType"; + abstract: boolean; + params: FormalParameters; + returnType: TSTypeAnnotation; + typeParameters: TSTypeParameterDeclaration | null; +} & Span; + +export type TSMappedType = { + type: "TSMappedType"; + typeParameter: TSTypeParameter; + nameType: TSType | null; + typeAnnotation: TSType | null; + optional: TSMappedTypeModifierOperator; + readonly: TSMappedTypeModifierOperator; +} & Span; + +export type TSMappedTypeModifierOperator = "true" | "+" | "-" | "none"; + +export type TSTemplateLiteralType = { + type: "TSTemplateLiteralType"; + quasis: Array; + types: Array; +} & Span; + +export type TSAsExpression = { + type: "TSAsExpression"; + expression: Expression; + typeAnnotation: TSType; +} & Span; + +export type TSSatisfiesExpression = { + type: "TSSatisfiesExpression"; + expression: Expression; + typeAnnotation: TSType; +} & Span; + +export type TSTypeAssertion = { + type: "TSTypeAssertion"; + expression: Expression; + typeAnnotation: TSType; +} & Span; + +export type TSImportEqualsDeclaration = { + type: "TSImportEqualsDeclaration"; + id: BindingIdentifier; + moduleReference: TSModuleReference; + importKind: ImportOrExportKind; +} & Span; + +export type TSModuleReference = + | TSExternalModuleReference + | IdentifierReference + | TSQualifiedName; + +export type TSExternalModuleReference = { + type: "TSExternalModuleReference"; + expression: StringLiteral; +} & Span; + +export type TSNonNullExpression = { + type: "TSNonNullExpression"; + expression: Expression; +} & Span; + +export type Decorator = { + type: "Decorator"; + expression: Expression; +} & Span; + +export type TSExportAssignment = { + type: "TSExportAssignment"; + expression: Expression; +} & Span; + +export type TSNamespaceExportDeclaration = { + type: "TSNamespaceExportDeclaration"; + id: IdentifierName; +} & Span; + +export type TSInstantiationExpression = { + type: "TSInstantiationExpression"; + expression: Expression; + typeParameters: TSTypeParameterInstantiation; +} & Span; + +export type ImportOrExportKind = "value" | "type"; + +export type JSDocNullableType = { + type: "JSDocNullableType"; + typeAnnotation: TSType; + postfix: boolean; +} & Span; + +export type JSDocNonNullableType = { + type: "JSDocNonNullableType"; + typeAnnotation: TSType; + postfix: boolean; +} & Span; + +export type JSDocUnknownType = { + type: "JSDocUnknownType"; +} & Span; + +export type JSXElement = { + type: "JSXElement"; + openingElement: JSXOpeningElement; + closingElement: JSXClosingElement | null; + children: Array; +} & Span; + +export type JSXOpeningElement = { + type: "JSXOpeningElement"; + selfClosing: boolean; + name: JSXElementName; + attributes: Array; + typeParameters: TSTypeParameterInstantiation | null; +} & Span; + +export type JSXClosingElement = { + type: "JSXClosingElement"; + name: JSXElementName; +} & Span; + +export type JSXFragment = { + type: "JSXFragment"; + openingFragment: JSXOpeningFragment; + closingFragment: JSXClosingFragment; + children: Array; +} & Span; + +export type JSXOpeningFragment = { + type: "JSXOpeningFragment"; +} & Span; + +export type JSXClosingFragment = { + type: "JSXClosingFragment"; +} & Span; + +export type JSXNamespacedName = { + type: "JSXNamespacedName"; + namespace: JSXIdentifier; + property: JSXIdentifier; +} & Span; + +export type JSXMemberExpression = { + type: "JSXMemberExpression"; + object: JSXMemberExpressionObject; + property: JSXIdentifier; +} & Span; + +export type JSXExpressionContainer = { + type: "JSXExpressionContainer"; + expression: JSXExpression; +} & Span; + +export type JSXExpression = + | JSXEmptyExpression + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export type JSXEmptyExpression = { + type: "JSXEmptyExpression"; +} & Span; + +export type JSXAttributeItem = JSXAttribute | JSXSpreadAttribute; + +export type JSXAttribute = { + type: "JSXAttribute"; + name: JSXAttributeName; + value: JSXAttributeValue | null; +} & Span; + +export type JSXSpreadAttribute = { + type: "JSXSpreadAttribute"; + argument: Expression; +} & Span; + +export type JSXAttributeName = JSXIdentifier | JSXNamespacedName; + +export type JSXAttributeValue = + | StringLiteral + | JSXExpressionContainer + | JSXElement + | JSXFragment; + +export type JSXIdentifier = { + type: "JSXIdentifier"; + name: string; +} & Span; + +export type JSXChild = + | JSXText + | JSXElement + | JSXFragment + | JSXExpressionContainer + | JSXSpreadChild; + +export type JSXSpreadChild = { + type: "JSXSpreadChild"; + expression: Expression; +} & Span; + +export type JSXText = { + type: "JSXText"; + value: string; +} & Span; + +export type AssignmentOperator = + | "=" + | "+=" + | "-=" + | "*=" + | "/=" + | "%=" + | "<<=" + | ">>=" + | ">>>=" + | "|=" + | "^=" + | "&=" + | "&&=" + | "||=" + | "??=" + | "**="; + +export type BinaryOperator = + | "==" + | "!=" + | "===" + | "!==" + | "<" + | "<=" + | ">" + | ">=" + | "<<" + | ">>" + | ">>>" + | "+" + | "-" + | "*" + | "/" + | "%" + | "|" + | "^" + | "&" + | "in" + | "instanceof" + | "**"; + +export type LogicalOperator = "||" | "&&" | "??"; + +export type UnaryOperator = + | "-" + | "+" + | "!" + | "~" + | "typeof" + | "void" + | "delete"; + +export type UpdateOperator = "++" | "--"; + +export type Span = { + type: "Span"; + start: number; + end: number; +}; + +export type SourceType = { + language: Language; + moduleKind: ModuleKind; + variant: LanguageVariant; +}; + +export type Language = "javascript" | "typescript" | "typescriptDefinition"; + +export type ModuleKind = "script" | "module" | "unambiguous"; + +export type LanguageVariant = "standard" | "jsx"; + +export type Pattern = { + type: "Pattern"; + body: Disjunction; +} & Span; + +export type Disjunction = { + type: "Disjunction"; + body: Array; +} & Span; + +export type Alternative = { + type: "Alternative"; + body: Array; +} & Span; + +export type Term = + | BoundaryAssertion + | LookAroundAssertion + | Quantifier + | Character + | Dot + | CharacterClassEscape + | UnicodePropertyEscape + | CharacterClass + | CapturingGroup + | IgnoreGroup + | IndexedReference + | NamedReference; + +export type BoundaryAssertion = { + type: "BoundaryAssertion"; + span: Span; + kind: BoundaryAssertionKind; +}; + +export type BoundaryAssertionKind = + | "start" + | "end" + | "boundary" + | "negativeBoundary"; + +export type LookAroundAssertion = { + type: "LookAroundAssertion"; + kind: LookAroundAssertionKind; + body: Disjunction; +} & Span; + +export type LookAroundAssertionKind = + | "lookahead" + | "negativeLookahead" + | "lookbehind" + | "negativeLookbehind"; + +export type Quantifier = { + type: "Quantifier"; + min: number; + max: number | null; + greedy: boolean; + body: Term; +} & Span; + +export type Character = { + type: "Character"; + kind: CharacterKind; + value: number; +} & Span; + +export type CharacterKind = + | "controlLetter" + | "hexadecimalEscape" + | "identifier" + | "null" + | "octal1" + | "octal2" + | "octal3" + | "singleEscape" + | "symbol" + | "unicodeEscape"; + +export type CharacterClassEscape = { + type: "CharacterClassEscape"; + kind: CharacterClassEscapeKind; +} & Span; + +export type CharacterClassEscapeKind = + | "d" + | "negativeD" + | "s" + | "negativeS" + | "w" + | "negativeW"; + +export type UnicodePropertyEscape = { + type: "UnicodePropertyEscape"; + negative: boolean; + strings: boolean; + name: string; + value: string | null; +} & Span; + +export type Dot = { + type: "Dot"; +} & Span; + +export type CharacterClass = { + type: "CharacterClass"; + negative: boolean; + strings: boolean; + kind: CharacterClassContentsKind; + body: Array; +} & Span; + +export type CharacterClassContentsKind = + | "union" + | "intersection" + | "subtraction"; + +export type CharacterClassContents = + | CharacterClassRange + | CharacterClassEscape + | UnicodePropertyEscape + | Character + | CharacterClass + | ClassStringDisjunction; + +export type CharacterClassRange = { + type: "CharacterClassRange"; + min: Character; + max: Character; +} & Span; + +export type ClassStringDisjunction = { + type: "ClassStringDisjunction"; + strings: boolean; + body: Array; +} & Span; + +export type ClassString = { + type: "ClassString"; + strings: boolean; + body: Array; +} & Span; + +export type CapturingGroup = { + type: "CapturingGroup"; + name: string | null; + body: Disjunction; +} & Span; + +export type IgnoreGroup = { + type: "IgnoreGroup"; + modifiers: Modifiers | null; + body: Disjunction; +} & Span; + +export type Modifiers = { + type: "Modifiers"; + enabling: Modifier | null; + disabling: Modifier | null; +} & Span; + +export type Modifier = { + type: "Modifier"; + ignoreCase: boolean; + multiline: boolean; + sticky: boolean; +}; + +export type IndexedReference = { + type: "IndexedReference"; + index: number; +} & Span; + +export type NamedReference = { + type: "NamedReference"; + name: string; +} & Span; diff --git a/tasks/ast_tools/src/generators/typescript.rs b/tasks/ast_tools/src/generators/typescript.rs index 5b3059a122582..fa385ddb6b991 100644 --- a/tasks/ast_tools/src/generators/typescript.rs +++ b/tasks/ast_tools/src/generators/typescript.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; +use convert_case::{Case, Casing}; use itertools::Itertools; use oxc_allocator::Allocator; use oxc_parser::{ParseOptions, Parser}; @@ -30,81 +31,84 @@ impl Generator for TypescriptGenerator { // Auto-generated code, DO NOT EDIT DIRECTLY!\n\n" ); - let type_map: HashMap = ctx - .schema() - .into_iter() - .filter_map(|def| { - let TypeDef::Struct(def) = def else { - return None; - }; - let Some(type_tag) = get_type_tag(def) else { - return None; - }; - Some((def.ident().to_string(), type_tag)) - }) - .collect(); - for def in ctx.schema() { + if !def.generates_derive("ESTree") { + continue; + } let type_def = match def { - TypeDef::Struct(it) => generate_struct(it, &type_map), - TypeDef::Enum(it) => generate_enum(it, &type_map), + TypeDef::Struct(it) => generate_struct(it), + TypeDef::Enum(it) => generate_enum(it), }; - - let ident = def.ident(); - contents.push_str(&format!("export type {ident} = {type_def}\n\n",)); + contents.push_str(&type_def); + contents.push_str("\n\n"); } GeneratorOutput::Raw(output(crate::TYPESCRIPT_PACKAGE, "types.d.ts"), contents) } } -fn generate_enum(def: &EnumDef, type_map: &HashMap) -> String { - if def.markers.estree.untagged { - def.all_variants() - .map(|var| { - let ident = var.ident().to_string(); - type_map.get(&ident).map_or_else(|| ident, |v| v.to_string()) - }) - .join(" | ") +// Untagged enums: "type Expression = BooleanLiteral | NullLiteral" +// Tagged enums: "type PropertyKind = 'init' | 'get' | 'set'" +fn generate_enum(def: &EnumDef) -> String { + let union = if def.markers.estree.untagged { + def.all_variants().map(|var| type_to_string(var.fields[0].typ.name())).join(" | ") } else { def.all_variants().map(|var| format!("'{}'", enum_variant_name(var, def))).join(" | ") - } + }; + let ident = def.ident(); + format!("export type {ident} = {union};") } -fn generate_struct(def: &StructDef, type_map: &HashMap) -> String { - let mut type_def = "{".to_string(); - let type_tag = type_map.get(&def.ident().to_string()); - if let Some(type_tag) = type_tag { - type_def.push_str(&format!("type: '{type_tag}';")); +fn generate_struct(def: &StructDef) -> String { + let ident = def.ident(); + let mut fields = String::new(); + let mut extends = vec![]; + + if let Some(type_tag) = get_type_tag(def) { + fields.push_str(&format!("\n\ttype: '{type_tag}';")); } + for field in &def.fields { if field.markers.derive_attributes.estree.skip { continue; } - let name = field.ident().expect("expected named field!").to_string(); - let name = name.strip_prefix("r#").map(ToString::to_string).unwrap_or(name); - let ty = type_to_string(field.typ.name(), type_map); - type_def.push_str(&format!("{name}: {ty};")); + let ty = match &field.markers.derive_attributes.tsify_type { + Some(ty) => ty.clone(), + None => type_to_string(field.typ.name()), + }; + + if field.markers.derive_attributes.estree.flatten { + extends.push(ty); + continue; + } + + let name = match &field.markers.derive_attributes.estree.rename { + Some(rename) => rename.to_string(), + None => field.name.clone().unwrap().to_case(Case::Camel), + }; + + fields.push_str(&format!("\n\t{name}: {ty};")); } - type_def.push('}'); - type_def + let extends = + if extends.is_empty() { String::new() } else { format!(" & {}", extends.join(" & ")) }; + format!("export type {ident} = ({{{fields}\n}}){extends};") } -fn type_to_string(ty: &TypeName, type_map: &HashMap) -> String { +fn type_to_string(ty: &TypeName) -> String { match ty { TypeName::Ident(ident) => match ident.as_str() { "f64" | "f32" | "usize" | "u64" | "u32" | "u16" | "u8" | "i64" | "i32" | "i16" | "i8" => "number", "bool" => "boolean", - "str" | "String" | "Atom" => "string", - ty => type_map.get(ty).map_or(ty, |v| v.as_str()), + "str" | "String" | "Atom" | "CompactStr" => "string", + ty => ty, } .to_string(), - TypeName::Vec(type_name) => format!("Array<{}>", type_to_string(type_name, type_map)), + TypeName::Vec(type_name) => format!("Array<{}>", type_to_string(type_name)), TypeName::Box(type_name) | TypeName::Ref(type_name) | TypeName::Complex(type_name) => { - type_to_string(type_name, type_map) + type_to_string(type_name) } - TypeName::Opt(type_name) => format!("({}) | null", type_to_string(type_name, type_map)), + TypeName::Opt(type_name) => format!("({}) | null", type_to_string(type_name)), } } diff --git a/tasks/ast_tools/src/markers.rs b/tasks/ast_tools/src/markers.rs index ea77337dcdc93..91cccdda9e960 100644 --- a/tasks/ast_tools/src/markers.rs +++ b/tasks/ast_tools/src/markers.rs @@ -75,6 +75,7 @@ pub struct ScopeMarkers { pub struct DeriveAttributes { pub clone_in: CloneInAttribute, pub estree: ESTreeFieldAttribute, + pub tsify_type: Option, } /// A enum representing the value passed in `#[clone_in(...)]` derive helper attribute. @@ -213,6 +214,18 @@ impl Parse for ESTreeFieldAttribute { } } +/// A struct representing the `#[tsify(type = "...")]` attribute. +pub struct TsifyAttribute(String); + +impl Parse for TsifyAttribute { + fn parse(input: ParseStream) -> Result { + input.parse::()?; + input.parse::()?; + let type_ = input.parse::()?; + Ok(Self(type_.value())) + } +} + /// A struct representing the `#[scope(...)]` attribute. #[derive(Debug, Default)] pub struct ScopeAttribute { @@ -355,8 +368,17 @@ where Ok(None) } } + fn try_parse_tsify_type(attr: &Attribute) -> crate::Result> { + if attr.path().is_ident("tsify") { + let arg = attr.parse_args_with(TsifyAttribute::parse).normalize()?; + Ok(Some(arg.0)) + } else { + Ok(None) + } + } let mut clone_in = None; let mut estree = None; + let mut tsify_type = None; for attr in attrs { if let Some(attr) = try_parse_clone_in(attr)? { assert!(clone_in.replace(attr).is_none(), "Duplicate `#[clone_in(...)]` attribute."); @@ -364,10 +386,17 @@ where if let Some(attr) = try_parse_estree(attr)? { assert!(estree.replace(attr).is_none(), "Duplicate `#[estree(...)]` attribute."); } + if let Some(attr) = try_parse_tsify_type(attr)? { + assert!( + tsify_type.replace(attr).is_none(), + "Duplicate `#[tsify(type = \"...\")]` attribute." + ); + } } Ok(DeriveAttributes { clone_in: clone_in.unwrap_or_default(), estree: estree.unwrap_or_default(), + tsify_type, }) } From 08c373118b8a97e9e27990de962a97981dbb6530 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Tue, 15 Oct 2024 23:49:31 -0700 Subject: [PATCH 14/28] Use wasm-bindgen for now --- .github/.generated_ast_watch_list.yml | 1 - Cargo.lock | 2 - crates/oxc_ast/src/ast/js.rs | 138 +- crates/oxc_ast/src/ast/jsx.rs | 25 - crates/oxc_ast/src/ast/literal.rs | 14 - crates/oxc_ast/src/ast/mod.rs | 2 - crates/oxc_ast/src/ast/ts.rs | 97 +- crates/oxc_ast/src/ast_impl/literal.rs | 3 - crates/oxc_ast/src/generated/derive_estree.rs | 561 +++++ crates/oxc_ast/src/serialize.rs | 7 +- crates/oxc_regular_expression/Cargo.toml | 5 - crates/oxc_regular_expression/src/ast.rs | 32 - .../src/generated/derive_estree.rs | 61 + crates/oxc_span/Cargo.toml | 3 +- .../oxc_span/src/generated/derive_estree.rs | 13 + crates/oxc_span/src/source_type/mod.rs | 9 - crates/oxc_span/src/span/mod.rs | 2 +- crates/oxc_span/src/span/types.rs | 6 - .../oxc_syntax/src/generated/derive_estree.rs | 11 + crates/oxc_syntax/src/operator.rs | 10 - npm/oxc-types/src/generated/types.d.ts | 2070 ----------------- tasks/ast_tools/src/derives/estree.rs | 107 +- tasks/ast_tools/src/generators/mod.rs | 4 +- tasks/ast_tools/src/generators/typescript.rs | 8 +- tasks/ast_tools/src/main.rs | 5 +- tasks/ast_tools/src/markers.rs | 15 +- tasks/ast_tools/src/schema/serialize.rs | 2 +- 27 files changed, 779 insertions(+), 2434 deletions(-) delete mode 100644 npm/oxc-types/src/generated/types.d.ts diff --git a/.github/.generated_ast_watch_list.yml b/.github/.generated_ast_watch_list.yml index b7a3c803c35d1..6b6d63d255f0e 100644 --- a/.github/.generated_ast_watch_list.yml +++ b/.github/.generated_ast_watch_list.yml @@ -31,6 +31,5 @@ src: - 'crates/oxc_ast/src/generated/ast_builder.rs' - 'crates/oxc_ast/src/generated/visit.rs' - 'crates/oxc_ast/src/generated/visit_mut.rs' - - 'npm/oxc-types/src/generated/types.d.ts' - 'tasks/ast_tools/src/**' - '.github/.generated_ast_watch_list.yml' diff --git a/Cargo.lock b/Cargo.lock index d096ed361a135..4ac4027ed27fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1873,7 +1873,6 @@ dependencies = [ "phf 0.11.2", "rustc-hash", "serde", - "tsify", "unicode-id-start", "wasm-bindgen", ] @@ -1947,7 +1946,6 @@ dependencies = [ "oxc_estree", "schemars", "serde", - "tsify", "wasm-bindgen", ] diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 1039888e1f69b..8cc1bfc2c9575 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -2,9 +2,6 @@ // They are purely markers for codegen used in `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Read [`macro@oxc_ast_macros::ast`] for more information. -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use std::cell::Cell; use oxc_allocator::{Box, CloneIn, Vec}; @@ -19,8 +16,6 @@ use oxc_syntax::{ scope::ScopeId, symbol::SymbolId, }; -#[cfg(feature = "serialize")] -use tsify::Tsify; use super::{macros::inherit_variants, *}; @@ -32,7 +27,6 @@ use super::{macros::inherit_variants, *}; )] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Program<'a> { #[estree(flatten)] pub span: Span, @@ -54,7 +48,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum Expression<'a> { /// See [`BooleanLiteral`] for AST node details. @@ -281,7 +274,6 @@ pub struct LabelIdentifier<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ThisExpression { #[estree(flatten)] pub span: Span, @@ -293,7 +285,6 @@ pub struct ThisExpression { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ArrayExpression<'a> { #[estree(flatten)] pub span: Span, @@ -345,7 +336,6 @@ pub struct Elision { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ObjectExpression<'a> { #[estree(flatten)] pub span: Span, @@ -359,7 +349,6 @@ pub struct ObjectExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ObjectPropertyKind<'a> { /// `a: 1` in `const obj = { a: 1 };` @@ -374,7 +363,6 @@ pub enum ObjectPropertyKind<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ObjectProperty<'a> { #[estree(flatten)] pub span: Span, @@ -396,7 +384,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum PropertyKey<'a> { /// `a` in `const obj = { a: 1 }; obj.a;` @@ -412,7 +399,6 @@ pub enum PropertyKey<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum PropertyKind { /// `a: 1` in `const obj = { a: 1 };` @@ -429,7 +415,6 @@ pub enum PropertyKind { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TemplateLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -443,7 +428,6 @@ pub struct TemplateLiteral<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TaggedTemplateExpression<'a> { #[estree(flatten)] pub span: Span, @@ -458,7 +442,6 @@ pub struct TaggedTemplateExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TemplateElement<'a> { #[estree(flatten)] pub span: Span, @@ -470,7 +453,6 @@ pub struct TemplateElement<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(no_type)] pub struct TemplateElementValue<'a> { /// A raw interpretation where backslashes do not have special meaning. @@ -490,7 +472,6 @@ pub struct TemplateElementValue<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum MemberExpression<'a> { /// `ar[0]` in `const ar = [1, 2]; ar[0];` @@ -518,7 +499,6 @@ pub use match_member_expression; #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ComputedMemberExpression<'a> { #[estree(flatten)] pub span: Span, @@ -533,7 +513,6 @@ pub struct ComputedMemberExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct StaticMemberExpression<'a> { #[estree(flatten)] pub span: Span, @@ -548,7 +527,6 @@ pub struct StaticMemberExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct PrivateFieldExpression<'a> { #[estree(flatten)] pub span: Span, @@ -576,7 +554,6 @@ pub struct PrivateFieldExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CallExpression<'a> { #[estree(flatten)] pub span: Span, @@ -601,7 +578,6 @@ pub struct CallExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct NewExpression<'a> { #[estree(flatten)] pub span: Span, @@ -616,7 +592,6 @@ pub struct NewExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct MetaProperty<'a> { #[estree(flatten)] pub span: Span, @@ -630,7 +605,6 @@ pub struct MetaProperty<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct SpreadElement<'a> { #[estree(flatten)] pub span: Span, @@ -647,7 +621,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum Argument<'a> { /// `...[1, 2]` in `const arr = [...[1, 2]];` @@ -663,7 +636,6 @@ pub enum Argument<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct UpdateExpression<'a> { #[estree(flatten)] pub span: Span, @@ -678,7 +650,6 @@ pub struct UpdateExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct UnaryExpression<'a> { #[estree(flatten)] pub span: Span, @@ -692,7 +663,6 @@ pub struct UnaryExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct BinaryExpression<'a> { #[estree(flatten)] pub span: Span, @@ -707,7 +677,6 @@ pub struct BinaryExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct PrivateInExpression<'a> { #[estree(flatten)] pub span: Span, @@ -722,7 +691,6 @@ pub struct PrivateInExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct LogicalExpression<'a> { #[estree(flatten)] pub span: Span, @@ -737,7 +705,6 @@ pub struct LogicalExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ConditionalExpression<'a> { #[estree(flatten)] pub span: Span, @@ -752,7 +719,6 @@ pub struct ConditionalExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct AssignmentExpression<'a> { #[estree(flatten)] pub span: Span, @@ -771,7 +737,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum AssignmentTarget<'a> { // `SimpleAssignmentTarget` variants added here by `inherit_variants!` macro @@ -790,7 +755,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum SimpleAssignmentTarget<'a> { AssignmentTargetIdentifier(Box<'a, IdentifierReference<'a>>) = 0, @@ -845,7 +809,6 @@ pub use match_simple_assignment_target; #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum AssignmentTargetPattern<'a> { ArrayAssignmentTarget(Box<'a, ArrayAssignmentTarget<'a>>) = 8, @@ -866,8 +829,8 @@ pub use match_assignment_target_pattern; /// Represents an array assignment target, which can include elements and a rest element. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] pub struct ArrayAssignmentTarget<'a> { #[estree(flatten)] pub span: Span, @@ -884,8 +847,8 @@ pub struct ArrayAssignmentTarget<'a> { /// Represents an object assignment target, which can include properties and a rest element. #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] pub struct ObjectAssignmentTarget<'a> { #[estree(flatten)] pub span: Span, @@ -918,7 +881,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum AssignmentTargetMaybeDefault<'a> { AssignmentTargetWithDefault(Box<'a, AssignmentTargetWithDefault<'a>>) = 16, @@ -930,7 +892,6 @@ pub enum AssignmentTargetMaybeDefault<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct AssignmentTargetWithDefault<'a> { #[estree(flatten)] pub span: Span, @@ -941,7 +902,6 @@ pub struct AssignmentTargetWithDefault<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum AssignmentTargetProperty<'a> { AssignmentTargetPropertyIdentifier(Box<'a, AssignmentTargetPropertyIdentifier<'a>>) = 0, @@ -954,7 +914,6 @@ pub enum AssignmentTargetProperty<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct AssignmentTargetPropertyIdentifier<'a> { #[estree(flatten)] pub span: Span, @@ -968,7 +927,6 @@ pub struct AssignmentTargetPropertyIdentifier<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct AssignmentTargetPropertyProperty<'a> { #[estree(flatten)] pub span: Span, @@ -982,7 +940,6 @@ pub struct AssignmentTargetPropertyProperty<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct SequenceExpression<'a> { #[estree(flatten)] pub span: Span, @@ -995,7 +952,6 @@ pub struct SequenceExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Super { #[estree(flatten)] pub span: Span, @@ -1007,7 +963,6 @@ pub struct Super { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct AwaitExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1020,7 +975,6 @@ pub struct AwaitExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ChainExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1036,7 +990,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ChainElement<'a> { CallExpression(Box<'a, CallExpression<'a>>) = 0, @@ -1051,7 +1004,6 @@ pub enum ChainElement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ParenthesizedExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1068,7 +1020,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum Statement<'a> { // Statements @@ -1103,7 +1054,6 @@ pub enum Statement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Directive<'a> { #[estree(flatten)] pub span: Span, @@ -1119,7 +1069,6 @@ pub struct Directive<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Hashbang<'a> { #[estree(flatten)] pub span: Span, @@ -1133,7 +1082,6 @@ pub struct Hashbang<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct BlockStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1147,7 +1095,6 @@ pub struct BlockStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum Declaration<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32, @@ -1184,7 +1131,6 @@ pub use match_declaration; #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct VariableDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1196,7 +1142,6 @@ pub struct VariableDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum VariableDeclarationKind { Var = 0, @@ -1218,7 +1163,6 @@ pub enum VariableDeclarationKind { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct VariableDeclarator<'a> { #[estree(flatten)] pub span: Span, @@ -1233,7 +1177,6 @@ pub struct VariableDeclarator<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct EmptyStatement { #[estree(flatten)] pub span: Span, @@ -1243,7 +1186,6 @@ pub struct EmptyStatement { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ExpressionStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1254,7 +1196,6 @@ pub struct ExpressionStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct IfStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1267,7 +1208,6 @@ pub struct IfStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct DoWhileStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1279,7 +1219,6 @@ pub struct DoWhileStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct WhileStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1292,7 +1231,6 @@ pub struct WhileStatement<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ForStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1314,7 +1252,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ForStatementInit<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 64, @@ -1328,7 +1265,6 @@ pub enum ForStatementInit<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ForInStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1349,7 +1285,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ForStatementLeft<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 16, @@ -1362,7 +1297,6 @@ pub enum ForStatementLeft<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ForOfStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1379,7 +1313,6 @@ pub struct ForOfStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ContinueStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1390,7 +1323,6 @@ pub struct ContinueStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct BreakStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1401,7 +1333,6 @@ pub struct BreakStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ReturnStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1412,7 +1343,6 @@ pub struct ReturnStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct WithStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1425,7 +1355,6 @@ pub struct WithStatement<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct SwitchStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1440,7 +1369,6 @@ pub struct SwitchStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct SwitchCase<'a> { #[estree(flatten)] pub span: Span, @@ -1452,7 +1380,6 @@ pub struct SwitchCase<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct LabeledStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1470,7 +1397,6 @@ pub struct LabeledStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ThrowStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1496,7 +1422,6 @@ pub struct ThrowStatement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TryStatement<'a> { #[estree(flatten)] pub span: Span, @@ -1525,7 +1450,6 @@ pub struct TryStatement<'a> { #[scope(flags(ScopeFlags::CatchClause))] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CatchClause<'a> { #[estree(flatten)] pub span: Span, @@ -1554,7 +1478,6 @@ pub struct CatchClause<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CatchParameter<'a> { #[estree(flatten)] pub span: Span, @@ -1572,7 +1495,6 @@ pub struct CatchParameter<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct DebuggerStatement { #[estree(flatten)] pub span: Span, @@ -1583,7 +1505,6 @@ pub struct DebuggerStatement { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(no_type)] pub struct BindingPattern<'a> { // serde(flatten) the attributes because estree has no `BindingPattern` @@ -1598,7 +1519,6 @@ pub struct BindingPattern<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum BindingPatternKind<'a> { /// `const a = 1` @@ -1617,7 +1537,6 @@ pub enum BindingPatternKind<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct AssignmentPattern<'a> { #[estree(flatten)] pub span: Span, @@ -1628,8 +1547,8 @@ pub struct AssignmentPattern<'a> { // See serializer in serialize.rs #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] pub struct ObjectPattern<'a> { #[estree(flatten)] pub span: Span, @@ -1642,7 +1561,6 @@ pub struct ObjectPattern<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct BindingProperty<'a> { #[estree(flatten)] pub span: Span, @@ -1655,8 +1573,8 @@ pub struct BindingProperty<'a> { // See serializer in serialize.rs #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] pub struct ArrayPattern<'a> { #[estree(flatten)] pub span: Span, @@ -1728,7 +1646,6 @@ pub struct BindingRestElement<'a> { )] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Function<'a> { pub r#type: FunctionType, #[estree(flatten)] @@ -1789,7 +1706,6 @@ pub struct Function<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum FunctionType { FunctionDeclaration = 0, FunctionExpression = 1, @@ -1802,8 +1718,8 @@ pub enum FunctionType { // See serializer in serialize.rs #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] pub struct FormalParameters<'a> { #[estree(flatten)] pub span: Span, @@ -1817,7 +1733,6 @@ pub struct FormalParameters<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct FormalParameter<'a> { #[estree(flatten)] pub span: Span, @@ -1831,7 +1746,6 @@ pub struct FormalParameter<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum FormalParameterKind { /// FormalParameter = 0, @@ -1847,7 +1761,6 @@ pub enum FormalParameterKind { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct FunctionBody<'a> { #[estree(flatten)] pub span: Span, @@ -1863,7 +1776,6 @@ pub struct FunctionBody<'a> { )] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ArrowFunctionExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1884,7 +1796,6 @@ pub struct ArrowFunctionExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct YieldExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1897,7 +1808,6 @@ pub struct YieldExpression<'a> { #[scope(flags(ScopeFlags::StrictMode))] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Class<'a> { pub r#type: ClassType, #[estree(flatten)] @@ -1969,7 +1879,6 @@ pub struct Class<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum ClassType { /// Class declaration statement /// ```ts @@ -1987,7 +1896,6 @@ pub enum ClassType { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ClassBody<'a> { #[estree(flatten)] pub span: Span, @@ -2015,7 +1923,6 @@ pub struct ClassBody<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ClassElement<'a> { StaticBlock(Box<'a, StaticBlock<'a>>) = 0, @@ -2039,7 +1946,6 @@ pub enum ClassElement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct MethodDefinition<'a> { /// Method definition type /// @@ -2067,7 +1973,6 @@ pub struct MethodDefinition<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum MethodDefinitionType { MethodDefinition = 0, TSAbstractMethodDefinition = 1, @@ -2076,7 +1981,6 @@ pub enum MethodDefinitionType { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct PropertyDefinition<'a> { pub r#type: PropertyDefinitionType, #[estree(flatten)] @@ -2157,7 +2061,6 @@ pub struct PropertyDefinition<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum PropertyDefinitionType { PropertyDefinition = 0, TSAbstractPropertyDefinition = 1, @@ -2166,7 +2069,6 @@ pub enum PropertyDefinitionType { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum MethodDefinitionKind { /// Class constructor @@ -2185,7 +2087,6 @@ pub enum MethodDefinitionKind { #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct PrivateIdentifier<'a> { #[estree(flatten)] pub span: Span, @@ -2209,7 +2110,6 @@ pub struct PrivateIdentifier<'a> { #[scope(flags(ScopeFlags::ClassStaticBlock))] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct StaticBlock<'a> { #[estree(flatten)] pub span: Span, @@ -2245,7 +2145,6 @@ pub struct StaticBlock<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ModuleDeclaration<'a> { /// `import hello from './world.js';` @@ -2282,7 +2181,6 @@ pub use match_module_declaration; #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum AccessorPropertyType { AccessorProperty = 0, TSAbstractAccessorProperty = 1, @@ -2299,7 +2197,6 @@ pub enum AccessorPropertyType { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct AccessorProperty<'a> { pub r#type: AccessorPropertyType, #[estree(flatten)] @@ -2342,7 +2239,6 @@ pub struct AccessorProperty<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ImportExpression<'a> { #[estree(flatten)] pub span: Span, @@ -2353,7 +2249,6 @@ pub struct ImportExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ImportDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -2369,7 +2264,6 @@ pub struct ImportDeclaration<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ImportDeclarationSpecifier<'a> { /// import {imported} from "source" @@ -2386,7 +2280,6 @@ pub enum ImportDeclarationSpecifier<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ImportSpecifier<'a> { #[estree(flatten)] pub span: Span, @@ -2416,7 +2309,6 @@ pub struct ImportSpecifier<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ImportDefaultSpecifier<'a> { #[estree(flatten)] pub span: Span, @@ -2433,7 +2325,6 @@ pub struct ImportDefaultSpecifier<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ImportNamespaceSpecifier<'a> { #[estree(flatten)] pub span: Span, @@ -2443,7 +2334,6 @@ pub struct ImportNamespaceSpecifier<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct WithClause<'a> { #[estree(flatten)] pub span: Span, @@ -2454,7 +2344,6 @@ pub struct WithClause<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ImportAttribute<'a> { #[estree(flatten)] pub span: Span, @@ -2465,7 +2354,6 @@ pub struct ImportAttribute<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ImportAttributeKey<'a> { Identifier(IdentifierName<'a>) = 0, @@ -2486,7 +2374,6 @@ pub enum ImportAttributeKey<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ExportNamedDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -2511,7 +2398,6 @@ pub struct ExportNamedDeclaration<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ExportDefaultDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -2531,7 +2417,6 @@ pub struct ExportDefaultDeclaration<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ExportAllDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -2557,7 +2442,6 @@ pub struct ExportAllDeclaration<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ExportSpecifier<'a> { #[estree(flatten)] pub span: Span, @@ -2575,7 +2459,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ExportDefaultDeclarationKind<'a> { #[visit(args(flags = ScopeFlags::Function))] @@ -2599,7 +2482,6 @@ pub enum ExportDefaultDeclarationKind<'a> { #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum ModuleExportName<'a> { IdentifierName(IdentifierName<'a>) = 0, diff --git a/crates/oxc_ast/src/ast/jsx.rs b/crates/oxc_ast/src/ast/jsx.rs index 6be9ce56e373e..289be4f57b4ff 100644 --- a/crates/oxc_ast/src/ast/jsx.rs +++ b/crates/oxc_ast/src/ast/jsx.rs @@ -4,15 +4,10 @@ // They are purely markers for codegen used in `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Read [`macro@oxc_ast_macros::ast`] for more information. -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use oxc_allocator::{Box, CloneIn, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; -#[cfg(feature = "serialize")] -use tsify::Tsify; use super::{inherit_variants, js::*, literal::*, ts::*}; @@ -38,7 +33,6 @@ use super::{inherit_variants, js::*, literal::*, ts::*}; #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXElement<'a> { #[estree(flatten)] pub span: Span, @@ -68,7 +62,6 @@ pub struct JSXElement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXOpeningElement<'a> { #[estree(flatten)] pub span: Span, @@ -101,7 +94,6 @@ pub struct JSXOpeningElement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXClosingElement<'a> { #[estree(flatten)] pub span: Span, @@ -119,7 +111,6 @@ pub struct JSXClosingElement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXFragment<'a> { #[estree(flatten)] pub span: Span, @@ -135,7 +126,6 @@ pub struct JSXFragment<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXOpeningFragment { #[estree(flatten)] pub span: Span, @@ -145,7 +135,6 @@ pub struct JSXOpeningFragment { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXClosingFragment { #[estree(flatten)] pub span: Span, @@ -179,7 +168,6 @@ pub enum JSXElementName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXNamespacedName<'a> { #[estree(flatten)] pub span: Span, @@ -207,7 +195,6 @@ pub struct JSXNamespacedName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXMemberExpression<'a> { #[estree(flatten)] pub span: Span, @@ -243,7 +230,6 @@ pub enum JSXMemberExpressionObject<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXExpressionContainer<'a> { #[estree(flatten)] pub span: Span, @@ -261,7 +247,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum JSXExpression<'a> { EmptyExpression(JSXEmptyExpression) = 64, @@ -274,7 +259,6 @@ pub enum JSXExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXEmptyExpression { #[estree(flatten)] pub span: Span, @@ -294,7 +278,6 @@ pub struct JSXEmptyExpression { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum JSXAttributeItem<'a> { /// A `key="value"` attribute @@ -317,7 +300,6 @@ pub enum JSXAttributeItem<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXAttribute<'a> { #[estree(flatten)] pub span: Span, @@ -339,7 +321,6 @@ pub struct JSXAttribute<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXSpreadAttribute<'a> { #[estree(flatten)] pub span: Span, @@ -364,7 +345,6 @@ pub struct JSXSpreadAttribute<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum JSXAttributeName<'a> { /// An attribute name without a namespace prefix, e.g. `foo` in `foo="bar"`. @@ -394,7 +374,6 @@ pub enum JSXAttributeName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum JSXAttributeValue<'a> { StringLiteral(Box<'a, StringLiteral<'a>>) = 0, @@ -411,7 +390,6 @@ pub enum JSXAttributeValue<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXIdentifier<'a> { #[estree(flatten)] pub span: Span, @@ -427,7 +405,6 @@ pub struct JSXIdentifier<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum JSXChild<'a> { /// `Some Text` @@ -448,7 +425,6 @@ pub enum JSXChild<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXSpreadChild<'a> { #[estree(flatten)] pub span: Span, @@ -469,7 +445,6 @@ pub struct JSXSpreadChild<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSXText<'a> { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_ast/src/ast/literal.rs b/crates/oxc_ast/src/ast/literal.rs index 4c1074f8c9d80..04da8bc414388 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -4,9 +4,6 @@ // They are purely markers for codegen used in `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Read [`macro@oxc_ast_macros::ast`] for more information. -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use std::hash::Hash; use bitflags::bitflags; @@ -16,8 +13,6 @@ use oxc_estree::ESTree; use oxc_regular_expression::ast::Pattern; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; use oxc_syntax::number::{BigintBase, NumberBase}; -#[cfg(feature = "serialize")] -use tsify::Tsify; /// Boolean literal /// @@ -25,7 +20,6 @@ use tsify::Tsify; #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct BooleanLiteral { #[estree(flatten)] pub span: Span, @@ -38,7 +32,6 @@ pub struct BooleanLiteral { #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct NullLiteral { #[estree(flatten)] pub span: Span, @@ -50,7 +43,6 @@ pub struct NullLiteral { #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct NumericLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -67,7 +59,6 @@ pub struct NumericLiteral<'a> { #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct BigIntLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -84,7 +75,6 @@ pub struct BigIntLiteral<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct RegExpLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -100,7 +90,6 @@ pub struct RegExpLiteral<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(no_type)] pub struct RegExp<'a> { /// The regex pattern between the slashes @@ -115,7 +104,6 @@ pub struct RegExp<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum RegExpPattern<'a> { /// Unparsed pattern. Contains string slice of the pattern. @@ -132,7 +120,6 @@ pub enum RegExpPattern<'a> { #[ast] #[derive(Debug, Clone)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(no_type)] pub struct EmptyObject; @@ -142,7 +129,6 @@ pub struct EmptyObject; #[ast(visit)] #[derive(Debug, Clone)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct StringLiteral<'a> { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_ast/src/ast/mod.rs b/crates/oxc_ast/src/ast/mod.rs index 3370e1c231408..5062d86cef55b 100644 --- a/crates/oxc_ast/src/ast/mod.rs +++ b/crates/oxc_ast/src/ast/mod.rs @@ -1,5 +1,3 @@ -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] //! AST Definitions //! //! # Enum inheritance diff --git a/crates/oxc_ast/src/ast/ts.rs b/crates/oxc_ast/src/ast/ts.rs index 5afdb79af9775..6be3effb93d8d 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -7,9 +7,6 @@ // They are purely markers for codegen used in `tasks/ast_tools` and `crates/oxc_traverse/scripts`. See docs in those crates. // Read [`macro@oxc_ast_macros::ast`] for more information. -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use std::cell::Cell; use oxc_allocator::{Box, CloneIn, Vec}; @@ -17,8 +14,6 @@ use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, GetSpanMut, Span}; use oxc_syntax::scope::ScopeId; -#[cfg(feature = "serialize")] -use tsify::Tsify; use super::{inherit_variants, js::*, jsx::*, literal::*}; @@ -35,7 +30,6 @@ use super::{inherit_variants, js::*, jsx::*, literal::*}; #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSThisParameter<'a> { #[estree(flatten)] pub span: Span, @@ -68,7 +62,6 @@ pub struct TSThisParameter<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSEnumDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -103,7 +96,6 @@ pub struct TSEnumDeclaration<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSEnumMember<'a> { #[estree(flatten)] pub span: Span, @@ -121,7 +113,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSEnumMemberName<'a> { StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64, @@ -150,7 +141,6 @@ pub enum TSEnumMemberName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeAnnotation<'a> { #[estree(flatten)] /// starts at the `:` token and ends at the end of the type annotation @@ -176,7 +166,6 @@ pub struct TSTypeAnnotation<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSLiteralType<'a> { #[estree(flatten)] pub span: Span, @@ -187,7 +176,6 @@ pub struct TSLiteralType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSLiteral<'a> { BooleanLiteral(Box<'a, BooleanLiteral>) = 0, @@ -214,7 +202,6 @@ pub enum TSLiteral<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSType<'a> { // Keyword @@ -323,7 +310,6 @@ pub use match_ts_type; #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSConditionalType<'a> { #[estree(flatten)] pub span: Span, @@ -354,7 +340,6 @@ pub struct TSConditionalType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSUnionType<'a> { #[estree(flatten)] pub span: Span, @@ -378,7 +363,6 @@ pub struct TSUnionType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSIntersectionType<'a> { #[estree(flatten)] pub span: Span, @@ -397,7 +381,6 @@ pub struct TSIntersectionType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSParenthesizedType<'a> { #[estree(flatten)] pub span: Span, @@ -416,7 +399,6 @@ pub struct TSParenthesizedType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeOperator<'a> { #[estree(flatten)] pub span: Span, @@ -429,7 +411,6 @@ pub struct TSTypeOperator<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum TSTypeOperatorOperator { Keyof = 0, @@ -451,7 +432,6 @@ pub enum TSTypeOperatorOperator { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSArrayType<'a> { #[estree(flatten)] pub span: Span, @@ -472,7 +452,6 @@ pub struct TSArrayType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSIndexedAccessType<'a> { #[estree(flatten)] pub span: Span, @@ -492,7 +471,6 @@ pub struct TSIndexedAccessType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTupleType<'a> { #[estree(flatten)] pub span: Span, @@ -512,7 +490,6 @@ pub struct TSTupleType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSNamedTupleMember<'a> { #[estree(flatten)] pub span: Span, @@ -533,7 +510,6 @@ pub struct TSNamedTupleMember<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSOptionalType<'a> { #[estree(flatten)] pub span: Span, @@ -551,7 +527,6 @@ pub struct TSOptionalType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSRestType<'a> { #[estree(flatten)] pub span: Span, @@ -569,7 +544,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSTupleElement<'a> { // Discriminants start at 64, so that `TSTupleElement::is_ts_type` is a single @@ -593,7 +567,6 @@ pub enum TSTupleElement<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSAnyKeyword { #[estree(flatten)] pub span: Span, @@ -611,7 +584,6 @@ pub struct TSAnyKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSStringKeyword { #[estree(flatten)] pub span: Span, @@ -629,7 +601,6 @@ pub struct TSStringKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSBooleanKeyword { #[estree(flatten)] pub span: Span, @@ -647,7 +618,6 @@ pub struct TSBooleanKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSNumberKeyword { #[estree(flatten)] pub span: Span, @@ -666,7 +636,6 @@ pub struct TSNumberKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSNeverKeyword { #[estree(flatten)] pub span: Span, @@ -685,7 +654,6 @@ pub struct TSNeverKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSIntrinsicKeyword { #[estree(flatten)] pub span: Span, @@ -705,7 +673,6 @@ pub struct TSIntrinsicKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSUnknownKeyword { #[estree(flatten)] pub span: Span, @@ -724,7 +691,6 @@ pub struct TSUnknownKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSNullKeyword { #[estree(flatten)] pub span: Span, @@ -745,7 +711,6 @@ pub struct TSNullKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSUndefinedKeyword { #[estree(flatten)] pub span: Span, @@ -754,7 +719,6 @@ pub struct TSUndefinedKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSVoidKeyword { #[estree(flatten)] pub span: Span, @@ -763,7 +727,6 @@ pub struct TSVoidKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSSymbolKeyword { #[estree(flatten)] pub span: Span, @@ -772,7 +735,6 @@ pub struct TSSymbolKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSThisType { #[estree(flatten)] pub span: Span, @@ -781,7 +743,6 @@ pub struct TSThisType { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSObjectKeyword { #[estree(flatten)] pub span: Span, @@ -790,7 +751,6 @@ pub struct TSObjectKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSBigIntKeyword { #[estree(flatten)] pub span: Span, @@ -807,7 +767,6 @@ pub struct TSBigIntKeyword { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeReference<'a> { #[estree(flatten)] pub span: Span, @@ -821,7 +780,6 @@ pub struct TSTypeReference<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSTypeName<'a> { IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, @@ -848,7 +806,6 @@ pub use match_ts_type_name; #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSQualifiedName<'a> { #[estree(flatten)] pub span: Span, @@ -859,7 +816,6 @@ pub struct TSQualifiedName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeParameterInstantiation<'a> { #[estree(flatten)] pub span: Span, @@ -886,7 +842,6 @@ pub struct TSTypeParameterInstantiation<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeParameter<'a> { #[estree(flatten)] pub span: Span, @@ -907,7 +862,6 @@ pub struct TSTypeParameter<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeParameterDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -926,7 +880,6 @@ pub struct TSTypeParameterDeclaration<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeAliasDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -944,7 +897,6 @@ pub struct TSTypeAliasDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum TSAccessibility { Private = 0, @@ -965,7 +917,6 @@ pub enum TSAccessibility { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSClassImplements<'a> { #[estree(flatten)] pub span: Span, @@ -992,7 +943,6 @@ pub struct TSClassImplements<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSInterfaceDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1015,7 +965,6 @@ pub struct TSInterfaceDeclaration<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSInterfaceBody<'a> { #[estree(flatten)] pub span: Span, @@ -1040,7 +989,6 @@ pub struct TSInterfaceBody<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSPropertySignature<'a> { #[estree(flatten)] pub span: Span, @@ -1054,7 +1002,6 @@ pub struct TSPropertySignature<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSSignature<'a> { TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0, @@ -1078,7 +1025,6 @@ pub enum TSSignature<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSIndexSignature<'a> { #[estree(flatten)] pub span: Span, @@ -1090,7 +1036,6 @@ pub struct TSIndexSignature<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSCallSignatureDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1103,7 +1048,6 @@ pub struct TSCallSignatureDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum TSMethodSignatureKind { Method = 0, @@ -1126,7 +1070,6 @@ pub enum TSMethodSignatureKind { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSMethodSignature<'a> { #[estree(flatten)] pub span: Span, @@ -1148,7 +1091,6 @@ pub struct TSMethodSignature<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSConstructSignatureDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1174,7 +1116,6 @@ pub struct TSIndexSignatureName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSInterfaceHeritage<'a> { #[estree(flatten)] pub span: Span, @@ -1205,7 +1146,6 @@ pub struct TSInterfaceHeritage<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypePredicate<'a> { #[estree(flatten)] pub span: Span, @@ -1224,7 +1164,6 @@ pub struct TSTypePredicate<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSTypePredicateName<'a> { Identifier(Box<'a, IdentifierName<'a>>) = 0, @@ -1264,7 +1203,6 @@ pub enum TSTypePredicateName<'a> { )] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSModuleDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1297,7 +1235,6 @@ pub struct TSModuleDeclaration<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum TSModuleDeclarationKind { /// `declare global {}` @@ -1331,7 +1268,6 @@ pub enum TSModuleDeclarationKind { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSModuleDeclarationName<'a> { Identifier(BindingIdentifier<'a>) = 0, @@ -1341,7 +1277,6 @@ pub enum TSModuleDeclarationName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSModuleDeclarationBody<'a> { TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0, @@ -1351,8 +1286,8 @@ pub enum TSModuleDeclarationBody<'a> { // See serializer in serialize.rs #[ast(visit)] #[derive(Debug)] -#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] pub struct TSModuleBlock<'a> { #[estree(flatten)] pub span: Span, @@ -1364,7 +1299,6 @@ pub struct TSModuleBlock<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeLiteral<'a> { #[estree(flatten)] pub span: Span, @@ -1387,7 +1321,6 @@ pub struct TSTypeLiteral<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSInferType<'a> { #[estree(flatten)] pub span: Span, @@ -1407,7 +1340,6 @@ pub struct TSInferType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeQuery<'a> { #[estree(flatten)] pub span: Span, @@ -1424,7 +1356,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSTypeQueryExprName<'a> { TSImportType(Box<'a, TSImportType<'a>>) = 2, @@ -1436,7 +1367,6 @@ pub enum TSTypeQueryExprName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSImportType<'a> { #[estree(flatten)] pub span: Span, @@ -1451,7 +1381,6 @@ pub struct TSImportType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSImportAttributes<'a> { #[estree(flatten)] pub span: Span, @@ -1462,7 +1391,6 @@ pub struct TSImportAttributes<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSImportAttribute<'a> { #[estree(flatten)] pub span: Span, @@ -1473,7 +1401,6 @@ pub struct TSImportAttribute<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSImportAttributeName<'a> { Identifier(IdentifierName<'a>) = 0, @@ -1491,7 +1418,6 @@ pub enum TSImportAttributeName<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSFunctionType<'a> { #[estree(flatten)] pub span: Span, @@ -1522,7 +1448,6 @@ pub struct TSFunctionType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSConstructorType<'a> { #[estree(flatten)] pub span: Span, @@ -1557,7 +1482,6 @@ pub struct TSConstructorType<'a> { #[scope] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSMappedType<'a> { #[estree(flatten)] pub span: Span, @@ -1597,7 +1521,6 @@ pub struct TSMappedType<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum TSMappedTypeModifierOperator { /// e.g. `?` in `{ [P in K]?: T }` @@ -1626,7 +1549,6 @@ pub enum TSMappedTypeModifierOperator { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTemplateLiteralType<'a> { #[estree(flatten)] pub span: Span, @@ -1639,7 +1561,6 @@ pub struct TSTemplateLiteralType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSAsExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1662,7 +1583,6 @@ pub struct TSAsExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSSatisfiesExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1675,7 +1595,6 @@ pub struct TSSatisfiesExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSTypeAssertion<'a> { #[estree(flatten)] pub span: Span, @@ -1686,7 +1605,6 @@ pub struct TSTypeAssertion<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSImportEqualsDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1704,7 +1622,6 @@ inherit_variants! { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum TSModuleReference<'a> { ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2, @@ -1716,7 +1633,6 @@ pub enum TSModuleReference<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSExternalModuleReference<'a> { #[estree(flatten)] pub span: Span, @@ -1726,7 +1642,6 @@ pub struct TSExternalModuleReference<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSNonNullExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1760,7 +1675,6 @@ pub struct TSNonNullExpression<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Decorator<'a> { #[estree(flatten)] pub span: Span, @@ -1773,7 +1687,6 @@ pub struct Decorator<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSExportAssignment<'a> { #[estree(flatten)] pub span: Span, @@ -1786,7 +1699,6 @@ pub struct TSExportAssignment<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSNamespaceExportDeclaration<'a> { #[estree(flatten)] pub span: Span, @@ -1796,7 +1708,6 @@ pub struct TSNamespaceExportDeclaration<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct TSInstantiationExpression<'a> { #[estree(flatten)] pub span: Span, @@ -1808,7 +1719,6 @@ pub struct TSInstantiationExpression<'a> { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum ImportOrExportKind { /// `import { foo } from './foo'`; @@ -1823,7 +1733,6 @@ pub enum ImportOrExportKind { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSDocNullableType<'a> { #[estree(flatten)] pub span: Span, @@ -1836,7 +1745,6 @@ pub struct JSDocNullableType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSDocNonNullableType<'a> { #[estree(flatten)] pub span: Span, @@ -1847,7 +1755,6 @@ pub struct JSDocNonNullableType<'a> { #[ast(visit)] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct JSDocUnknownType { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_ast/src/ast_impl/literal.rs b/crates/oxc_ast/src/ast_impl/literal.rs index 982fecdaed1d6..5f70ab317ab63 100644 --- a/crates/oxc_ast/src/ast_impl/literal.rs +++ b/crates/oxc_ast/src/ast_impl/literal.rs @@ -1,8 +1,5 @@ //! Literals -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use std::{ borrow::Cow, fmt, diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs index 0c6fa7c29b0c5..c0fe51e04a6b0 100644 --- a/crates/oxc_ast/src/generated/derive_estree.rs +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -29,6 +29,9 @@ impl Serialize for BooleanLiteral { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type BooleanLiteral = ({\n\ttype: 'BooleanLiteral';\n\tvalue: boolean;\n}) & Span;"; impl Serialize for NullLiteral { #[allow(clippy::match_same_arms, unused_mut)] @@ -42,6 +45,9 @@ impl Serialize for NullLiteral { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type NullLiteral = ({\n\ttype: 'NullLiteral';\n}) & Span;"; impl<'a> Serialize for NumericLiteral<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -57,6 +63,8 @@ impl<'a> Serialize for NumericLiteral<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type NumericLiteral = ({\n\ttype: 'NumericLiteral';\n\tvalue: number;\n\traw: string;\n}) & Span;"; impl<'a> Serialize for BigIntLiteral<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -71,6 +79,9 @@ impl<'a> Serialize for BigIntLiteral<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type BigIntLiteral = ({\n\ttype: 'BigIntLiteral';\n\traw: string;\n}) & Span;"; impl<'a> Serialize for RegExpLiteral<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -86,6 +97,8 @@ impl<'a> Serialize for RegExpLiteral<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type RegExpLiteral = ({\n\ttype: 'RegExpLiteral';\n\tvalue: EmptyObject;\n\tregex: RegExp;\n}) & Span;"; impl<'a> Serialize for RegExp<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -99,6 +112,9 @@ impl<'a> Serialize for RegExp<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type RegExp = ({\n\tpattern: RegExpPattern;\n\tflags: RegExpFlags;\n});"; impl<'a> Serialize for RegExpPattern<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -113,6 +129,8 @@ impl<'a> Serialize for RegExpPattern<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type RegExpPattern = string | string | Pattern;"; impl Serialize for EmptyObject { #[allow(clippy::match_same_arms, unused_mut)] @@ -124,6 +142,8 @@ impl Serialize for EmptyObject { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type EmptyObject = ({\n});"; impl<'a> Serialize for StringLiteral<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -138,6 +158,9 @@ impl<'a> Serialize for StringLiteral<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type StringLiteral = ({\n\ttype: 'StringLiteral';\n\tvalue: string;\n}) & Span;"; impl<'a> Serialize for Program<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -155,6 +178,8 @@ impl<'a> Serialize for Program<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Program = ({\n\ttype: 'Program';\n\tsourceType: SourceType;\n\thashbang: (Hashbang) | null;\n\tdirectives: Array;\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for Expression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -208,6 +233,8 @@ impl<'a> Serialize for Expression<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Expression = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for IdentifierName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -222,6 +249,9 @@ impl<'a> Serialize for IdentifierName<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type IdentifierName = ({\n\ttype: 'Identifier';\n\tname: string;\n}) & Span;"; impl<'a> Serialize for IdentifierReference<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -236,6 +266,9 @@ impl<'a> Serialize for IdentifierReference<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type IdentifierReference = ({\n\ttype: 'Identifier';\n\tname: string;\n}) & Span;"; impl<'a> Serialize for BindingIdentifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -250,6 +283,9 @@ impl<'a> Serialize for BindingIdentifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type BindingIdentifier = ({\n\ttype: 'Identifier';\n\tname: string;\n}) & Span;"; impl<'a> Serialize for LabelIdentifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -264,6 +300,9 @@ impl<'a> Serialize for LabelIdentifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type LabelIdentifier = ({\n\ttype: 'Identifier';\n\tname: string;\n}) & Span;"; impl Serialize for ThisExpression { #[allow(clippy::match_same_arms, unused_mut)] @@ -277,6 +316,9 @@ impl Serialize for ThisExpression { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type ThisExpression = ({\n\ttype: 'ThisExpression';\n}) & Span;"; impl<'a> Serialize for ArrayExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -291,6 +333,8 @@ impl<'a> Serialize for ArrayExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ArrayExpression = ({\n\ttype: 'ArrayExpression';\n\telements: Array;\n}) & Span;"; impl<'a> Serialize for ArrayExpressionElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -374,6 +418,8 @@ impl<'a> Serialize for ArrayExpressionElement<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ArrayExpressionElement = SpreadElement | Elision | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for ObjectExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -388,6 +434,8 @@ impl<'a> Serialize for ObjectExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ObjectExpression = ({\n\ttype: 'ObjectExpression';\n\tproperties: Array;\n}) & Span;"; impl<'a> Serialize for ObjectPropertyKind<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -401,6 +449,9 @@ impl<'a> Serialize for ObjectPropertyKind<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type ObjectPropertyKind = ObjectProperty | SpreadElement;"; impl<'a> Serialize for ObjectProperty<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -421,6 +472,8 @@ impl<'a> Serialize for ObjectProperty<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ObjectProperty = ({\n\ttype: 'ObjectProperty';\n\tkind: PropertyKind;\n\tkey: PropertyKey;\n\tvalue: Expression;\n\tinit: (Expression) | null;\n\tmethod: boolean;\n\tshorthand: boolean;\n\tcomputed: boolean;\n}) & Span;"; impl<'a> Serialize for PropertyKey<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -476,6 +529,8 @@ impl<'a> Serialize for PropertyKey<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type PropertyKey = IdentifierName | PrivateIdentifier | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl Serialize for PropertyKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -490,6 +545,8 @@ impl Serialize for PropertyKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type PropertyKind = 'init' | 'get' | 'set';"; impl<'a> Serialize for TemplateLiteral<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -505,6 +562,8 @@ impl<'a> Serialize for TemplateLiteral<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TemplateLiteral = ({\n\ttype: 'TemplateLiteral';\n\tquasis: Array;\n\texpressions: Array;\n}) & Span;"; impl<'a> Serialize for TaggedTemplateExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -521,6 +580,8 @@ impl<'a> Serialize for TaggedTemplateExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TaggedTemplateExpression = ({\n\ttype: 'TaggedTemplateExpression';\n\ttag: Expression;\n\tquasi: TemplateLiteral;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n}) & Span;"; impl<'a> Serialize for TemplateElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -536,6 +597,8 @@ impl<'a> Serialize for TemplateElement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TemplateElement = ({\n\ttype: 'TemplateElement';\n\ttail: boolean;\n\tvalue: TemplateElementValue;\n}) & Span;"; impl<'a> Serialize for TemplateElementValue<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -549,6 +612,9 @@ impl<'a> Serialize for TemplateElementValue<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TemplateElementValue = ({\n\traw: string;\n\tcooked: (string) | null;\n});"; impl<'a> Serialize for MemberExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -565,6 +631,8 @@ impl<'a> Serialize for MemberExpression<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type MemberExpression = ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for ComputedMemberExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -581,6 +649,8 @@ impl<'a> Serialize for ComputedMemberExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ComputedMemberExpression = ({\n\ttype: 'ComputedMemberExpression';\n\tobject: Expression;\n\texpression: Expression;\n\toptional: boolean;\n}) & Span;"; impl<'a> Serialize for StaticMemberExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -597,6 +667,8 @@ impl<'a> Serialize for StaticMemberExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type StaticMemberExpression = ({\n\ttype: 'StaticMemberExpression';\n\tobject: Expression;\n\tproperty: IdentifierName;\n\toptional: boolean;\n}) & Span;"; impl<'a> Serialize for PrivateFieldExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -613,6 +685,8 @@ impl<'a> Serialize for PrivateFieldExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type PrivateFieldExpression = ({\n\ttype: 'PrivateFieldExpression';\n\tobject: Expression;\n\tfield: PrivateIdentifier;\n\toptional: boolean;\n}) & Span;"; impl<'a> Serialize for CallExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -630,6 +704,8 @@ impl<'a> Serialize for CallExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CallExpression = ({\n\ttype: 'CallExpression';\n\tcallee: Expression;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n\targuments: Array;\n\toptional: boolean;\n}) & Span;"; impl<'a> Serialize for NewExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -646,6 +722,8 @@ impl<'a> Serialize for NewExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type NewExpression = ({\n\ttype: 'NewExpression';\n\tcallee: Expression;\n\targuments: Array;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n}) & Span;"; impl<'a> Serialize for MetaProperty<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -661,6 +739,8 @@ impl<'a> Serialize for MetaProperty<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type MetaProperty = ({\n\ttype: 'MetaProperty';\n\tmeta: IdentifierName;\n\tproperty: IdentifierName;\n}) & Span;"; impl<'a> Serialize for SpreadElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -675,6 +755,9 @@ impl<'a> Serialize for SpreadElement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type SpreadElement = ({\n\ttype: 'SpreadElement';\n\targument: Expression;\n}) & Span;"; impl<'a> Serialize for Argument<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -729,6 +812,8 @@ impl<'a> Serialize for Argument<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Argument = SpreadElement | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for UpdateExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -745,6 +830,8 @@ impl<'a> Serialize for UpdateExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type UpdateExpression = ({\n\ttype: 'UpdateExpression';\n\toperator: UpdateOperator;\n\tprefix: boolean;\n\targument: SimpleAssignmentTarget;\n}) & Span;"; impl<'a> Serialize for UnaryExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -760,6 +847,8 @@ impl<'a> Serialize for UnaryExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type UnaryExpression = ({\n\ttype: 'UnaryExpression';\n\toperator: UnaryOperator;\n\targument: Expression;\n}) & Span;"; impl<'a> Serialize for BinaryExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -776,6 +865,8 @@ impl<'a> Serialize for BinaryExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BinaryExpression = ({\n\ttype: 'BinaryExpression';\n\tleft: Expression;\n\toperator: BinaryOperator;\n\tright: Expression;\n}) & Span;"; impl<'a> Serialize for PrivateInExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -792,6 +883,8 @@ impl<'a> Serialize for PrivateInExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type PrivateInExpression = ({\n\ttype: 'PrivateInExpression';\n\tleft: PrivateIdentifier;\n\toperator: BinaryOperator;\n\tright: Expression;\n}) & Span;"; impl<'a> Serialize for LogicalExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -808,6 +901,8 @@ impl<'a> Serialize for LogicalExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type LogicalExpression = ({\n\ttype: 'LogicalExpression';\n\tleft: Expression;\n\toperator: LogicalOperator;\n\tright: Expression;\n}) & Span;"; impl<'a> Serialize for ConditionalExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -824,6 +919,8 @@ impl<'a> Serialize for ConditionalExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ConditionalExpression = ({\n\ttype: 'ConditionalExpression';\n\ttest: Expression;\n\tconsequent: Expression;\n\talternate: Expression;\n}) & Span;"; impl<'a> Serialize for AssignmentExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -840,6 +937,8 @@ impl<'a> Serialize for AssignmentExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentExpression = ({\n\ttype: 'AssignmentExpression';\n\toperator: AssignmentOperator;\n\tleft: AssignmentTarget;\n\tright: Expression;\n}) & Span;"; impl<'a> Serialize for AssignmentTarget<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -868,6 +967,8 @@ impl<'a> Serialize for AssignmentTarget<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentTarget = IdentifierReference | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget;"; impl<'a> Serialize for SimpleAssignmentTarget<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -902,6 +1003,8 @@ impl<'a> Serialize for SimpleAssignmentTarget<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type SimpleAssignmentTarget = IdentifierReference | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for AssignmentTargetPattern<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -919,6 +1022,15 @@ impl<'a> Serialize for AssignmentTargetPattern<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type AssignmentTargetPattern = ArrayAssignmentTarget | ObjectAssignmentTarget;"; + +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ArrayAssignmentTarget = ({\n\telements: Array;\n}) & Span;"; + +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ObjectAssignmentTarget = ({\n\tproperties: Array;\n}) & Span;"; impl<'a> Serialize for AssignmentTargetRest<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -933,6 +1045,8 @@ impl<'a> Serialize for AssignmentTargetRest<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentTargetRest = ({\n\ttype: 'RestElement';\n\targument: AssignmentTarget;\n}) & Span;"; impl<'a> Serialize for AssignmentTargetMaybeDefault<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -980,6 +1094,8 @@ impl<'a> Serialize for AssignmentTargetMaybeDefault<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentTargetMaybeDefault = AssignmentTargetWithDefault | IdentifierReference | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget;"; impl<'a> Serialize for AssignmentTargetWithDefault<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -995,6 +1111,8 @@ impl<'a> Serialize for AssignmentTargetWithDefault<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentTargetWithDefault = ({\n\ttype: 'AssignmentTargetWithDefault';\n\tbinding: AssignmentTarget;\n\tinit: Expression;\n}) & Span;"; impl<'a> Serialize for AssignmentTargetProperty<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1012,6 +1130,8 @@ impl<'a> Serialize for AssignmentTargetProperty<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentTargetProperty = AssignmentTargetPropertyIdentifier | AssignmentTargetPropertyProperty;"; impl<'a> Serialize for AssignmentTargetPropertyIdentifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1027,6 +1147,8 @@ impl<'a> Serialize for AssignmentTargetPropertyIdentifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentTargetPropertyIdentifier = ({\n\ttype: 'AssignmentTargetPropertyIdentifier';\n\tbinding: IdentifierReference;\n\tinit: (Expression) | null;\n}) & Span;"; impl<'a> Serialize for AssignmentTargetPropertyProperty<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1042,6 +1164,8 @@ impl<'a> Serialize for AssignmentTargetPropertyProperty<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentTargetPropertyProperty = ({\n\ttype: 'AssignmentTargetPropertyProperty';\n\tname: PropertyKey;\n\tbinding: AssignmentTargetMaybeDefault;\n}) & Span;"; impl<'a> Serialize for SequenceExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1056,6 +1180,8 @@ impl<'a> Serialize for SequenceExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type SequenceExpression = ({\n\ttype: 'SequenceExpression';\n\texpressions: Array;\n}) & Span;"; impl Serialize for Super { #[allow(clippy::match_same_arms, unused_mut)] @@ -1069,6 +1195,8 @@ impl Serialize for Super { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Super = ({\n\ttype: 'Super';\n}) & Span;"; impl<'a> Serialize for AwaitExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1083,6 +1211,8 @@ impl<'a> Serialize for AwaitExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AwaitExpression = ({\n\ttype: 'AwaitExpression';\n\targument: Expression;\n}) & Span;"; impl<'a> Serialize for ChainExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1097,6 +1227,8 @@ impl<'a> Serialize for ChainExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ChainExpression = ({\n\ttype: 'ChainExpression';\n\texpression: ChainElement;\n}) & Span;"; impl<'a> Serialize for ChainElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1112,6 +1244,8 @@ impl<'a> Serialize for ChainElement<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ChainElement = CallExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for ParenthesizedExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1126,6 +1260,8 @@ impl<'a> Serialize for ParenthesizedExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ParenthesizedExpression = ({\n\ttype: 'ParenthesizedExpression';\n\texpression: Expression;\n}) & Span;"; impl<'a> Serialize for Statement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1169,6 +1305,8 @@ impl<'a> Serialize for Statement<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Statement = BlockStatement | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | IfStatement | LabeledStatement | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | WithStatement | VariableDeclaration | Function | Class | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration | ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration;"; impl<'a> Serialize for Directive<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1184,6 +1322,8 @@ impl<'a> Serialize for Directive<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Directive = ({\n\ttype: 'Directive';\n\texpression: StringLiteral;\n\tdirective: string;\n}) & Span;"; impl<'a> Serialize for Hashbang<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1198,6 +1338,9 @@ impl<'a> Serialize for Hashbang<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type Hashbang = ({\n\ttype: 'Hashbang';\n\tvalue: string;\n}) & Span;"; impl<'a> Serialize for BlockStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1212,6 +1355,8 @@ impl<'a> Serialize for BlockStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BlockStatement = ({\n\ttype: 'BlockStatement';\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for Declaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1231,6 +1376,8 @@ impl<'a> Serialize for Declaration<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Declaration = VariableDeclaration | Function | Class | TSTypeAliasDeclaration | TSInterfaceDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration;"; impl<'a> Serialize for VariableDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1247,6 +1394,8 @@ impl<'a> Serialize for VariableDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type VariableDeclaration = ({\n\ttype: 'VariableDeclaration';\n\tkind: VariableDeclarationKind;\n\tdeclarations: Array;\n\tdeclare: boolean;\n}) & Span;"; impl Serialize for VariableDeclarationKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -1273,6 +1422,9 @@ impl Serialize for VariableDeclarationKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type VariableDeclarationKind = 'var' | 'const' | 'let' | 'using' | 'await using';"; impl<'a> Serialize for VariableDeclarator<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1289,6 +1441,8 @@ impl<'a> Serialize for VariableDeclarator<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type VariableDeclarator = ({\n\ttype: 'VariableDeclarator';\n\tid: BindingPattern;\n\tinit: (Expression) | null;\n\tdefinite: boolean;\n}) & Span;"; impl Serialize for EmptyStatement { #[allow(clippy::match_same_arms, unused_mut)] @@ -1302,6 +1456,9 @@ impl Serialize for EmptyStatement { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type EmptyStatement = ({\n\ttype: 'EmptyStatement';\n}) & Span;"; impl<'a> Serialize for ExpressionStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1316,6 +1473,8 @@ impl<'a> Serialize for ExpressionStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ExpressionStatement = ({\n\ttype: 'ExpressionStatement';\n\texpression: Expression;\n}) & Span;"; impl<'a> Serialize for IfStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1332,6 +1491,8 @@ impl<'a> Serialize for IfStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type IfStatement = ({\n\ttype: 'IfStatement';\n\ttest: Expression;\n\tconsequent: Statement;\n\talternate: (Statement) | null;\n}) & Span;"; impl<'a> Serialize for DoWhileStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1347,6 +1508,8 @@ impl<'a> Serialize for DoWhileStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type DoWhileStatement = ({\n\ttype: 'DoWhileStatement';\n\tbody: Statement;\n\ttest: Expression;\n}) & Span;"; impl<'a> Serialize for WhileStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1362,6 +1525,8 @@ impl<'a> Serialize for WhileStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type WhileStatement = ({\n\ttype: 'WhileStatement';\n\ttest: Expression;\n\tbody: Statement;\n}) & Span;"; impl<'a> Serialize for ForStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1379,6 +1544,8 @@ impl<'a> Serialize for ForStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ForStatement = ({\n\ttype: 'ForStatement';\n\tinit: (ForStatementInit) | null;\n\ttest: (Expression) | null;\n\tupdate: (Expression) | null;\n\tbody: Statement;\n}) & Span;"; impl<'a> Serialize for ForStatementInit<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1439,6 +1606,8 @@ impl<'a> Serialize for ForStatementInit<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ForStatementInit = VariableDeclaration | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for ForInStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1455,6 +1624,8 @@ impl<'a> Serialize for ForInStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ForInStatement = ({\n\ttype: 'ForInStatement';\n\tleft: ForStatementLeft;\n\tright: Expression;\n\tbody: Statement;\n}) & Span;"; impl<'a> Serialize for ForStatementLeft<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1484,6 +1655,8 @@ impl<'a> Serialize for ForStatementLeft<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ForStatementLeft = VariableDeclaration | IdentifierReference | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression | ArrayAssignmentTarget | ObjectAssignmentTarget;"; impl<'a> Serialize for ForOfStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1501,6 +1674,8 @@ impl<'a> Serialize for ForOfStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ForOfStatement = ({\n\ttype: 'ForOfStatement';\n\tawait: boolean;\n\tleft: ForStatementLeft;\n\tright: Expression;\n\tbody: Statement;\n}) & Span;"; impl<'a> Serialize for ContinueStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1515,6 +1690,8 @@ impl<'a> Serialize for ContinueStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ContinueStatement = ({\n\ttype: 'ContinueStatement';\n\tlabel: (LabelIdentifier) | null;\n}) & Span;"; impl<'a> Serialize for BreakStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1529,6 +1706,8 @@ impl<'a> Serialize for BreakStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BreakStatement = ({\n\ttype: 'BreakStatement';\n\tlabel: (LabelIdentifier) | null;\n}) & Span;"; impl<'a> Serialize for ReturnStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1543,6 +1722,8 @@ impl<'a> Serialize for ReturnStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ReturnStatement = ({\n\ttype: 'ReturnStatement';\n\targument: (Expression) | null;\n}) & Span;"; impl<'a> Serialize for WithStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1558,6 +1739,8 @@ impl<'a> Serialize for WithStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type WithStatement = ({\n\ttype: 'WithStatement';\n\tobject: Expression;\n\tbody: Statement;\n}) & Span;"; impl<'a> Serialize for SwitchStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1573,6 +1756,8 @@ impl<'a> Serialize for SwitchStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type SwitchStatement = ({\n\ttype: 'SwitchStatement';\n\tdiscriminant: Expression;\n\tcases: Array;\n}) & Span;"; impl<'a> Serialize for SwitchCase<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1588,6 +1773,8 @@ impl<'a> Serialize for SwitchCase<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type SwitchCase = ({\n\ttype: 'SwitchCase';\n\ttest: (Expression) | null;\n\tconsequent: Array;\n}) & Span;"; impl<'a> Serialize for LabeledStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1603,6 +1790,8 @@ impl<'a> Serialize for LabeledStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type LabeledStatement = ({\n\ttype: 'LabeledStatement';\n\tlabel: LabelIdentifier;\n\tbody: Statement;\n}) & Span;"; impl<'a> Serialize for ThrowStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1617,6 +1806,8 @@ impl<'a> Serialize for ThrowStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ThrowStatement = ({\n\ttype: 'ThrowStatement';\n\targument: Expression;\n}) & Span;"; impl<'a> Serialize for TryStatement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1633,6 +1824,8 @@ impl<'a> Serialize for TryStatement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TryStatement = ({\n\ttype: 'TryStatement';\n\tblock: BlockStatement;\n\thandler: (CatchClause) | null;\n\tfinalizer: (BlockStatement) | null;\n}) & Span;"; impl<'a> Serialize for CatchClause<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1648,6 +1841,8 @@ impl<'a> Serialize for CatchClause<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CatchClause = ({\n\ttype: 'CatchClause';\n\tparam: (CatchParameter) | null;\n\tbody: BlockStatement;\n}) & Span;"; impl<'a> Serialize for CatchParameter<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1662,6 +1857,8 @@ impl<'a> Serialize for CatchParameter<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CatchParameter = ({\n\ttype: 'CatchParameter';\n\tpattern: BindingPattern;\n}) & Span;"; impl Serialize for DebuggerStatement { #[allow(clippy::match_same_arms, unused_mut)] @@ -1675,6 +1872,9 @@ impl Serialize for DebuggerStatement { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type DebuggerStatement = ({\n\ttype: 'DebuggerStatement';\n}) & Span;"; impl<'a> Serialize for BindingPattern<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1689,6 +1889,8 @@ impl<'a> Serialize for BindingPattern<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BindingPattern = ({\n\ttypeAnnotation: (TSTypeAnnotation) | null;\n\toptional: boolean;\n}) & (BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern);"; impl<'a> Serialize for BindingPatternKind<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1704,6 +1906,8 @@ impl<'a> Serialize for BindingPatternKind<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BindingPatternKind = BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern;"; impl<'a> Serialize for AssignmentPattern<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1719,6 +1923,11 @@ impl<'a> Serialize for AssignmentPattern<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentPattern = ({\n\ttype: 'AssignmentPattern';\n\tleft: BindingPattern;\n\tright: Expression;\n}) & Span;"; + +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ObjectPattern = ({\n\tproperties: Array;\n}) & Span;"; impl<'a> Serialize for BindingProperty<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1736,6 +1945,11 @@ impl<'a> Serialize for BindingProperty<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BindingProperty = ({\n\ttype: 'BindingProperty';\n\tkey: PropertyKey;\n\tvalue: BindingPattern;\n\tshorthand: boolean;\n\tcomputed: boolean;\n}) & Span;"; + +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ArrayPattern = ({\n\telements: Array;\n}) & Span;"; impl<'a> Serialize for BindingRestElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1750,6 +1964,8 @@ impl<'a> Serialize for BindingRestElement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BindingRestElement = ({\n\ttype: 'RestElement';\n\targument: BindingPattern;\n}) & Span;"; impl<'a> Serialize for Function<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1772,6 +1988,8 @@ impl<'a> Serialize for Function<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Function = ({\n\ttype: FunctionType;\n\tid: (BindingIdentifier) | null;\n\tgenerator: boolean;\n\tasync: boolean;\n\tdeclare: boolean;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tthisParam: (TSThisParameter) | null;\n\tparams: FormalParameters;\n\treturnType: (TSTypeAnnotation) | null;\n\tbody: (FunctionBody) | null;\n}) & Span;"; impl Serialize for FunctionType { #[allow(clippy::match_same_arms, unused_mut)] @@ -1797,6 +2015,11 @@ impl Serialize for FunctionType { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type FunctionType = 'FunctionDeclaration' | 'FunctionExpression' | 'TSDeclareFunction' | 'TSEmptyBodyFunctionExpression';"; + +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type FormalParameters = ({\n\tkind: FormalParameterKind;\n\titems: Array;\n}) & Span;"; impl<'a> Serialize for FormalParameter<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1815,6 +2038,8 @@ impl<'a> Serialize for FormalParameter<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type FormalParameter = ({\n\ttype: 'FormalParameter';\n\tdecorators: Array;\n\tpattern: BindingPattern;\n\taccessibility: (TSAccessibility) | null;\n\treadonly: boolean;\n\toverride: boolean;\n}) & Span;"; impl Serialize for FormalParameterKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -1842,6 +2067,8 @@ impl Serialize for FormalParameterKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type FormalParameterKind = 'FormalParameter' | 'UniqueFormalParameters' | 'ArrowFormalParameters' | 'Signature';"; impl<'a> Serialize for FunctionBody<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1857,6 +2084,8 @@ impl<'a> Serialize for FunctionBody<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type FunctionBody = ({\n\ttype: 'FunctionBody';\n\tdirectives: Array;\n\tstatements: Array;\n}) & Span;"; impl<'a> Serialize for ArrowFunctionExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1876,6 +2105,8 @@ impl<'a> Serialize for ArrowFunctionExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ArrowFunctionExpression = ({\n\ttype: 'ArrowFunctionExpression';\n\texpression: boolean;\n\tasync: boolean;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tparams: FormalParameters;\n\treturnType: (TSTypeAnnotation) | null;\n\tbody: FunctionBody;\n}) & Span;"; impl<'a> Serialize for YieldExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1891,6 +2122,8 @@ impl<'a> Serialize for YieldExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type YieldExpression = ({\n\ttype: 'YieldExpression';\n\tdelegate: boolean;\n\targument: (Expression) | null;\n}) & Span;"; impl<'a> Serialize for Class<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1913,6 +2146,8 @@ impl<'a> Serialize for Class<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Class = ({\n\ttype: ClassType;\n\tdecorators: Array;\n\tid: (BindingIdentifier) | null;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tsuperClass: (Expression) | null;\n\tsuperTypeParameters: (TSTypeParameterInstantiation) | null;\n\timplements: (Array) | null;\n\tbody: ClassBody;\n\tabstract: boolean;\n\tdeclare: boolean;\n}) & Span;"; impl Serialize for ClassType { #[allow(clippy::match_same_arms, unused_mut)] @@ -1930,6 +2165,9 @@ impl Serialize for ClassType { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type ClassType = 'ClassDeclaration' | 'ClassExpression';"; impl<'a> Serialize for ClassBody<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1944,6 +2182,9 @@ impl<'a> Serialize for ClassBody<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type ClassBody = ({\n\ttype: 'ClassBody';\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for ClassElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1960,6 +2201,8 @@ impl<'a> Serialize for ClassElement<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ClassElement = StaticBlock | MethodDefinition | PropertyDefinition | AccessorProperty | TSIndexSignature;"; impl<'a> Serialize for MethodDefinition<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1982,6 +2225,8 @@ impl<'a> Serialize for MethodDefinition<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type MethodDefinition = ({\n\ttype: MethodDefinitionType;\n\tdecorators: Array;\n\tkey: PropertyKey;\n\tvalue: Function;\n\tkind: MethodDefinitionKind;\n\tcomputed: boolean;\n\tstatic: boolean;\n\toverride: boolean;\n\toptional: boolean;\n\taccessibility: (TSAccessibility) | null;\n}) & Span;"; impl Serialize for MethodDefinitionType { #[allow(clippy::match_same_arms, unused_mut)] @@ -2001,6 +2246,9 @@ impl Serialize for MethodDefinitionType { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type MethodDefinitionType = 'MethodDefinition' | 'TSAbstractMethodDefinition';"; impl<'a> Serialize for PropertyDefinition<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2026,6 +2274,8 @@ impl<'a> Serialize for PropertyDefinition<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type PropertyDefinition = ({\n\ttype: PropertyDefinitionType;\n\tdecorators: Array;\n\tkey: PropertyKey;\n\tvalue: (Expression) | null;\n\tcomputed: boolean;\n\tstatic: boolean;\n\tdeclare: boolean;\n\toverride: boolean;\n\toptional: boolean;\n\tdefinite: boolean;\n\treadonly: boolean;\n\ttypeAnnotation: (TSTypeAnnotation) | null;\n\taccessibility: (TSAccessibility) | null;\n}) & Span;"; impl Serialize for PropertyDefinitionType { #[allow(clippy::match_same_arms, unused_mut)] @@ -2048,6 +2298,9 @@ impl Serialize for PropertyDefinitionType { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type PropertyDefinitionType = 'PropertyDefinition' | 'TSAbstractPropertyDefinition';"; impl Serialize for MethodDefinitionKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -2071,6 +2324,9 @@ impl Serialize for MethodDefinitionKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type MethodDefinitionKind = 'constructor' | 'method' | 'get' | 'set';"; impl<'a> Serialize for PrivateIdentifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2085,6 +2341,9 @@ impl<'a> Serialize for PrivateIdentifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type PrivateIdentifier = ({\n\ttype: 'PrivateIdentifier';\n\tname: string;\n}) & Span;"; impl<'a> Serialize for StaticBlock<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2099,6 +2358,9 @@ impl<'a> Serialize for StaticBlock<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type StaticBlock = ({\n\ttype: 'StaticBlock';\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for ModuleDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2120,6 +2382,8 @@ impl<'a> Serialize for ModuleDeclaration<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ModuleDeclaration = ImportDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | TSExportAssignment | TSNamespaceExportDeclaration;"; impl Serialize for AccessorPropertyType { #[allow(clippy::match_same_arms, unused_mut)] @@ -2139,6 +2403,9 @@ impl Serialize for AccessorPropertyType { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type AccessorPropertyType = 'AccessorProperty' | 'TSAbstractAccessorProperty';"; impl<'a> Serialize for AccessorProperty<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2160,6 +2427,8 @@ impl<'a> Serialize for AccessorProperty<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AccessorProperty = ({\n\ttype: AccessorPropertyType;\n\tdecorators: Array;\n\tkey: PropertyKey;\n\tvalue: (Expression) | null;\n\tcomputed: boolean;\n\tstatic: boolean;\n\tdefinite: boolean;\n\ttypeAnnotation: (TSTypeAnnotation) | null;\n\taccessibility: (TSAccessibility) | null;\n}) & Span;"; impl<'a> Serialize for ImportExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2175,6 +2444,8 @@ impl<'a> Serialize for ImportExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ImportExpression = ({\n\ttype: 'ImportExpression';\n\tsource: Expression;\n\targuments: Array;\n}) & Span;"; impl<'a> Serialize for ImportDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2192,6 +2463,8 @@ impl<'a> Serialize for ImportDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ImportDeclaration = ({\n\ttype: 'ImportDeclaration';\n\tspecifiers: (Array) | null;\n\tsource: StringLiteral;\n\twithClause: (WithClause) | null;\n\timportKind: ImportOrExportKind;\n}) & Span;"; impl<'a> Serialize for ImportDeclarationSpecifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2212,6 +2485,8 @@ impl<'a> Serialize for ImportDeclarationSpecifier<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ImportDeclarationSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier;"; impl<'a> Serialize for ImportSpecifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2228,6 +2503,8 @@ impl<'a> Serialize for ImportSpecifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ImportSpecifier = ({\n\ttype: 'ImportSpecifier';\n\timported: ModuleExportName;\n\tlocal: BindingIdentifier;\n\timportKind: ImportOrExportKind;\n}) & Span;"; impl<'a> Serialize for ImportDefaultSpecifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2242,6 +2519,8 @@ impl<'a> Serialize for ImportDefaultSpecifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ImportDefaultSpecifier = ({\n\ttype: 'ImportDefaultSpecifier';\n\tlocal: BindingIdentifier;\n}) & Span;"; impl<'a> Serialize for ImportNamespaceSpecifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2256,6 +2535,8 @@ impl<'a> Serialize for ImportNamespaceSpecifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ImportNamespaceSpecifier = ({\n\ttype: 'ImportNamespaceSpecifier';\n\tlocal: BindingIdentifier;\n}) & Span;"; impl<'a> Serialize for WithClause<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2271,6 +2552,8 @@ impl<'a> Serialize for WithClause<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type WithClause = ({\n\ttype: 'WithClause';\n\tattributesKeyword: IdentifierName;\n\twithEntries: Array;\n}) & Span;"; impl<'a> Serialize for ImportAttribute<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2286,6 +2569,8 @@ impl<'a> Serialize for ImportAttribute<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ImportAttribute = ({\n\ttype: 'ImportAttribute';\n\tkey: ImportAttributeKey;\n\tvalue: StringLiteral;\n}) & Span;"; impl<'a> Serialize for ImportAttributeKey<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2299,6 +2584,9 @@ impl<'a> Serialize for ImportAttributeKey<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type ImportAttributeKey = IdentifierName | StringLiteral;"; impl<'a> Serialize for ExportNamedDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2317,6 +2605,8 @@ impl<'a> Serialize for ExportNamedDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ExportNamedDeclaration = ({\n\ttype: 'ExportNamedDeclaration';\n\tdeclaration: (Declaration) | null;\n\tspecifiers: Array;\n\tsource: (StringLiteral) | null;\n\texportKind: ImportOrExportKind;\n\twithClause: (WithClause) | null;\n}) & Span;"; impl<'a> Serialize for ExportDefaultDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2332,6 +2622,8 @@ impl<'a> Serialize for ExportDefaultDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ExportDefaultDeclaration = ({\n\ttype: 'ExportDefaultDeclaration';\n\tdeclaration: ExportDefaultDeclarationKind;\n\texported: ModuleExportName;\n}) & Span;"; impl<'a> Serialize for ExportAllDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2349,6 +2641,8 @@ impl<'a> Serialize for ExportAllDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ExportAllDeclaration = ({\n\ttype: 'ExportAllDeclaration';\n\texported: (ModuleExportName) | null;\n\tsource: StringLiteral;\n\twithClause: (WithClause) | null;\n\texportKind: ImportOrExportKind;\n}) & Span;"; impl<'a> Serialize for ExportSpecifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2365,6 +2659,8 @@ impl<'a> Serialize for ExportSpecifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ExportSpecifier = ({\n\ttype: 'ExportSpecifier';\n\tlocal: ModuleExportName;\n\texported: ModuleExportName;\n\texportKind: ImportOrExportKind;\n}) & Span;"; impl<'a> Serialize for ExportDefaultDeclarationKind<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2501,6 +2797,8 @@ impl<'a> Serialize for ExportDefaultDeclarationKind<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ExportDefaultDeclarationKind = Function | Class | TSInterfaceDeclaration | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for ModuleExportName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2515,6 +2813,9 @@ impl<'a> Serialize for ModuleExportName<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type ModuleExportName = IdentifierName | IdentifierReference | StringLiteral;"; impl<'a> Serialize for TSThisParameter<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2530,6 +2831,8 @@ impl<'a> Serialize for TSThisParameter<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSThisParameter = ({\n\ttype: 'TSThisParameter';\n\tthisSpan: Span;\n\ttypeAnnotation: (TSTypeAnnotation) | null;\n}) & Span;"; impl<'a> Serialize for TSEnumDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2547,6 +2850,8 @@ impl<'a> Serialize for TSEnumDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSEnumDeclaration = ({\n\ttype: 'TSEnumDeclaration';\n\tid: BindingIdentifier;\n\tmembers: Array;\n\tconst: boolean;\n\tdeclare: boolean;\n}) & Span;"; impl<'a> Serialize for TSEnumMember<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2562,6 +2867,8 @@ impl<'a> Serialize for TSEnumMember<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSEnumMember = ({\n\ttype: 'TSEnumMember';\n\tid: TSEnumMemberName;\n\tinitializer: (Expression) | null;\n}) & Span;"; impl<'a> Serialize for TSEnumMemberName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2625,6 +2932,8 @@ impl<'a> Serialize for TSEnumMemberName<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSEnumMemberName = IdentifierName | StringLiteral | TemplateLiteral | NumericLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl<'a> Serialize for TSTypeAnnotation<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2639,6 +2948,8 @@ impl<'a> Serialize for TSTypeAnnotation<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeAnnotation = ({\n\ttype: 'TSTypeAnnotation';\n\ttypeAnnotation: TSType;\n}) & Span;"; impl<'a> Serialize for TSLiteralType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2653,6 +2964,9 @@ impl<'a> Serialize for TSLiteralType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSLiteralType = ({\n\ttype: 'TSLiteralType';\n\tliteral: TSLiteral;\n}) & Span;"; impl<'a> Serialize for TSLiteral<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2672,6 +2986,8 @@ impl<'a> Serialize for TSLiteral<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSLiteral = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | UnaryExpression;"; impl<'a> Serialize for TSType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2721,6 +3037,8 @@ impl<'a> Serialize for TSType<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSType = TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSNamedTupleMember | TSQualifiedName | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperator | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TSParenthesizedType | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType;"; impl<'a> Serialize for TSConditionalType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2738,6 +3056,8 @@ impl<'a> Serialize for TSConditionalType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSConditionalType = ({\n\ttype: 'TSConditionalType';\n\tcheckType: TSType;\n\textendsType: TSType;\n\ttrueType: TSType;\n\tfalseType: TSType;\n}) & Span;"; impl<'a> Serialize for TSUnionType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2752,6 +3072,9 @@ impl<'a> Serialize for TSUnionType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSUnionType = ({\n\ttype: 'TSUnionType';\n\ttypes: Array;\n}) & Span;"; impl<'a> Serialize for TSIntersectionType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2766,6 +3089,8 @@ impl<'a> Serialize for TSIntersectionType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSIntersectionType = ({\n\ttype: 'TSIntersectionType';\n\ttypes: Array;\n}) & Span;"; impl<'a> Serialize for TSParenthesizedType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2780,6 +3105,8 @@ impl<'a> Serialize for TSParenthesizedType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSParenthesizedType = ({\n\ttype: 'TSParenthesizedType';\n\ttypeAnnotation: TSType;\n}) & Span;"; impl<'a> Serialize for TSTypeOperator<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2795,6 +3122,8 @@ impl<'a> Serialize for TSTypeOperator<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeOperator = ({\n\ttype: 'TSTypeOperator';\n\toperator: TSTypeOperatorOperator;\n\ttypeAnnotation: TSType;\n}) & Span;"; impl Serialize for TSTypeOperatorOperator { #[allow(clippy::match_same_arms, unused_mut)] @@ -2815,6 +3144,9 @@ impl Serialize for TSTypeOperatorOperator { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSTypeOperatorOperator = 'keyof' | 'unique' | 'readonly';"; impl<'a> Serialize for TSArrayType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2829,6 +3161,9 @@ impl<'a> Serialize for TSArrayType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSArrayType = ({\n\ttype: 'TSArrayType';\n\telementType: TSType;\n}) & Span;"; impl<'a> Serialize for TSIndexedAccessType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2844,6 +3179,8 @@ impl<'a> Serialize for TSIndexedAccessType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSIndexedAccessType = ({\n\ttype: 'TSIndexedAccessType';\n\tobjectType: TSType;\n\tindexType: TSType;\n}) & Span;"; impl<'a> Serialize for TSTupleType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2858,6 +3195,8 @@ impl<'a> Serialize for TSTupleType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTupleType = ({\n\ttype: 'TSTupleType';\n\telementTypes: Array;\n}) & Span;"; impl<'a> Serialize for TSNamedTupleMember<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2874,6 +3213,8 @@ impl<'a> Serialize for TSNamedTupleMember<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSNamedTupleMember = ({\n\ttype: 'TSNamedTupleMember';\n\telementType: TSTupleElement;\n\tlabel: IdentifierName;\n\toptional: boolean;\n}) & Span;"; impl<'a> Serialize for TSOptionalType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2888,6 +3229,8 @@ impl<'a> Serialize for TSOptionalType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSOptionalType = ({\n\ttype: 'TSOptionalType';\n\ttypeAnnotation: TSType;\n}) & Span;"; impl<'a> Serialize for TSRestType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2902,6 +3245,9 @@ impl<'a> Serialize for TSRestType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSRestType = ({\n\ttype: 'TSRestType';\n\ttypeAnnotation: TSType;\n}) & Span;"; impl<'a> Serialize for TSTupleElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2953,6 +3299,8 @@ impl<'a> Serialize for TSTupleElement<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTupleElement = TSOptionalType | TSRestType | TSAnyKeyword | TSBigIntKeyword | TSBooleanKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSArrayType | TSConditionalType | TSConstructorType | TSFunctionType | TSImportType | TSIndexedAccessType | TSInferType | TSIntersectionType | TSLiteralType | TSMappedType | TSNamedTupleMember | TSQualifiedName | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeLiteral | TSTypeOperator | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUnionType | TSParenthesizedType | JSDocNullableType | JSDocNonNullableType | JSDocUnknownType;"; impl Serialize for TSAnyKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -2966,6 +3314,9 @@ impl Serialize for TSAnyKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSAnyKeyword = ({\n\ttype: 'TSAnyKeyword';\n}) & Span;"; impl Serialize for TSStringKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -2979,6 +3330,9 @@ impl Serialize for TSStringKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSStringKeyword = ({\n\ttype: 'TSStringKeyword';\n}) & Span;"; impl Serialize for TSBooleanKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -2992,6 +3346,9 @@ impl Serialize for TSBooleanKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSBooleanKeyword = ({\n\ttype: 'TSBooleanKeyword';\n}) & Span;"; impl Serialize for TSNumberKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3005,6 +3362,9 @@ impl Serialize for TSNumberKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSNumberKeyword = ({\n\ttype: 'TSNumberKeyword';\n}) & Span;"; impl Serialize for TSNeverKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3018,6 +3378,9 @@ impl Serialize for TSNeverKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSNeverKeyword = ({\n\ttype: 'TSNeverKeyword';\n}) & Span;"; impl Serialize for TSIntrinsicKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3031,6 +3394,9 @@ impl Serialize for TSIntrinsicKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSIntrinsicKeyword = ({\n\ttype: 'TSIntrinsicKeyword';\n}) & Span;"; impl Serialize for TSUnknownKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3044,6 +3410,9 @@ impl Serialize for TSUnknownKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSUnknownKeyword = ({\n\ttype: 'TSUnknownKeyword';\n}) & Span;"; impl Serialize for TSNullKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3057,6 +3426,9 @@ impl Serialize for TSNullKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSNullKeyword = ({\n\ttype: 'TSNullKeyword';\n}) & Span;"; impl Serialize for TSUndefinedKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3070,6 +3442,9 @@ impl Serialize for TSUndefinedKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSUndefinedKeyword = ({\n\ttype: 'TSUndefinedKeyword';\n}) & Span;"; impl Serialize for TSVoidKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3083,6 +3458,9 @@ impl Serialize for TSVoidKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSVoidKeyword = ({\n\ttype: 'TSVoidKeyword';\n}) & Span;"; impl Serialize for TSSymbolKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3096,6 +3474,9 @@ impl Serialize for TSSymbolKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSSymbolKeyword = ({\n\ttype: 'TSSymbolKeyword';\n}) & Span;"; impl Serialize for TSThisType { #[allow(clippy::match_same_arms, unused_mut)] @@ -3109,6 +3490,9 @@ impl Serialize for TSThisType { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSThisType = ({\n\ttype: 'TSThisType';\n}) & Span;"; impl Serialize for TSObjectKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3122,6 +3506,9 @@ impl Serialize for TSObjectKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSObjectKeyword = ({\n\ttype: 'TSObjectKeyword';\n}) & Span;"; impl Serialize for TSBigIntKeyword { #[allow(clippy::match_same_arms, unused_mut)] @@ -3135,6 +3522,9 @@ impl Serialize for TSBigIntKeyword { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSBigIntKeyword = ({\n\ttype: 'TSBigIntKeyword';\n}) & Span;"; impl<'a> Serialize for TSTypeReference<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3150,6 +3540,8 @@ impl<'a> Serialize for TSTypeReference<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeReference = ({\n\ttype: 'TSTypeReference';\n\ttypeName: TSTypeName;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n}) & Span;"; impl<'a> Serialize for TSTypeName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3163,6 +3555,9 @@ impl<'a> Serialize for TSTypeName<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSTypeName = IdentifierReference | TSQualifiedName;"; impl<'a> Serialize for TSQualifiedName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3178,6 +3573,8 @@ impl<'a> Serialize for TSQualifiedName<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSQualifiedName = ({\n\ttype: 'TSQualifiedName';\n\tleft: TSTypeName;\n\tright: IdentifierName;\n}) & Span;"; impl<'a> Serialize for TSTypeParameterInstantiation<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3192,6 +3589,8 @@ impl<'a> Serialize for TSTypeParameterInstantiation<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeParameterInstantiation = ({\n\ttype: 'TSTypeParameterInstantiation';\n\tparams: Array;\n}) & Span;"; impl<'a> Serialize for TSTypeParameter<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3211,6 +3610,8 @@ impl<'a> Serialize for TSTypeParameter<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeParameter = ({\n\ttype: 'TSTypeParameter';\n\tname: BindingIdentifier;\n\tconstraint: (TSType) | null;\n\tdefault: (TSType) | null;\n\tin: boolean;\n\tout: boolean;\n\tconst: boolean;\n}) & Span;"; impl<'a> Serialize for TSTypeParameterDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3225,6 +3626,8 @@ impl<'a> Serialize for TSTypeParameterDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeParameterDeclaration = ({\n\ttype: 'TSTypeParameterDeclaration';\n\tparams: Array;\n}) & Span;"; impl<'a> Serialize for TSTypeAliasDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3242,6 +3645,8 @@ impl<'a> Serialize for TSTypeAliasDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeAliasDeclaration = ({\n\ttype: 'TSTypeAliasDeclaration';\n\tid: BindingIdentifier;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\ttypeAnnotation: TSType;\n\tdeclare: boolean;\n}) & Span;"; impl Serialize for TSAccessibility { #[allow(clippy::match_same_arms, unused_mut)] @@ -3262,6 +3667,9 @@ impl Serialize for TSAccessibility { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSAccessibility = 'private' | 'protected' | 'public';"; impl<'a> Serialize for TSClassImplements<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3277,6 +3685,8 @@ impl<'a> Serialize for TSClassImplements<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSClassImplements = ({\n\ttype: 'TSClassImplements';\n\texpression: TSTypeName;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n}) & Span;"; impl<'a> Serialize for TSInterfaceDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3295,6 +3705,8 @@ impl<'a> Serialize for TSInterfaceDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSInterfaceDeclaration = ({\n\ttype: 'TSInterfaceDeclaration';\n\tid: BindingIdentifier;\n\textends: (Array) | null;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tbody: TSInterfaceBody;\n\tdeclare: boolean;\n}) & Span;"; impl<'a> Serialize for TSInterfaceBody<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3309,6 +3721,8 @@ impl<'a> Serialize for TSInterfaceBody<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSInterfaceBody = ({\n\ttype: 'TSInterfaceBody';\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for TSPropertySignature<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3327,6 +3741,8 @@ impl<'a> Serialize for TSPropertySignature<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSPropertySignature = ({\n\ttype: 'TSPropertySignature';\n\tcomputed: boolean;\n\toptional: boolean;\n\treadonly: boolean;\n\tkey: PropertyKey;\n\ttypeAnnotation: (TSTypeAnnotation) | null;\n}) & Span;"; impl<'a> Serialize for TSSignature<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3345,6 +3761,8 @@ impl<'a> Serialize for TSSignature<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSSignature = TSIndexSignature | TSPropertySignature | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSMethodSignature;"; impl<'a> Serialize for TSIndexSignature<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3361,6 +3779,8 @@ impl<'a> Serialize for TSIndexSignature<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSIndexSignature = ({\n\ttype: 'TSIndexSignature';\n\tparameters: Array;\n\ttypeAnnotation: TSTypeAnnotation;\n\treadonly: boolean;\n}) & Span;"; impl<'a> Serialize for TSCallSignatureDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3378,6 +3798,8 @@ impl<'a> Serialize for TSCallSignatureDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSCallSignatureDeclaration = ({\n\ttype: 'TSCallSignatureDeclaration';\n\tthisParam: (TSThisParameter) | null;\n\tparams: FormalParameters;\n\treturnType: (TSTypeAnnotation) | null;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n}) & Span;"; impl Serialize for TSMethodSignatureKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -3398,6 +3820,9 @@ impl Serialize for TSMethodSignatureKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSMethodSignatureKind = 'method' | 'get' | 'set';"; impl<'a> Serialize for TSMethodSignature<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3419,6 +3844,8 @@ impl<'a> Serialize for TSMethodSignature<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSMethodSignature = ({\n\ttype: 'TSMethodSignature';\n\tkey: PropertyKey;\n\tcomputed: boolean;\n\toptional: boolean;\n\tkind: TSMethodSignatureKind;\n\tthisParam: (TSThisParameter) | null;\n\tparams: FormalParameters;\n\treturnType: (TSTypeAnnotation) | null;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n}) & Span;"; impl<'a> Serialize for TSConstructSignatureDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3435,6 +3862,8 @@ impl<'a> Serialize for TSConstructSignatureDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSConstructSignatureDeclaration = ({\n\ttype: 'TSConstructSignatureDeclaration';\n\tparams: FormalParameters;\n\treturnType: (TSTypeAnnotation) | null;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n}) & Span;"; impl<'a> Serialize for TSIndexSignatureName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3450,6 +3879,8 @@ impl<'a> Serialize for TSIndexSignatureName<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSIndexSignatureName = ({\n\ttype: 'Identifier';\n\tname: string;\n\ttypeAnnotation: TSTypeAnnotation;\n}) & Span;"; impl<'a> Serialize for TSInterfaceHeritage<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3465,6 +3896,8 @@ impl<'a> Serialize for TSInterfaceHeritage<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSInterfaceHeritage = ({\n\ttype: 'TSInterfaceHeritage';\n\texpression: Expression;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n}) & Span;"; impl<'a> Serialize for TSTypePredicate<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3481,6 +3914,8 @@ impl<'a> Serialize for TSTypePredicate<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypePredicate = ({\n\ttype: 'TSTypePredicate';\n\tparameterName: TSTypePredicateName;\n\tasserts: boolean;\n\ttypeAnnotation: (TSTypeAnnotation) | null;\n}) & Span;"; impl<'a> Serialize for TSTypePredicateName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3494,6 +3929,9 @@ impl<'a> Serialize for TSTypePredicateName<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSTypePredicateName = IdentifierName | TSThisType;"; impl<'a> Serialize for TSModuleDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3511,6 +3949,8 @@ impl<'a> Serialize for TSModuleDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSModuleDeclaration = ({\n\ttype: 'TSModuleDeclaration';\n\tid: TSModuleDeclarationName;\n\tbody: (TSModuleDeclarationBody) | null;\n\tkind: TSModuleDeclarationKind;\n\tdeclare: boolean;\n}) & Span;"; impl Serialize for TSModuleDeclarationKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -3531,6 +3971,9 @@ impl Serialize for TSModuleDeclarationKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSModuleDeclarationKind = 'global' | 'module' | 'namespace';"; impl<'a> Serialize for TSModuleDeclarationName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3544,6 +3987,9 @@ impl<'a> Serialize for TSModuleDeclarationName<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSModuleDeclarationName = BindingIdentifier | StringLiteral;"; impl<'a> Serialize for TSModuleDeclarationBody<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3559,6 +4005,13 @@ impl<'a> Serialize for TSModuleDeclarationBody<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSModuleDeclarationBody = TSModuleDeclaration | TSModuleBlock;"; + +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSModuleBlock = ({\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for TSTypeLiteral<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3573,6 +4026,8 @@ impl<'a> Serialize for TSTypeLiteral<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeLiteral = ({\n\ttype: 'TSTypeLiteral';\n\tmembers: Array;\n}) & Span;"; impl<'a> Serialize for TSInferType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3587,6 +4042,8 @@ impl<'a> Serialize for TSInferType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSInferType = ({\n\ttype: 'TSInferType';\n\ttypeParameter: TSTypeParameter;\n}) & Span;"; impl<'a> Serialize for TSTypeQuery<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3602,6 +4059,8 @@ impl<'a> Serialize for TSTypeQuery<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeQuery = ({\n\ttype: 'TSTypeQuery';\n\texprName: TSTypeQueryExprName;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n}) & Span;"; impl<'a> Serialize for TSTypeQueryExprName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3616,6 +4075,9 @@ impl<'a> Serialize for TSTypeQueryExprName<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSTypeQueryExprName = TSImportType | IdentifierReference | TSQualifiedName;"; impl<'a> Serialize for TSImportType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3634,6 +4096,8 @@ impl<'a> Serialize for TSImportType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSImportType = ({\n\ttype: 'TSImportType';\n\tisTypeOf: boolean;\n\tparameter: TSType;\n\tqualifier: (TSTypeName) | null;\n\tattributes: (TSImportAttributes) | null;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n}) & Span;"; impl<'a> Serialize for TSImportAttributes<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3649,6 +4113,8 @@ impl<'a> Serialize for TSImportAttributes<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSImportAttributes = ({\n\ttype: 'TSImportAttributes';\n\tattributesKeyword: IdentifierName;\n\telements: Array;\n}) & Span;"; impl<'a> Serialize for TSImportAttribute<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3664,6 +4130,8 @@ impl<'a> Serialize for TSImportAttribute<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSImportAttribute = ({\n\ttype: 'TSImportAttribute';\n\tname: TSImportAttributeName;\n\tvalue: Expression;\n}) & Span;"; impl<'a> Serialize for TSImportAttributeName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3677,6 +4145,9 @@ impl<'a> Serialize for TSImportAttributeName<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSImportAttributeName = IdentifierName | StringLiteral;"; impl<'a> Serialize for TSFunctionType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3694,6 +4165,8 @@ impl<'a> Serialize for TSFunctionType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSFunctionType = ({\n\ttype: 'TSFunctionType';\n\tthisParam: (TSThisParameter) | null;\n\tparams: FormalParameters;\n\treturnType: TSTypeAnnotation;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n}) & Span;"; impl<'a> Serialize for TSConstructorType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3711,6 +4184,8 @@ impl<'a> Serialize for TSConstructorType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSConstructorType = ({\n\ttype: 'TSConstructorType';\n\tabstract: boolean;\n\tparams: FormalParameters;\n\treturnType: TSTypeAnnotation;\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n}) & Span;"; impl<'a> Serialize for TSMappedType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3729,6 +4204,8 @@ impl<'a> Serialize for TSMappedType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSMappedType = ({\n\ttype: 'TSMappedType';\n\ttypeParameter: TSTypeParameter;\n\tnameType: (TSType) | null;\n\ttypeAnnotation: (TSType) | null;\n\toptional: TSMappedTypeModifierOperator;\n\treadonly: TSMappedTypeModifierOperator;\n}) & Span;"; impl Serialize for TSMappedTypeModifierOperator { #[allow(clippy::match_same_arms, unused_mut)] @@ -3752,6 +4229,9 @@ impl Serialize for TSMappedTypeModifierOperator { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type TSMappedTypeModifierOperator = 'true' | '+' | '-' | 'none';"; impl<'a> Serialize for TSTemplateLiteralType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3767,6 +4247,8 @@ impl<'a> Serialize for TSTemplateLiteralType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTemplateLiteralType = ({\n\ttype: 'TSTemplateLiteralType';\n\tquasis: Array;\n\ttypes: Array;\n}) & Span;"; impl<'a> Serialize for TSAsExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3782,6 +4264,8 @@ impl<'a> Serialize for TSAsExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSAsExpression = ({\n\ttype: 'TSAsExpression';\n\texpression: Expression;\n\ttypeAnnotation: TSType;\n}) & Span;"; impl<'a> Serialize for TSSatisfiesExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3797,6 +4281,8 @@ impl<'a> Serialize for TSSatisfiesExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSSatisfiesExpression = ({\n\ttype: 'TSSatisfiesExpression';\n\texpression: Expression;\n\ttypeAnnotation: TSType;\n}) & Span;"; impl<'a> Serialize for TSTypeAssertion<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3812,6 +4298,8 @@ impl<'a> Serialize for TSTypeAssertion<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSTypeAssertion = ({\n\ttype: 'TSTypeAssertion';\n\texpression: Expression;\n\ttypeAnnotation: TSType;\n}) & Span;"; impl<'a> Serialize for TSImportEqualsDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3828,6 +4316,8 @@ impl<'a> Serialize for TSImportEqualsDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSImportEqualsDeclaration = ({\n\ttype: 'TSImportEqualsDeclaration';\n\tid: BindingIdentifier;\n\tmoduleReference: TSModuleReference;\n\timportKind: ImportOrExportKind;\n}) & Span;"; impl<'a> Serialize for TSModuleReference<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3844,6 +4334,8 @@ impl<'a> Serialize for TSModuleReference<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSModuleReference = TSExternalModuleReference | IdentifierReference | TSQualifiedName;"; impl<'a> Serialize for TSExternalModuleReference<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3858,6 +4350,8 @@ impl<'a> Serialize for TSExternalModuleReference<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSExternalModuleReference = ({\n\ttype: 'TSExternalModuleReference';\n\texpression: StringLiteral;\n}) & Span;"; impl<'a> Serialize for TSNonNullExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3872,6 +4366,8 @@ impl<'a> Serialize for TSNonNullExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSNonNullExpression = ({\n\ttype: 'TSNonNullExpression';\n\texpression: Expression;\n}) & Span;"; impl<'a> Serialize for Decorator<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3886,6 +4382,9 @@ impl<'a> Serialize for Decorator<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type Decorator = ({\n\ttype: 'Decorator';\n\texpression: Expression;\n}) & Span;"; impl<'a> Serialize for TSExportAssignment<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3900,6 +4399,8 @@ impl<'a> Serialize for TSExportAssignment<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSExportAssignment = ({\n\ttype: 'TSExportAssignment';\n\texpression: Expression;\n}) & Span;"; impl<'a> Serialize for TSNamespaceExportDeclaration<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3914,6 +4415,8 @@ impl<'a> Serialize for TSNamespaceExportDeclaration<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSNamespaceExportDeclaration = ({\n\ttype: 'TSNamespaceExportDeclaration';\n\tid: IdentifierName;\n}) & Span;"; impl<'a> Serialize for TSInstantiationExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3929,6 +4432,8 @@ impl<'a> Serialize for TSInstantiationExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSInstantiationExpression = ({\n\ttype: 'TSInstantiationExpression';\n\texpression: Expression;\n\ttypeParameters: TSTypeParameterInstantiation;\n}) & Span;"; impl Serialize for ImportOrExportKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -3946,6 +4451,8 @@ impl Serialize for ImportOrExportKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ImportOrExportKind = 'value' | 'type';"; impl<'a> Serialize for JSDocNullableType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3961,6 +4468,8 @@ impl<'a> Serialize for JSDocNullableType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSDocNullableType = ({\n\ttype: 'JSDocNullableType';\n\ttypeAnnotation: TSType;\n\tpostfix: boolean;\n}) & Span;"; impl<'a> Serialize for JSDocNonNullableType<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -3976,6 +4485,8 @@ impl<'a> Serialize for JSDocNonNullableType<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSDocNonNullableType = ({\n\ttype: 'JSDocNonNullableType';\n\ttypeAnnotation: TSType;\n\tpostfix: boolean;\n}) & Span;"; impl Serialize for JSDocUnknownType { #[allow(clippy::match_same_arms, unused_mut)] @@ -3989,6 +4500,9 @@ impl Serialize for JSDocUnknownType { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type JSDocUnknownType = ({\n\ttype: 'JSDocUnknownType';\n}) & Span;"; impl<'a> Serialize for JSXElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4005,6 +4519,8 @@ impl<'a> Serialize for JSXElement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXElement = ({\n\ttype: 'JSXElement';\n\topeningElement: JSXOpeningElement;\n\tclosingElement: (JSXClosingElement) | null;\n\tchildren: Array;\n}) & Span;"; impl<'a> Serialize for JSXOpeningElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4022,6 +4538,8 @@ impl<'a> Serialize for JSXOpeningElement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXOpeningElement = ({\n\ttype: 'JSXOpeningElement';\n\tselfClosing: boolean;\n\tname: JSXElementName;\n\tattributes: Array;\n\ttypeParameters: (TSTypeParameterInstantiation) | null;\n}) & Span;"; impl<'a> Serialize for JSXClosingElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4036,6 +4554,8 @@ impl<'a> Serialize for JSXClosingElement<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXClosingElement = ({\n\ttype: 'JSXClosingElement';\n\tname: JSXElementName;\n}) & Span;"; impl<'a> Serialize for JSXFragment<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4052,6 +4572,8 @@ impl<'a> Serialize for JSXFragment<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXFragment = ({\n\ttype: 'JSXFragment';\n\topeningFragment: JSXOpeningFragment;\n\tclosingFragment: JSXClosingFragment;\n\tchildren: Array;\n}) & Span;"; impl Serialize for JSXOpeningFragment { #[allow(clippy::match_same_arms, unused_mut)] @@ -4065,6 +4587,9 @@ impl Serialize for JSXOpeningFragment { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type JSXOpeningFragment = ({\n\ttype: 'JSXOpeningFragment';\n}) & Span;"; impl Serialize for JSXClosingFragment { #[allow(clippy::match_same_arms, unused_mut)] @@ -4078,6 +4603,9 @@ impl Serialize for JSXClosingFragment { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type JSXClosingFragment = ({\n\ttype: 'JSXClosingFragment';\n}) & Span;"; impl<'a> Serialize for JSXNamespacedName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4093,6 +4621,8 @@ impl<'a> Serialize for JSXNamespacedName<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXNamespacedName = ({\n\ttype: 'JSXNamespacedName';\n\tnamespace: JSXIdentifier;\n\tproperty: JSXIdentifier;\n}) & Span;"; impl<'a> Serialize for JSXMemberExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4108,6 +4638,8 @@ impl<'a> Serialize for JSXMemberExpression<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXMemberExpression = ({\n\ttype: 'JSXMemberExpression';\n\tobject: JSXMemberExpressionObject;\n\tproperty: JSXIdentifier;\n}) & Span;"; impl<'a> Serialize for JSXExpressionContainer<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4122,6 +4654,8 @@ impl<'a> Serialize for JSXExpressionContainer<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXExpressionContainer = ({\n\ttype: 'JSXExpressionContainer';\n\texpression: JSXExpression;\n}) & Span;"; impl<'a> Serialize for JSXExpression<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4176,6 +4710,8 @@ impl<'a> Serialize for JSXExpression<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXExpression = JSXEmptyExpression | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;"; impl Serialize for JSXEmptyExpression { #[allow(clippy::match_same_arms, unused_mut)] @@ -4189,6 +4725,9 @@ impl Serialize for JSXEmptyExpression { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type JSXEmptyExpression = ({\n\ttype: 'JSXEmptyExpression';\n}) & Span;"; impl<'a> Serialize for JSXAttributeItem<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4202,6 +4741,9 @@ impl<'a> Serialize for JSXAttributeItem<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type JSXAttributeItem = JSXAttribute | JSXSpreadAttribute;"; impl<'a> Serialize for JSXAttribute<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4217,6 +4759,8 @@ impl<'a> Serialize for JSXAttribute<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXAttribute = ({\n\ttype: 'JSXAttribute';\n\tname: JSXAttributeName;\n\tvalue: (JSXAttributeValue) | null;\n}) & Span;"; impl<'a> Serialize for JSXSpreadAttribute<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4231,6 +4775,8 @@ impl<'a> Serialize for JSXSpreadAttribute<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXSpreadAttribute = ({\n\ttype: 'JSXSpreadAttribute';\n\targument: Expression;\n}) & Span;"; impl<'a> Serialize for JSXAttributeName<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4244,6 +4790,9 @@ impl<'a> Serialize for JSXAttributeName<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type JSXAttributeName = JSXIdentifier | JSXNamespacedName;"; impl<'a> Serialize for JSXAttributeValue<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4259,6 +4808,8 @@ impl<'a> Serialize for JSXAttributeValue<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXAttributeValue = StringLiteral | JSXExpressionContainer | JSXElement | JSXFragment;"; impl<'a> Serialize for JSXIdentifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4273,6 +4824,9 @@ impl<'a> Serialize for JSXIdentifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type JSXIdentifier = ({\n\ttype: 'JSXIdentifier';\n\tname: string;\n}) & Span;"; impl<'a> Serialize for JSXChild<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4289,6 +4843,8 @@ impl<'a> Serialize for JSXChild<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXChild = JSXText | JSXElement | JSXFragment | JSXExpressionContainer | JSXSpreadChild;"; impl<'a> Serialize for JSXSpreadChild<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4303,6 +4859,8 @@ impl<'a> Serialize for JSXSpreadChild<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type JSXSpreadChild = ({\n\ttype: 'JSXSpreadChild';\n\texpression: Expression;\n}) & Span;"; impl<'a> Serialize for JSXText<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4317,3 +4875,6 @@ impl<'a> Serialize for JSXText<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type JSXText = ({\n\ttype: 'JSXText';\n\tvalue: string;\n}) & Span;"; diff --git a/crates/oxc_ast/src/serialize.rs b/crates/oxc_ast/src/serialize.rs index f713fe88d4663..4e3adacd49733 100644 --- a/crates/oxc_ast/src/serialize.rs +++ b/crates/oxc_ast/src/serialize.rs @@ -60,6 +60,9 @@ impl Serialize for Elision { serializer.serialize_none() } } +#[cfg(feature = "serialize")] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Elision = null;"; /// Serialize `ArrayAssignmentTarget`, `ObjectAssignmentTarget`, `ObjectPattern`, `ArrayPattern` /// to be estree compatible, with `elements`/`properties` and `rest` fields combined. @@ -159,12 +162,12 @@ impl<'a> Serialize for FormalParameters<'a> { #[cfg(feature = "serialize")] #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" -export interface FormalParameterRest extends Span { +export type FormalParameterRest = ({ type: "RestElement", argument: BindingPatternKind, typeAnnotation?: TSTypeAnnotation, optional: boolean, -} +}) & Span; "#; #[derive(Serialize)] diff --git a/crates/oxc_regular_expression/Cargo.toml b/crates/oxc_regular_expression/Cargo.toml index 3e1ff4ed02cc2..7603151d3d425 100644 --- a/crates/oxc_regular_expression/Cargo.toml +++ b/crates/oxc_regular_expression/Cargo.toml @@ -31,18 +31,13 @@ rustc-hash = { workspace = true } serde = { workspace = true, optional = true } unicode-id-start = { workspace = true } -tsify = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } [features] default = [] serialize = [ "dep:serde", - "dep:tsify", "dep:wasm-bindgen", "oxc_allocator/serialize", "oxc_span/serialize", ] - -[package.metadata.cargo-shear] -ignored = ["wasm-bindgen"] # wasm-bindgen used by tsify diff --git a/crates/oxc_regular_expression/src/ast.rs b/crates/oxc_regular_expression/src/ast.rs index 03e4f9c0804fc..96bba7434769f 100644 --- a/crates/oxc_regular_expression/src/ast.rs +++ b/crates/oxc_regular_expression/src/ast.rs @@ -1,18 +1,12 @@ -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use oxc_allocator::{Box, CloneIn, Vec}; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash, Atom, GetSpan, Span}; -#[cfg(feature = "serialize")] -use tsify::Tsify; /// The root of the `PatternParser` result. #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Pattern<'a> { #[estree(flatten)] pub span: Span, @@ -23,7 +17,6 @@ pub struct Pattern<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Disjunction<'a> { #[estree(flatten)] pub span: Span, @@ -34,7 +27,6 @@ pub struct Disjunction<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Alternative<'a> { #[estree(flatten)] pub span: Span, @@ -45,7 +37,6 @@ pub struct Alternative<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum Term<'a> { // Assertion, QuantifiableAssertion @@ -90,7 +81,6 @@ impl<'a> GetSpan for Term<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct BoundaryAssertion { pub span: Span, pub kind: BoundaryAssertionKind, @@ -99,7 +89,6 @@ pub struct BoundaryAssertion { #[ast] #[derive(Debug, Clone, PartialEq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum BoundaryAssertionKind { Start = 0, @@ -113,7 +102,6 @@ pub enum BoundaryAssertionKind { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct LookAroundAssertion<'a> { #[estree(flatten)] pub span: Span, @@ -124,7 +112,6 @@ pub struct LookAroundAssertion<'a> { #[ast] #[derive(Debug, Clone, PartialEq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum LookAroundAssertionKind { Lookahead = 0, @@ -138,7 +125,6 @@ pub enum LookAroundAssertionKind { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Quantifier<'a> { #[estree(flatten)] pub span: Span, @@ -153,7 +139,6 @@ pub struct Quantifier<'a> { #[ast] #[derive(Debug, Clone, Copy)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Character { /// This will be invalid position when `UnicodeMode` is disabled and `value` is a surrogate pair. #[estree(flatten)] @@ -166,7 +151,6 @@ pub struct Character { #[ast] #[derive(Debug, Clone, Copy, PartialEq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum CharacterKind { ControlLetter = 0, @@ -187,7 +171,6 @@ pub enum CharacterKind { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CharacterClassEscape { #[estree(flatten)] pub span: Span, @@ -197,7 +180,6 @@ pub struct CharacterClassEscape { #[ast] #[derive(Debug, Clone, Copy, PartialEq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum CharacterClassEscapeKind { D = 0, @@ -213,7 +195,6 @@ pub enum CharacterClassEscapeKind { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct UnicodePropertyEscape<'a> { #[estree(flatten)] pub span: Span, @@ -228,7 +209,6 @@ pub struct UnicodePropertyEscape<'a> { #[ast] #[derive(Debug, Clone, Copy)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Dot { #[estree(flatten)] pub span: Span, @@ -239,7 +219,6 @@ pub struct Dot { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CharacterClass<'a> { #[estree(flatten)] pub span: Span, @@ -255,7 +234,6 @@ pub struct CharacterClass<'a> { #[ast] #[derive(Debug, PartialEq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum CharacterClassContentsKind { Union = 0, @@ -268,7 +246,6 @@ pub enum CharacterClassContentsKind { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(untagged)] pub enum CharacterClassContents<'a> { CharacterClassRange(Box<'a, CharacterClassRange>) = 0, @@ -300,7 +277,6 @@ impl<'a> GetSpan for CharacterClassContents<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CharacterClassRange { #[estree(flatten)] pub span: Span, @@ -312,7 +288,6 @@ pub struct CharacterClassRange { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ClassStringDisjunction<'a> { #[estree(flatten)] pub span: Span, @@ -325,7 +300,6 @@ pub struct ClassStringDisjunction<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct ClassString<'a> { #[estree(flatten)] pub span: Span, @@ -339,7 +313,6 @@ pub struct ClassString<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct CapturingGroup<'a> { #[estree(flatten)] pub span: Span, @@ -353,7 +326,6 @@ pub struct CapturingGroup<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct IgnoreGroup<'a> { #[estree(flatten)] pub span: Span, @@ -366,7 +338,6 @@ pub struct IgnoreGroup<'a> { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Modifiers { #[estree(flatten)] pub span: Span, @@ -378,7 +349,6 @@ pub struct Modifiers { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct Modifier { pub ignore_case: bool, pub multiline: bool, @@ -390,7 +360,6 @@ pub struct Modifier { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct IndexedReference { #[estree(flatten)] pub span: Span, @@ -402,7 +371,6 @@ pub struct IndexedReference { #[ast] #[derive(Debug)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub struct NamedReference<'a> { #[estree(flatten)] pub span: Span, diff --git a/crates/oxc_regular_expression/src/generated/derive_estree.rs b/crates/oxc_regular_expression/src/generated/derive_estree.rs index 8acc5287ac264..09080b58f3519 100644 --- a/crates/oxc_regular_expression/src/generated/derive_estree.rs +++ b/crates/oxc_regular_expression/src/generated/derive_estree.rs @@ -20,6 +20,9 @@ impl<'a> Serialize for Pattern<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type Pattern = ({\n\ttype: 'Pattern';\n\tbody: Disjunction;\n}) & Span;"; impl<'a> Serialize for Disjunction<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -34,6 +37,9 @@ impl<'a> Serialize for Disjunction<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type Disjunction = ({\n\ttype: 'Disjunction';\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for Alternative<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -48,6 +54,9 @@ impl<'a> Serialize for Alternative<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type Alternative = ({\n\ttype: 'Alternative';\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for Term<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -71,6 +80,8 @@ impl<'a> Serialize for Term<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Term = BoundaryAssertion | LookAroundAssertion | Quantifier | Character | Dot | CharacterClassEscape | UnicodePropertyEscape | CharacterClass | CapturingGroup | IgnoreGroup | IndexedReference | NamedReference;"; impl Serialize for BoundaryAssertion { #[allow(clippy::match_same_arms, unused_mut)] @@ -85,6 +96,8 @@ impl Serialize for BoundaryAssertion { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BoundaryAssertion = ({\n\ttype: 'BoundaryAssertion';\n\tspan: Span;\n\tkind: BoundaryAssertionKind;\n});"; impl Serialize for BoundaryAssertionKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -108,6 +121,9 @@ impl Serialize for BoundaryAssertionKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type BoundaryAssertionKind = 'start' | 'end' | 'boundary' | 'negativeBoundary';"; impl<'a> Serialize for LookAroundAssertion<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -123,6 +139,8 @@ impl<'a> Serialize for LookAroundAssertion<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type LookAroundAssertion = ({\n\ttype: 'LookAroundAssertion';\n\tkind: LookAroundAssertionKind;\n\tbody: Disjunction;\n}) & Span;"; impl Serialize for LookAroundAssertionKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -150,6 +168,8 @@ impl Serialize for LookAroundAssertionKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type LookAroundAssertionKind = 'lookahead' | 'negativeLookahead' | 'lookbehind' | 'negativeLookbehind';"; impl<'a> Serialize for Quantifier<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -167,6 +187,8 @@ impl<'a> Serialize for Quantifier<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Quantifier = ({\n\ttype: 'Quantifier';\n\tmin: number;\n\tmax: (number) | null;\n\tgreedy: boolean;\n\tbody: Term;\n}) & Span;"; impl Serialize for Character { #[allow(clippy::match_same_arms, unused_mut)] @@ -182,6 +204,8 @@ impl Serialize for Character { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Character = ({\n\ttype: 'Character';\n\tkind: CharacterKind;\n\tvalue: number;\n}) & Span;"; impl Serialize for CharacterKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -221,6 +245,8 @@ impl Serialize for CharacterKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CharacterKind = 'controlLetter' | 'hexadecimalEscape' | 'identifier' | 'null' | 'octal1' | 'octal2' | 'octal3' | 'singleEscape' | 'symbol' | 'unicodeEscape';"; impl Serialize for CharacterClassEscape { #[allow(clippy::match_same_arms, unused_mut)] @@ -235,6 +261,8 @@ impl Serialize for CharacterClassEscape { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CharacterClassEscape = ({\n\ttype: 'CharacterClassEscape';\n\tkind: CharacterClassEscapeKind;\n}) & Span;"; impl Serialize for CharacterClassEscapeKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -264,6 +292,8 @@ impl Serialize for CharacterClassEscapeKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CharacterClassEscapeKind = 'd' | 'negativeD' | 's' | 'negativeS' | 'w' | 'negativeW';"; impl<'a> Serialize for UnicodePropertyEscape<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -281,6 +311,8 @@ impl<'a> Serialize for UnicodePropertyEscape<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type UnicodePropertyEscape = ({\n\ttype: 'UnicodePropertyEscape';\n\tnegative: boolean;\n\tstrings: boolean;\n\tname: string;\n\tvalue: (string) | null;\n}) & Span;"; impl Serialize for Dot { #[allow(clippy::match_same_arms, unused_mut)] @@ -294,6 +326,8 @@ impl Serialize for Dot { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Dot = ({\n\ttype: 'Dot';\n}) & Span;"; impl<'a> Serialize for CharacterClass<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -311,6 +345,8 @@ impl<'a> Serialize for CharacterClass<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CharacterClass = ({\n\ttype: 'CharacterClass';\n\tnegative: boolean;\n\tstrings: boolean;\n\tkind: CharacterClassContentsKind;\n\tbody: Array;\n}) & Span;"; impl Serialize for CharacterClassContentsKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -333,6 +369,9 @@ impl Serialize for CharacterClassContentsKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type CharacterClassContentsKind = 'union' | 'intersection' | 'subtraction';"; impl<'a> Serialize for CharacterClassContents<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -360,6 +399,8 @@ impl<'a> Serialize for CharacterClassContents<'a> { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CharacterClassContents = CharacterClassRange | CharacterClassEscape | UnicodePropertyEscape | Character | CharacterClass | ClassStringDisjunction;"; impl Serialize for CharacterClassRange { #[allow(clippy::match_same_arms, unused_mut)] @@ -375,6 +416,8 @@ impl Serialize for CharacterClassRange { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CharacterClassRange = ({\n\ttype: 'CharacterClassRange';\n\tmin: Character;\n\tmax: Character;\n}) & Span;"; impl<'a> Serialize for ClassStringDisjunction<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -390,6 +433,8 @@ impl<'a> Serialize for ClassStringDisjunction<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ClassStringDisjunction = ({\n\ttype: 'ClassStringDisjunction';\n\tstrings: boolean;\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for ClassString<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -405,6 +450,8 @@ impl<'a> Serialize for ClassString<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type ClassString = ({\n\ttype: 'ClassString';\n\tstrings: boolean;\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for CapturingGroup<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -420,6 +467,8 @@ impl<'a> Serialize for CapturingGroup<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type CapturingGroup = ({\n\ttype: 'CapturingGroup';\n\tname: (string) | null;\n\tbody: Disjunction;\n}) & Span;"; impl<'a> Serialize for IgnoreGroup<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -435,6 +484,8 @@ impl<'a> Serialize for IgnoreGroup<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type IgnoreGroup = ({\n\ttype: 'IgnoreGroup';\n\tmodifiers: (Modifiers) | null;\n\tbody: Disjunction;\n}) & Span;"; impl Serialize for Modifiers { #[allow(clippy::match_same_arms, unused_mut)] @@ -450,6 +501,8 @@ impl Serialize for Modifiers { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Modifiers = ({\n\ttype: 'Modifiers';\n\tenabling: (Modifier) | null;\n\tdisabling: (Modifier) | null;\n}) & Span;"; impl Serialize for Modifier { #[allow(clippy::match_same_arms, unused_mut)] @@ -465,6 +518,8 @@ impl Serialize for Modifier { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type Modifier = ({\n\ttype: 'Modifier';\n\tignoreCase: boolean;\n\tmultiline: boolean;\n\tsticky: boolean;\n});"; impl Serialize for IndexedReference { #[allow(clippy::match_same_arms, unused_mut)] @@ -479,6 +534,9 @@ impl Serialize for IndexedReference { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type IndexedReference = ({\n\ttype: 'IndexedReference';\n\tindex: number;\n}) & Span;"; impl<'a> Serialize for NamedReference<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -493,3 +551,6 @@ impl<'a> Serialize for NamedReference<'a> { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type NamedReference = ({\n\ttype: 'NamedReference';\n\tname: string;\n}) & Span;"; diff --git a/crates/oxc_span/Cargo.toml b/crates/oxc_span/Cargo.toml index e985b3267a6b6..11cc1f0314e82 100644 --- a/crates/oxc_span/Cargo.toml +++ b/crates/oxc_span/Cargo.toml @@ -29,10 +29,9 @@ miette = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"], optional = true } -tsify = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } [features] default = [] -serialize = ["compact_str/serde", "dep:serde", "dep:tsify", "dep:wasm-bindgen"] +serialize = ["compact_str/serde", "dep:serde", "dep:wasm-bindgen"] schemars = ["dep:schemars"] diff --git a/crates/oxc_span/src/generated/derive_estree.rs b/crates/oxc_span/src/generated/derive_estree.rs index a19467d5d7157..362b4e21e1724 100644 --- a/crates/oxc_span/src/generated/derive_estree.rs +++ b/crates/oxc_span/src/generated/derive_estree.rs @@ -23,6 +23,9 @@ impl Serialize for Span { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type Span = ({\n\ttype: 'Span';\n\tstart: number;\n\tend: number;\n});"; impl Serialize for SourceType { #[allow(clippy::match_same_arms, unused_mut)] @@ -37,6 +40,8 @@ impl Serialize for SourceType { map.end() } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type SourceType = ({\n\tlanguage: Language;\n\tmoduleKind: ModuleKind;\n\tvariant: LanguageVariant;\n});"; impl Serialize for Language { #[allow(clippy::match_same_arms, unused_mut)] @@ -57,6 +62,9 @@ impl Serialize for Language { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type Language = 'javascript' | 'typescript' | 'typescriptDefinition';"; impl Serialize for ModuleKind { #[allow(clippy::match_same_arms, unused_mut)] @@ -73,6 +81,9 @@ impl Serialize for ModuleKind { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type ModuleKind = 'script' | 'module' | 'unambiguous';"; impl Serialize for LanguageVariant { #[allow(clippy::match_same_arms, unused_mut)] @@ -90,3 +101,5 @@ impl Serialize for LanguageVariant { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type LanguageVariant = 'standard' | 'jsx';"; diff --git a/crates/oxc_span/src/source_type/mod.rs b/crates/oxc_span/src/source_type/mod.rs index 242b768320826..1c619fdc7e758 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -1,6 +1,3 @@ -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - mod error; use std::{hash::Hash, path::Path}; @@ -8,8 +5,6 @@ use std::{hash::Hash, path::Path}; use oxc_allocator::{Allocator, CloneIn}; use oxc_ast_macros::ast; use oxc_estree::ESTree; -#[cfg(feature = "serialize")] -use tsify::Tsify; use crate::{cmp::ContentEq, hash::ContentHash}; pub use error::UnknownExtension; @@ -18,7 +13,6 @@ pub use error::UnknownExtension; #[ast] #[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(no_type)] pub struct SourceType { /// JavaScript or TypeScript, default JavaScript @@ -35,7 +29,6 @@ pub struct SourceType { #[ast] #[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] pub enum Language { #[estree(rename = "javascript")] JavaScript = 0, @@ -49,7 +42,6 @@ pub enum Language { #[ast] #[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum ModuleKind { /// Regular JS script or CommonJS file @@ -71,7 +63,6 @@ pub enum ModuleKind { #[ast] #[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum LanguageVariant { Standard = 0, diff --git a/crates/oxc_span/src/span/mod.rs b/crates/oxc_span/src/span/mod.rs index fb928f2a51d9c..0a03646d8ead9 100644 --- a/crates/oxc_span/src/span/mod.rs +++ b/crates/oxc_span/src/span/mod.rs @@ -2,7 +2,7 @@ use std::ops::{Index, IndexMut, Range}; use miette::{LabeledSpan, SourceOffset, SourceSpan}; -mod types; +pub mod types; use oxc_allocator::{Allocator, CloneIn}; pub use types::Span; diff --git a/crates/oxc_span/src/span/types.rs b/crates/oxc_span/src/span/types.rs index f44e429903025..3ad8615273508 100644 --- a/crates/oxc_span/src/span/types.rs +++ b/crates/oxc_span/src/span/types.rs @@ -1,10 +1,5 @@ -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use oxc_ast_macros::ast; use oxc_estree::ESTree; -#[cfg(feature = "serialize")] -use tsify::Tsify; /// Newtype for working with text ranges /// @@ -31,7 +26,6 @@ use tsify::Tsify; #[ast] #[generate_derive(ESTree)] #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[non_exhaustive] // Disallow struct expression constructor `Span {}` pub struct Span { pub start: u32, diff --git a/crates/oxc_syntax/src/generated/derive_estree.rs b/crates/oxc_syntax/src/generated/derive_estree.rs index 5fc926c5373e9..8a61f93311c9b 100644 --- a/crates/oxc_syntax/src/generated/derive_estree.rs +++ b/crates/oxc_syntax/src/generated/derive_estree.rs @@ -65,6 +65,8 @@ impl Serialize for AssignmentOperator { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type AssignmentOperator = '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '<<=' | '>>=' | '>>>=' | '|=' | '^=' | '&=' | '&&=' | '||=' | '??=' | '**=';"; impl Serialize for BinaryOperator { #[allow(clippy::match_same_arms, unused_mut)] @@ -140,6 +142,8 @@ impl Serialize for BinaryOperator { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type BinaryOperator = '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | '|' | '^' | '&' | 'in' | 'instanceof' | '**';"; impl Serialize for LogicalOperator { #[allow(clippy::match_same_arms, unused_mut)] @@ -158,6 +162,8 @@ impl Serialize for LogicalOperator { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type LogicalOperator = '||' | '&&' | '??';"; impl Serialize for UnaryOperator { #[allow(clippy::match_same_arms, unused_mut)] @@ -188,6 +194,9 @@ impl Serialize for UnaryOperator { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type UnaryOperator = '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete';"; impl Serialize for UpdateOperator { #[allow(clippy::match_same_arms, unused_mut)] @@ -205,3 +214,5 @@ impl Serialize for UpdateOperator { } } } +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type UpdateOperator = '++' | '--';"; diff --git a/crates/oxc_syntax/src/operator.rs b/crates/oxc_syntax/src/operator.rs index 50842ef7dccd5..c33e75cf38d9a 100644 --- a/crates/oxc_syntax/src/operator.rs +++ b/crates/oxc_syntax/src/operator.rs @@ -1,19 +1,13 @@ -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use oxc_allocator::CloneIn; use oxc_ast_macros::ast; use oxc_estree::ESTree; use oxc_span::{cmp::ContentEq, hash::ContentHash}; -#[cfg(feature = "serialize")] -use tsify::Tsify; use crate::precedence::{GetPrecedence, Precedence}; #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum AssignmentOperator { #[estree(rename = "=")] @@ -94,7 +88,6 @@ impl AssignmentOperator { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum BinaryOperator { #[estree(rename = "==")] @@ -284,7 +277,6 @@ impl GetPrecedence for BinaryOperator { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum LogicalOperator { #[estree(rename = "||")] @@ -326,7 +318,6 @@ impl GetPrecedence for LogicalOperator { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum UnaryOperator { #[estree(rename = "-")] @@ -385,7 +376,6 @@ impl UnaryOperator { #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] -#[cfg_attr(feature = "serialize", derive(Tsify))] #[estree(rename_all = "camelCase")] pub enum UpdateOperator { #[estree(rename = "++")] diff --git a/npm/oxc-types/src/generated/types.d.ts b/npm/oxc-types/src/generated/types.d.ts deleted file mode 100644 index 63436409a10b1..0000000000000 --- a/npm/oxc-types/src/generated/types.d.ts +++ /dev/null @@ -1,2070 +0,0 @@ -// To edit this generated file you have to edit `tasks/ast_tools/src/generators/typescript.rs` -// Auto-generated code, DO NOT EDIT DIRECTLY! - -export type BooleanLiteral = { - type: "BooleanLiteral"; - value: boolean; -} & Span; - -export type NullLiteral = { - type: "NullLiteral"; -} & Span; - -export type NumericLiteral = { - type: "NumericLiteral"; - value: number; - raw: string; -} & Span; - -export type BigIntLiteral = { - type: "BigIntLiteral"; - raw: string; -} & Span; - -export type RegExpLiteral = { - type: "RegExpLiteral"; - value: EmptyObject; - regex: RegExp; -} & Span; - -export type RegExp = { - pattern: RegExpPattern; - flags: RegExpFlags; -}; - -export type RegExpPattern = string | string | Pattern; - -export type EmptyObject = {}; - -export type StringLiteral = { - type: "StringLiteral"; - value: string; -} & Span; - -export type Program = { - type: "Program"; - sourceType: SourceType; - hashbang: Hashbang | null; - directives: Array; - body: Array; -} & Span; - -export type Expression = - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type IdentifierName = { - type: "Identifier"; - name: string; -} & Span; - -export type IdentifierReference = { - type: "Identifier"; - name: string; -} & Span; - -export type BindingIdentifier = { - type: "Identifier"; - name: string; -} & Span; - -export type LabelIdentifier = { - type: "Identifier"; - name: string; -} & Span; - -export type ThisExpression = { - type: "ThisExpression"; -} & Span; - -export type ArrayExpression = { - type: "ArrayExpression"; - elements: Array; -} & Span; - -export type ArrayExpressionElement = - | SpreadElement - | Elision - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type ObjectExpression = { - type: "ObjectExpression"; - properties: Array; -} & Span; - -export type ObjectPropertyKind = ObjectProperty | SpreadElement; - -export type ObjectProperty = { - type: "ObjectProperty"; - kind: PropertyKind; - key: PropertyKey; - value: Expression; - init: Expression | null; - method: boolean; - shorthand: boolean; - computed: boolean; -} & Span; - -export type PropertyKey = - | IdentifierName - | PrivateIdentifier - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type PropertyKind = "init" | "get" | "set"; - -export type TemplateLiteral = { - type: "TemplateLiteral"; - quasis: Array; - expressions: Array; -} & Span; - -export type TaggedTemplateExpression = { - type: "TaggedTemplateExpression"; - tag: Expression; - quasi: TemplateLiteral; - typeParameters: TSTypeParameterInstantiation | null; -} & Span; - -export type TemplateElement = { - type: "TemplateElement"; - tail: boolean; - value: TemplateElementValue; -} & Span; - -export type TemplateElementValue = { - raw: string; - cooked: string | null; -}; - -export type MemberExpression = - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type ComputedMemberExpression = { - type: "ComputedMemberExpression"; - object: Expression; - expression: Expression; - optional: boolean; -} & Span; - -export type StaticMemberExpression = { - type: "StaticMemberExpression"; - object: Expression; - property: IdentifierName; - optional: boolean; -} & Span; - -export type PrivateFieldExpression = { - type: "PrivateFieldExpression"; - object: Expression; - field: PrivateIdentifier; - optional: boolean; -} & Span; - -export type CallExpression = { - type: "CallExpression"; - callee: Expression; - typeParameters: TSTypeParameterInstantiation | null; - arguments: Array; - optional: boolean; -} & Span; - -export type NewExpression = { - type: "NewExpression"; - callee: Expression; - arguments: Array; - typeParameters: TSTypeParameterInstantiation | null; -} & Span; - -export type MetaProperty = { - type: "MetaProperty"; - meta: IdentifierName; - property: IdentifierName; -} & Span; - -export type SpreadElement = { - type: "SpreadElement"; - argument: Expression; -} & Span; - -export type Argument = - | SpreadElement - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type UpdateExpression = { - type: "UpdateExpression"; - operator: UpdateOperator; - prefix: boolean; - argument: SimpleAssignmentTarget; -} & Span; - -export type UnaryExpression = { - type: "UnaryExpression"; - operator: UnaryOperator; - argument: Expression; -} & Span; - -export type BinaryExpression = { - type: "BinaryExpression"; - left: Expression; - operator: BinaryOperator; - right: Expression; -} & Span; - -export type PrivateInExpression = { - type: "PrivateInExpression"; - left: PrivateIdentifier; - operator: BinaryOperator; - right: Expression; -} & Span; - -export type LogicalExpression = { - type: "LogicalExpression"; - left: Expression; - operator: LogicalOperator; - right: Expression; -} & Span; - -export type ConditionalExpression = { - type: "ConditionalExpression"; - test: Expression; - consequent: Expression; - alternate: Expression; -} & Span; - -export type AssignmentExpression = { - type: "AssignmentExpression"; - operator: AssignmentOperator; - left: AssignmentTarget; - right: Expression; -} & Span; - -export type AssignmentTarget = - | IdentifierReference - | TSAsExpression - | TSSatisfiesExpression - | TSNonNullExpression - | TSTypeAssertion - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression - | ArrayAssignmentTarget - | ObjectAssignmentTarget; - -export type SimpleAssignmentTarget = - | IdentifierReference - | TSAsExpression - | TSSatisfiesExpression - | TSNonNullExpression - | TSTypeAssertion - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type AssignmentTargetPattern = - | ArrayAssignmentTarget - | ObjectAssignmentTarget; - -export type AssignmentTargetRest = { - type: "RestElement"; - argument: AssignmentTarget; -} & Span; - -export type AssignmentTargetMaybeDefault = - | AssignmentTargetWithDefault - | IdentifierReference - | TSAsExpression - | TSSatisfiesExpression - | TSNonNullExpression - | TSTypeAssertion - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression - | ArrayAssignmentTarget - | ObjectAssignmentTarget; - -export type AssignmentTargetWithDefault = { - type: "AssignmentTargetWithDefault"; - binding: AssignmentTarget; - init: Expression; -} & Span; - -export type AssignmentTargetProperty = - | AssignmentTargetPropertyIdentifier - | AssignmentTargetPropertyProperty; - -export type AssignmentTargetPropertyIdentifier = { - type: "AssignmentTargetPropertyIdentifier"; - binding: IdentifierReference; - init: Expression | null; -} & Span; - -export type AssignmentTargetPropertyProperty = { - type: "AssignmentTargetPropertyProperty"; - name: PropertyKey; - binding: AssignmentTargetMaybeDefault; -} & Span; - -export type SequenceExpression = { - type: "SequenceExpression"; - expressions: Array; -} & Span; - -export type Super = { - type: "Super"; -} & Span; - -export type AwaitExpression = { - type: "AwaitExpression"; - argument: Expression; -} & Span; - -export type ChainExpression = { - type: "ChainExpression"; - expression: ChainElement; -} & Span; - -export type ChainElement = - | CallExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type ParenthesizedExpression = { - type: "ParenthesizedExpression"; - expression: Expression; -} & Span; - -export type Statement = - | BlockStatement - | BreakStatement - | ContinueStatement - | DebuggerStatement - | DoWhileStatement - | EmptyStatement - | ExpressionStatement - | ForInStatement - | ForOfStatement - | ForStatement - | IfStatement - | LabeledStatement - | ReturnStatement - | SwitchStatement - | ThrowStatement - | TryStatement - | WhileStatement - | WithStatement - | VariableDeclaration - | Function - | Class - | TSTypeAliasDeclaration - | TSInterfaceDeclaration - | TSEnumDeclaration - | TSModuleDeclaration - | TSImportEqualsDeclaration - | ImportDeclaration - | ExportAllDeclaration - | ExportDefaultDeclaration - | ExportNamedDeclaration - | TSExportAssignment - | TSNamespaceExportDeclaration; - -export type Directive = { - type: "Directive"; - expression: StringLiteral; - directive: string; -} & Span; - -export type Hashbang = { - type: "Hashbang"; - value: string; -} & Span; - -export type BlockStatement = { - type: "BlockStatement"; - body: Array; -} & Span; - -export type Declaration = - | VariableDeclaration - | Function - | Class - | TSTypeAliasDeclaration - | TSInterfaceDeclaration - | TSEnumDeclaration - | TSModuleDeclaration - | TSImportEqualsDeclaration; - -export type VariableDeclaration = { - type: "VariableDeclaration"; - kind: VariableDeclarationKind; - declarations: Array; - declare: boolean; -} & Span; - -export type VariableDeclarationKind = - | "var" - | "const" - | "let" - | "using" - | "await using"; - -export type VariableDeclarator = { - type: "VariableDeclarator"; - id: BindingPattern; - init: Expression | null; - definite: boolean; -} & Span; - -export type EmptyStatement = { - type: "EmptyStatement"; -} & Span; - -export type ExpressionStatement = { - type: "ExpressionStatement"; - expression: Expression; -} & Span; - -export type IfStatement = { - type: "IfStatement"; - test: Expression; - consequent: Statement; - alternate: Statement | null; -} & Span; - -export type DoWhileStatement = { - type: "DoWhileStatement"; - body: Statement; - test: Expression; -} & Span; - -export type WhileStatement = { - type: "WhileStatement"; - test: Expression; - body: Statement; -} & Span; - -export type ForStatement = { - type: "ForStatement"; - init: ForStatementInit | null; - test: Expression | null; - update: Expression | null; - body: Statement; -} & Span; - -export type ForStatementInit = - | VariableDeclaration - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type ForInStatement = { - type: "ForInStatement"; - left: ForStatementLeft; - right: Expression; - body: Statement; -} & Span; - -export type ForStatementLeft = - | VariableDeclaration - | IdentifierReference - | TSAsExpression - | TSSatisfiesExpression - | TSNonNullExpression - | TSTypeAssertion - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression - | ArrayAssignmentTarget - | ObjectAssignmentTarget; - -export type ForOfStatement = { - type: "ForOfStatement"; - await: boolean; - left: ForStatementLeft; - right: Expression; - body: Statement; -} & Span; - -export type ContinueStatement = { - type: "ContinueStatement"; - label: LabelIdentifier | null; -} & Span; - -export type BreakStatement = { - type: "BreakStatement"; - label: LabelIdentifier | null; -} & Span; - -export type ReturnStatement = { - type: "ReturnStatement"; - argument: Expression | null; -} & Span; - -export type WithStatement = { - type: "WithStatement"; - object: Expression; - body: Statement; -} & Span; - -export type SwitchStatement = { - type: "SwitchStatement"; - discriminant: Expression; - cases: Array; -} & Span; - -export type SwitchCase = { - type: "SwitchCase"; - test: Expression | null; - consequent: Array; -} & Span; - -export type LabeledStatement = { - type: "LabeledStatement"; - label: LabelIdentifier; - body: Statement; -} & Span; - -export type ThrowStatement = { - type: "ThrowStatement"; - argument: Expression; -} & Span; - -export type TryStatement = { - type: "TryStatement"; - block: BlockStatement; - handler: CatchClause | null; - finalizer: BlockStatement | null; -} & Span; - -export type CatchClause = { - type: "CatchClause"; - param: CatchParameter | null; - body: BlockStatement; -} & Span; - -export type CatchParameter = { - type: "CatchParameter"; - pattern: BindingPattern; -} & Span; - -export type DebuggerStatement = { - type: "DebuggerStatement"; -} & Span; - -export type BindingPattern = { - typeAnnotation: TSTypeAnnotation | null; - optional: boolean; -} & (BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern); - -export type BindingPatternKind = - | BindingIdentifier - | ObjectPattern - | ArrayPattern - | AssignmentPattern; - -export type AssignmentPattern = { - type: "AssignmentPattern"; - left: BindingPattern; - right: Expression; -} & Span; - -export type BindingProperty = { - type: "BindingProperty"; - key: PropertyKey; - value: BindingPattern; - shorthand: boolean; - computed: boolean; -} & Span; - -export type BindingRestElement = { - type: "RestElement"; - argument: BindingPattern; -} & Span; - -export type Function = { - type: FunctionType; - id: BindingIdentifier | null; - generator: boolean; - async: boolean; - declare: boolean; - typeParameters: TSTypeParameterDeclaration | null; - thisParam: TSThisParameter | null; - params: FormalParameters; - returnType: TSTypeAnnotation | null; - body: FunctionBody | null; -} & Span; - -export type FunctionType = - | "FunctionDeclaration" - | "FunctionExpression" - | "TSDeclareFunction" - | "TSEmptyBodyFunctionExpression"; - -export type FormalParameter = { - type: "FormalParameter"; - decorators: Array; - pattern: BindingPattern; - accessibility: TSAccessibility | null; - readonly: boolean; - override: boolean; -} & Span; - -export type FormalParameterKind = - | "FormalParameter" - | "UniqueFormalParameters" - | "ArrowFormalParameters" - | "Signature"; - -export type FunctionBody = { - type: "FunctionBody"; - directives: Array; - statements: Array; -} & Span; - -export type ArrowFunctionExpression = { - type: "ArrowFunctionExpression"; - expression: boolean; - async: boolean; - typeParameters: TSTypeParameterDeclaration | null; - params: FormalParameters; - returnType: TSTypeAnnotation | null; - body: FunctionBody; -} & Span; - -export type YieldExpression = { - type: "YieldExpression"; - delegate: boolean; - argument: Expression | null; -} & Span; - -export type Class = { - type: ClassType; - decorators: Array; - id: BindingIdentifier | null; - typeParameters: TSTypeParameterDeclaration | null; - superClass: Expression | null; - superTypeParameters: TSTypeParameterInstantiation | null; - implements: Array | null; - body: ClassBody; - abstract: boolean; - declare: boolean; -} & Span; - -export type ClassType = "ClassDeclaration" | "ClassExpression"; - -export type ClassBody = { - type: "ClassBody"; - body: Array; -} & Span; - -export type ClassElement = - | StaticBlock - | MethodDefinition - | PropertyDefinition - | AccessorProperty - | TSIndexSignature; - -export type MethodDefinition = { - type: MethodDefinitionType; - decorators: Array; - key: PropertyKey; - value: Function; - kind: MethodDefinitionKind; - computed: boolean; - static: boolean; - override: boolean; - optional: boolean; - accessibility: TSAccessibility | null; -} & Span; - -export type MethodDefinitionType = - | "MethodDefinition" - | "TSAbstractMethodDefinition"; - -export type PropertyDefinition = { - type: PropertyDefinitionType; - decorators: Array; - key: PropertyKey; - value: Expression | null; - computed: boolean; - static: boolean; - declare: boolean; - override: boolean; - optional: boolean; - definite: boolean; - readonly: boolean; - typeAnnotation: TSTypeAnnotation | null; - accessibility: TSAccessibility | null; -} & Span; - -export type PropertyDefinitionType = - | "PropertyDefinition" - | "TSAbstractPropertyDefinition"; - -export type MethodDefinitionKind = "constructor" | "method" | "get" | "set"; - -export type PrivateIdentifier = { - type: "PrivateIdentifier"; - name: string; -} & Span; - -export type StaticBlock = { - type: "StaticBlock"; - body: Array; -} & Span; - -export type ModuleDeclaration = - | ImportDeclaration - | ExportAllDeclaration - | ExportDefaultDeclaration - | ExportNamedDeclaration - | TSExportAssignment - | TSNamespaceExportDeclaration; - -export type AccessorPropertyType = - | "AccessorProperty" - | "TSAbstractAccessorProperty"; - -export type AccessorProperty = { - type: AccessorPropertyType; - decorators: Array; - key: PropertyKey; - value: Expression | null; - computed: boolean; - static: boolean; - definite: boolean; - typeAnnotation: TSTypeAnnotation | null; - accessibility: TSAccessibility | null; -} & Span; - -export type ImportExpression = { - type: "ImportExpression"; - source: Expression; - arguments: Array; -} & Span; - -export type ImportDeclaration = { - type: "ImportDeclaration"; - specifiers: Array | null; - source: StringLiteral; - withClause: WithClause | null; - importKind: ImportOrExportKind; -} & Span; - -export type ImportDeclarationSpecifier = - | ImportSpecifier - | ImportDefaultSpecifier - | ImportNamespaceSpecifier; - -export type ImportSpecifier = { - type: "ImportSpecifier"; - imported: ModuleExportName; - local: BindingIdentifier; - importKind: ImportOrExportKind; -} & Span; - -export type ImportDefaultSpecifier = { - type: "ImportDefaultSpecifier"; - local: BindingIdentifier; -} & Span; - -export type ImportNamespaceSpecifier = { - type: "ImportNamespaceSpecifier"; - local: BindingIdentifier; -} & Span; - -export type WithClause = { - type: "WithClause"; - attributesKeyword: IdentifierName; - withEntries: Array; -} & Span; - -export type ImportAttribute = { - type: "ImportAttribute"; - key: ImportAttributeKey; - value: StringLiteral; -} & Span; - -export type ImportAttributeKey = IdentifierName | StringLiteral; - -export type ExportNamedDeclaration = { - type: "ExportNamedDeclaration"; - declaration: Declaration | null; - specifiers: Array; - source: StringLiteral | null; - exportKind: ImportOrExportKind; - withClause: WithClause | null; -} & Span; - -export type ExportDefaultDeclaration = { - type: "ExportDefaultDeclaration"; - declaration: ExportDefaultDeclarationKind; - exported: ModuleExportName; -} & Span; - -export type ExportAllDeclaration = { - type: "ExportAllDeclaration"; - exported: ModuleExportName | null; - source: StringLiteral; - withClause: WithClause | null; - exportKind: ImportOrExportKind; -} & Span; - -export type ExportSpecifier = { - type: "ExportSpecifier"; - local: ModuleExportName; - exported: ModuleExportName; - exportKind: ImportOrExportKind; -} & Span; - -export type ExportDefaultDeclarationKind = - | Function - | Class - | TSInterfaceDeclaration - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type ModuleExportName = - | IdentifierName - | IdentifierReference - | StringLiteral; - -export type TSThisParameter = { - type: "TSThisParameter"; - thisSpan: Span; - typeAnnotation: TSTypeAnnotation | null; -} & Span; - -export type TSEnumDeclaration = { - type: "TSEnumDeclaration"; - id: BindingIdentifier; - members: Array; - const: boolean; - declare: boolean; -} & Span; - -export type TSEnumMember = { - type: "TSEnumMember"; - id: TSEnumMemberName; - initializer: Expression | null; -} & Span; - -export type TSEnumMemberName = - | IdentifierName - | StringLiteral - | TemplateLiteral - | NumericLiteral - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type TSTypeAnnotation = { - type: "TSTypeAnnotation"; - typeAnnotation: TSType; -} & Span; - -export type TSLiteralType = { - type: "TSLiteralType"; - literal: TSLiteral; -} & Span; - -export type TSLiteral = - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | UnaryExpression; - -export type TSType = - | TSAnyKeyword - | TSBigIntKeyword - | TSBooleanKeyword - | TSIntrinsicKeyword - | TSNeverKeyword - | TSNullKeyword - | TSNumberKeyword - | TSObjectKeyword - | TSStringKeyword - | TSSymbolKeyword - | TSUndefinedKeyword - | TSUnknownKeyword - | TSVoidKeyword - | TSArrayType - | TSConditionalType - | TSConstructorType - | TSFunctionType - | TSImportType - | TSIndexedAccessType - | TSInferType - | TSIntersectionType - | TSLiteralType - | TSMappedType - | TSNamedTupleMember - | TSQualifiedName - | TSTemplateLiteralType - | TSThisType - | TSTupleType - | TSTypeLiteral - | TSTypeOperator - | TSTypePredicate - | TSTypeQuery - | TSTypeReference - | TSUnionType - | TSParenthesizedType - | JSDocNullableType - | JSDocNonNullableType - | JSDocUnknownType; - -export type TSConditionalType = { - type: "TSConditionalType"; - checkType: TSType; - extendsType: TSType; - trueType: TSType; - falseType: TSType; -} & Span; - -export type TSUnionType = { - type: "TSUnionType"; - types: Array; -} & Span; - -export type TSIntersectionType = { - type: "TSIntersectionType"; - types: Array; -} & Span; - -export type TSParenthesizedType = { - type: "TSParenthesizedType"; - typeAnnotation: TSType; -} & Span; - -export type TSTypeOperator = { - type: "TSTypeOperator"; - operator: TSTypeOperatorOperator; - typeAnnotation: TSType; -} & Span; - -export type TSTypeOperatorOperator = "keyof" | "unique" | "readonly"; - -export type TSArrayType = { - type: "TSArrayType"; - elementType: TSType; -} & Span; - -export type TSIndexedAccessType = { - type: "TSIndexedAccessType"; - objectType: TSType; - indexType: TSType; -} & Span; - -export type TSTupleType = { - type: "TSTupleType"; - elementTypes: Array; -} & Span; - -export type TSNamedTupleMember = { - type: "TSNamedTupleMember"; - elementType: TSTupleElement; - label: IdentifierName; - optional: boolean; -} & Span; - -export type TSOptionalType = { - type: "TSOptionalType"; - typeAnnotation: TSType; -} & Span; - -export type TSRestType = { - type: "TSRestType"; - typeAnnotation: TSType; -} & Span; - -export type TSTupleElement = - | TSOptionalType - | TSRestType - | TSAnyKeyword - | TSBigIntKeyword - | TSBooleanKeyword - | TSIntrinsicKeyword - | TSNeverKeyword - | TSNullKeyword - | TSNumberKeyword - | TSObjectKeyword - | TSStringKeyword - | TSSymbolKeyword - | TSUndefinedKeyword - | TSUnknownKeyword - | TSVoidKeyword - | TSArrayType - | TSConditionalType - | TSConstructorType - | TSFunctionType - | TSImportType - | TSIndexedAccessType - | TSInferType - | TSIntersectionType - | TSLiteralType - | TSMappedType - | TSNamedTupleMember - | TSQualifiedName - | TSTemplateLiteralType - | TSThisType - | TSTupleType - | TSTypeLiteral - | TSTypeOperator - | TSTypePredicate - | TSTypeQuery - | TSTypeReference - | TSUnionType - | TSParenthesizedType - | JSDocNullableType - | JSDocNonNullableType - | JSDocUnknownType; - -export type TSAnyKeyword = { - type: "TSAnyKeyword"; -} & Span; - -export type TSStringKeyword = { - type: "TSStringKeyword"; -} & Span; - -export type TSBooleanKeyword = { - type: "TSBooleanKeyword"; -} & Span; - -export type TSNumberKeyword = { - type: "TSNumberKeyword"; -} & Span; - -export type TSNeverKeyword = { - type: "TSNeverKeyword"; -} & Span; - -export type TSIntrinsicKeyword = { - type: "TSIntrinsicKeyword"; -} & Span; - -export type TSUnknownKeyword = { - type: "TSUnknownKeyword"; -} & Span; - -export type TSNullKeyword = { - type: "TSNullKeyword"; -} & Span; - -export type TSUndefinedKeyword = { - type: "TSUndefinedKeyword"; -} & Span; - -export type TSVoidKeyword = { - type: "TSVoidKeyword"; -} & Span; - -export type TSSymbolKeyword = { - type: "TSSymbolKeyword"; -} & Span; - -export type TSThisType = { - type: "TSThisType"; -} & Span; - -export type TSObjectKeyword = { - type: "TSObjectKeyword"; -} & Span; - -export type TSBigIntKeyword = { - type: "TSBigIntKeyword"; -} & Span; - -export type TSTypeReference = { - type: "TSTypeReference"; - typeName: TSTypeName; - typeParameters: TSTypeParameterInstantiation | null; -} & Span; - -export type TSTypeName = IdentifierReference | TSQualifiedName; - -export type TSQualifiedName = { - type: "TSQualifiedName"; - left: TSTypeName; - right: IdentifierName; -} & Span; - -export type TSTypeParameterInstantiation = { - type: "TSTypeParameterInstantiation"; - params: Array; -} & Span; - -export type TSTypeParameter = { - type: "TSTypeParameter"; - name: BindingIdentifier; - constraint: TSType | null; - default: TSType | null; - in: boolean; - out: boolean; - const: boolean; -} & Span; - -export type TSTypeParameterDeclaration = { - type: "TSTypeParameterDeclaration"; - params: Array; -} & Span; - -export type TSTypeAliasDeclaration = { - type: "TSTypeAliasDeclaration"; - id: BindingIdentifier; - typeParameters: TSTypeParameterDeclaration | null; - typeAnnotation: TSType; - declare: boolean; -} & Span; - -export type TSAccessibility = "private" | "protected" | "public"; - -export type TSClassImplements = { - type: "TSClassImplements"; - expression: TSTypeName; - typeParameters: TSTypeParameterInstantiation | null; -} & Span; - -export type TSInterfaceDeclaration = { - type: "TSInterfaceDeclaration"; - id: BindingIdentifier; - extends: Array | null; - typeParameters: TSTypeParameterDeclaration | null; - body: TSInterfaceBody; - declare: boolean; -} & Span; - -export type TSInterfaceBody = { - type: "TSInterfaceBody"; - body: Array; -} & Span; - -export type TSPropertySignature = { - type: "TSPropertySignature"; - computed: boolean; - optional: boolean; - readonly: boolean; - key: PropertyKey; - typeAnnotation: TSTypeAnnotation | null; -} & Span; - -export type TSSignature = - | TSIndexSignature - | TSPropertySignature - | TSCallSignatureDeclaration - | TSConstructSignatureDeclaration - | TSMethodSignature; - -export type TSIndexSignature = { - type: "TSIndexSignature"; - parameters: Array; - typeAnnotation: TSTypeAnnotation; - readonly: boolean; -} & Span; - -export type TSCallSignatureDeclaration = { - type: "TSCallSignatureDeclaration"; - thisParam: TSThisParameter | null; - params: FormalParameters; - returnType: TSTypeAnnotation | null; - typeParameters: TSTypeParameterDeclaration | null; -} & Span; - -export type TSMethodSignatureKind = "method" | "get" | "set"; - -export type TSMethodSignature = { - type: "TSMethodSignature"; - key: PropertyKey; - computed: boolean; - optional: boolean; - kind: TSMethodSignatureKind; - thisParam: TSThisParameter | null; - params: FormalParameters; - returnType: TSTypeAnnotation | null; - typeParameters: TSTypeParameterDeclaration | null; -} & Span; - -export type TSConstructSignatureDeclaration = { - type: "TSConstructSignatureDeclaration"; - params: FormalParameters; - returnType: TSTypeAnnotation | null; - typeParameters: TSTypeParameterDeclaration | null; -} & Span; - -export type TSIndexSignatureName = { - type: "Identifier"; - name: string; - typeAnnotation: TSTypeAnnotation; -} & Span; - -export type TSInterfaceHeritage = { - type: "TSInterfaceHeritage"; - expression: Expression; - typeParameters: TSTypeParameterInstantiation | null; -} & Span; - -export type TSTypePredicate = { - type: "TSTypePredicate"; - parameterName: TSTypePredicateName; - asserts: boolean; - typeAnnotation: TSTypeAnnotation | null; -} & Span; - -export type TSTypePredicateName = IdentifierName | TSThisType; - -export type TSModuleDeclaration = { - type: "TSModuleDeclaration"; - id: TSModuleDeclarationName; - body: TSModuleDeclarationBody | null; - kind: TSModuleDeclarationKind; - declare: boolean; -} & Span; - -export type TSModuleDeclarationKind = "global" | "module" | "namespace"; - -export type TSModuleDeclarationName = BindingIdentifier | StringLiteral; - -export type TSModuleDeclarationBody = TSModuleDeclaration | TSModuleBlock; - -export type TSTypeLiteral = { - type: "TSTypeLiteral"; - members: Array; -} & Span; - -export type TSInferType = { - type: "TSInferType"; - typeParameter: TSTypeParameter; -} & Span; - -export type TSTypeQuery = { - type: "TSTypeQuery"; - exprName: TSTypeQueryExprName; - typeParameters: TSTypeParameterInstantiation | null; -} & Span; - -export type TSTypeQueryExprName = - | TSImportType - | IdentifierReference - | TSQualifiedName; - -export type TSImportType = { - type: "TSImportType"; - isTypeOf: boolean; - parameter: TSType; - qualifier: TSTypeName | null; - attributes: TSImportAttributes | null; - typeParameters: TSTypeParameterInstantiation | null; -} & Span; - -export type TSImportAttributes = { - type: "TSImportAttributes"; - attributesKeyword: IdentifierName; - elements: Array; -} & Span; - -export type TSImportAttribute = { - type: "TSImportAttribute"; - name: TSImportAttributeName; - value: Expression; -} & Span; - -export type TSImportAttributeName = IdentifierName | StringLiteral; - -export type TSFunctionType = { - type: "TSFunctionType"; - thisParam: TSThisParameter | null; - params: FormalParameters; - returnType: TSTypeAnnotation; - typeParameters: TSTypeParameterDeclaration | null; -} & Span; - -export type TSConstructorType = { - type: "TSConstructorType"; - abstract: boolean; - params: FormalParameters; - returnType: TSTypeAnnotation; - typeParameters: TSTypeParameterDeclaration | null; -} & Span; - -export type TSMappedType = { - type: "TSMappedType"; - typeParameter: TSTypeParameter; - nameType: TSType | null; - typeAnnotation: TSType | null; - optional: TSMappedTypeModifierOperator; - readonly: TSMappedTypeModifierOperator; -} & Span; - -export type TSMappedTypeModifierOperator = "true" | "+" | "-" | "none"; - -export type TSTemplateLiteralType = { - type: "TSTemplateLiteralType"; - quasis: Array; - types: Array; -} & Span; - -export type TSAsExpression = { - type: "TSAsExpression"; - expression: Expression; - typeAnnotation: TSType; -} & Span; - -export type TSSatisfiesExpression = { - type: "TSSatisfiesExpression"; - expression: Expression; - typeAnnotation: TSType; -} & Span; - -export type TSTypeAssertion = { - type: "TSTypeAssertion"; - expression: Expression; - typeAnnotation: TSType; -} & Span; - -export type TSImportEqualsDeclaration = { - type: "TSImportEqualsDeclaration"; - id: BindingIdentifier; - moduleReference: TSModuleReference; - importKind: ImportOrExportKind; -} & Span; - -export type TSModuleReference = - | TSExternalModuleReference - | IdentifierReference - | TSQualifiedName; - -export type TSExternalModuleReference = { - type: "TSExternalModuleReference"; - expression: StringLiteral; -} & Span; - -export type TSNonNullExpression = { - type: "TSNonNullExpression"; - expression: Expression; -} & Span; - -export type Decorator = { - type: "Decorator"; - expression: Expression; -} & Span; - -export type TSExportAssignment = { - type: "TSExportAssignment"; - expression: Expression; -} & Span; - -export type TSNamespaceExportDeclaration = { - type: "TSNamespaceExportDeclaration"; - id: IdentifierName; -} & Span; - -export type TSInstantiationExpression = { - type: "TSInstantiationExpression"; - expression: Expression; - typeParameters: TSTypeParameterInstantiation; -} & Span; - -export type ImportOrExportKind = "value" | "type"; - -export type JSDocNullableType = { - type: "JSDocNullableType"; - typeAnnotation: TSType; - postfix: boolean; -} & Span; - -export type JSDocNonNullableType = { - type: "JSDocNonNullableType"; - typeAnnotation: TSType; - postfix: boolean; -} & Span; - -export type JSDocUnknownType = { - type: "JSDocUnknownType"; -} & Span; - -export type JSXElement = { - type: "JSXElement"; - openingElement: JSXOpeningElement; - closingElement: JSXClosingElement | null; - children: Array; -} & Span; - -export type JSXOpeningElement = { - type: "JSXOpeningElement"; - selfClosing: boolean; - name: JSXElementName; - attributes: Array; - typeParameters: TSTypeParameterInstantiation | null; -} & Span; - -export type JSXClosingElement = { - type: "JSXClosingElement"; - name: JSXElementName; -} & Span; - -export type JSXFragment = { - type: "JSXFragment"; - openingFragment: JSXOpeningFragment; - closingFragment: JSXClosingFragment; - children: Array; -} & Span; - -export type JSXOpeningFragment = { - type: "JSXOpeningFragment"; -} & Span; - -export type JSXClosingFragment = { - type: "JSXClosingFragment"; -} & Span; - -export type JSXNamespacedName = { - type: "JSXNamespacedName"; - namespace: JSXIdentifier; - property: JSXIdentifier; -} & Span; - -export type JSXMemberExpression = { - type: "JSXMemberExpression"; - object: JSXMemberExpressionObject; - property: JSXIdentifier; -} & Span; - -export type JSXExpressionContainer = { - type: "JSXExpressionContainer"; - expression: JSXExpression; -} & Span; - -export type JSXExpression = - | JSXEmptyExpression - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export type JSXEmptyExpression = { - type: "JSXEmptyExpression"; -} & Span; - -export type JSXAttributeItem = JSXAttribute | JSXSpreadAttribute; - -export type JSXAttribute = { - type: "JSXAttribute"; - name: JSXAttributeName; - value: JSXAttributeValue | null; -} & Span; - -export type JSXSpreadAttribute = { - type: "JSXSpreadAttribute"; - argument: Expression; -} & Span; - -export type JSXAttributeName = JSXIdentifier | JSXNamespacedName; - -export type JSXAttributeValue = - | StringLiteral - | JSXExpressionContainer - | JSXElement - | JSXFragment; - -export type JSXIdentifier = { - type: "JSXIdentifier"; - name: string; -} & Span; - -export type JSXChild = - | JSXText - | JSXElement - | JSXFragment - | JSXExpressionContainer - | JSXSpreadChild; - -export type JSXSpreadChild = { - type: "JSXSpreadChild"; - expression: Expression; -} & Span; - -export type JSXText = { - type: "JSXText"; - value: string; -} & Span; - -export type AssignmentOperator = - | "=" - | "+=" - | "-=" - | "*=" - | "/=" - | "%=" - | "<<=" - | ">>=" - | ">>>=" - | "|=" - | "^=" - | "&=" - | "&&=" - | "||=" - | "??=" - | "**="; - -export type BinaryOperator = - | "==" - | "!=" - | "===" - | "!==" - | "<" - | "<=" - | ">" - | ">=" - | "<<" - | ">>" - | ">>>" - | "+" - | "-" - | "*" - | "/" - | "%" - | "|" - | "^" - | "&" - | "in" - | "instanceof" - | "**"; - -export type LogicalOperator = "||" | "&&" | "??"; - -export type UnaryOperator = - | "-" - | "+" - | "!" - | "~" - | "typeof" - | "void" - | "delete"; - -export type UpdateOperator = "++" | "--"; - -export type Span = { - type: "Span"; - start: number; - end: number; -}; - -export type SourceType = { - language: Language; - moduleKind: ModuleKind; - variant: LanguageVariant; -}; - -export type Language = "javascript" | "typescript" | "typescriptDefinition"; - -export type ModuleKind = "script" | "module" | "unambiguous"; - -export type LanguageVariant = "standard" | "jsx"; - -export type Pattern = { - type: "Pattern"; - body: Disjunction; -} & Span; - -export type Disjunction = { - type: "Disjunction"; - body: Array; -} & Span; - -export type Alternative = { - type: "Alternative"; - body: Array; -} & Span; - -export type Term = - | BoundaryAssertion - | LookAroundAssertion - | Quantifier - | Character - | Dot - | CharacterClassEscape - | UnicodePropertyEscape - | CharacterClass - | CapturingGroup - | IgnoreGroup - | IndexedReference - | NamedReference; - -export type BoundaryAssertion = { - type: "BoundaryAssertion"; - span: Span; - kind: BoundaryAssertionKind; -}; - -export type BoundaryAssertionKind = - | "start" - | "end" - | "boundary" - | "negativeBoundary"; - -export type LookAroundAssertion = { - type: "LookAroundAssertion"; - kind: LookAroundAssertionKind; - body: Disjunction; -} & Span; - -export type LookAroundAssertionKind = - | "lookahead" - | "negativeLookahead" - | "lookbehind" - | "negativeLookbehind"; - -export type Quantifier = { - type: "Quantifier"; - min: number; - max: number | null; - greedy: boolean; - body: Term; -} & Span; - -export type Character = { - type: "Character"; - kind: CharacterKind; - value: number; -} & Span; - -export type CharacterKind = - | "controlLetter" - | "hexadecimalEscape" - | "identifier" - | "null" - | "octal1" - | "octal2" - | "octal3" - | "singleEscape" - | "symbol" - | "unicodeEscape"; - -export type CharacterClassEscape = { - type: "CharacterClassEscape"; - kind: CharacterClassEscapeKind; -} & Span; - -export type CharacterClassEscapeKind = - | "d" - | "negativeD" - | "s" - | "negativeS" - | "w" - | "negativeW"; - -export type UnicodePropertyEscape = { - type: "UnicodePropertyEscape"; - negative: boolean; - strings: boolean; - name: string; - value: string | null; -} & Span; - -export type Dot = { - type: "Dot"; -} & Span; - -export type CharacterClass = { - type: "CharacterClass"; - negative: boolean; - strings: boolean; - kind: CharacterClassContentsKind; - body: Array; -} & Span; - -export type CharacterClassContentsKind = - | "union" - | "intersection" - | "subtraction"; - -export type CharacterClassContents = - | CharacterClassRange - | CharacterClassEscape - | UnicodePropertyEscape - | Character - | CharacterClass - | ClassStringDisjunction; - -export type CharacterClassRange = { - type: "CharacterClassRange"; - min: Character; - max: Character; -} & Span; - -export type ClassStringDisjunction = { - type: "ClassStringDisjunction"; - strings: boolean; - body: Array; -} & Span; - -export type ClassString = { - type: "ClassString"; - strings: boolean; - body: Array; -} & Span; - -export type CapturingGroup = { - type: "CapturingGroup"; - name: string | null; - body: Disjunction; -} & Span; - -export type IgnoreGroup = { - type: "IgnoreGroup"; - modifiers: Modifiers | null; - body: Disjunction; -} & Span; - -export type Modifiers = { - type: "Modifiers"; - enabling: Modifier | null; - disabling: Modifier | null; -} & Span; - -export type Modifier = { - type: "Modifier"; - ignoreCase: boolean; - multiline: boolean; - sticky: boolean; -}; - -export type IndexedReference = { - type: "IndexedReference"; - index: number; -} & Span; - -export type NamedReference = { - type: "NamedReference"; - name: string; -} & Span; diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index 345fae8036b5c..2ec0f91511581 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -1,13 +1,15 @@ use convert_case::{Case, Casing}; +use itertools::Itertools; use proc_macro2::TokenStream; use quote::quote; use super::{define_derive, Derive, DeriveOutput}; use crate::{ codegen::LateCtx, + markers::ESTreeStructAttribute, schema::{ serialize::{enum_variant_name, get_type_tag}, - EnumDef, GetGenerics, GetIdent, StructDef, TypeDef, + EnumDef, GetGenerics, GetIdent, StructDef, TypeDef, TypeName, }, }; @@ -21,12 +23,30 @@ impl Derive for DeriveESTree { } fn derive(&mut self, def: &TypeDef, _: &LateCtx) -> TokenStream { - let ident = def.ident(); + let type_def = match def { + TypeDef::Enum(def) => typescript_enum(def), + TypeDef::Struct(def) => typescript_struct(def), + }; + let type_def = quote! { + #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] + const TS_APPEND_CONTENT: &'static str = #type_def; + }; + if let TypeDef::Struct(def) = def { + if def + .markers + .estree + .as_ref() + .is_some_and(|e| e == &ESTreeStructAttribute::CustomSerialize) + { + return type_def; + } + } let body = match def { TypeDef::Enum(def) => serialize_enum(def), TypeDef::Struct(def) => serialize_struct(def), }; + let ident = def.ident(); if def.has_lifetime() { quote! { @@ -38,17 +58,19 @@ impl Derive for DeriveESTree { #body } } + #type_def } } else { quote! { - impl Serialize for #ident { - #[allow(clippy::match_same_arms, unused_mut)] - fn serialize(&self, serializer: S) -> Result - where S: Serializer, - { - #body - } - } + impl Serialize for #ident { + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where S: Serializer, + { + #body + } + } + #type_def } } } @@ -152,3 +174,68 @@ fn serialize_enum(def: &EnumDef) -> TokenStream { } } } + +// Untagged enums: "type Expression = BooleanLiteral | NullLiteral" +// Tagged enums: "type PropertyKind = 'init' | 'get' | 'set'" +fn typescript_enum(def: &EnumDef) -> String { + let union = if def.markers.estree.untagged { + def.all_variants().map(|var| type_to_string(var.fields[0].typ.name())).join(" | ") + } else { + def.all_variants().map(|var| format!("'{}'", enum_variant_name(var, def))).join(" | ") + }; + let ident = def.ident(); + format!("export type {ident} = {union};") +} + +fn typescript_struct(def: &StructDef) -> String { + let ident = def.ident(); + let mut fields = String::new(); + let mut extends = vec![]; + + if let Some(type_tag) = get_type_tag(def) { + fields.push_str(&format!("\n\ttype: '{type_tag}';")); + } + + for field in &def.fields { + if field.markers.derive_attributes.estree.skip { + continue; + } + let ty = match &field.markers.derive_attributes.tsify_type { + Some(ty) => ty.clone(), + None => type_to_string(field.typ.name()), + }; + + if field.markers.derive_attributes.estree.flatten { + extends.push(ty); + continue; + } + + let name = match &field.markers.derive_attributes.estree.rename { + Some(rename) => rename.to_string(), + None => field.name.clone().unwrap().to_case(Case::Camel), + }; + + fields.push_str(&format!("\n\t{name}: {ty};")); + } + let extends = + if extends.is_empty() { String::new() } else { format!(" & {}", extends.join(" & ")) }; + format!("export type {ident} = ({{{fields}\n}}){extends};") +} + +fn type_to_string(ty: &TypeName) -> String { + match ty { + TypeName::Ident(ident) => match ident.as_str() { + "f64" | "f32" | "usize" | "u64" | "u32" | "u16" | "u8" | "i64" | "i32" | "i16" + | "i8" => "number", + "bool" => "boolean", + "str" | "String" | "Atom" | "CompactStr" => "string", + ty => ty, + } + .to_string(), + TypeName::Vec(type_name) => format!("Array<{}>", type_to_string(type_name)), + TypeName::Box(type_name) | TypeName::Ref(type_name) | TypeName::Complex(type_name) => { + type_to_string(type_name) + } + TypeName::Opt(type_name) => format!("({}) | null", type_to_string(type_name)), + } +} diff --git a/tasks/ast_tools/src/generators/mod.rs b/tasks/ast_tools/src/generators/mod.rs index 066b1db2b0e26..b9b0c0f369405 100644 --- a/tasks/ast_tools/src/generators/mod.rs +++ b/tasks/ast_tools/src/generators/mod.rs @@ -7,13 +7,13 @@ use crate::codegen::LateCtx; mod assert_layouts; mod ast_builder; mod ast_kind; -mod typescript; +// mod typescript; mod visit; pub use assert_layouts::AssertLayouts; pub use ast_builder::AstBuilderGenerator; pub use ast_kind::AstKindGenerator; -pub use typescript::TypescriptGenerator; +// pub use typescript::TypescriptGenerator; pub use visit::{VisitGenerator, VisitMutGenerator}; /// Inserts a newline in the `TokenStream`. diff --git a/tasks/ast_tools/src/generators/typescript.rs b/tasks/ast_tools/src/generators/typescript.rs index fa385ddb6b991..2699b21813c8c 100644 --- a/tasks/ast_tools/src/generators/typescript.rs +++ b/tasks/ast_tools/src/generators/typescript.rs @@ -1,5 +1,3 @@ -use std::collections::HashMap; - use convert_case::{Case, Casing}; use itertools::Itertools; use oxc_allocator::Allocator; @@ -18,6 +16,8 @@ use crate::{ Generator, GeneratorOutput, }; +// TODO: Generate directly to types.d.ts instead of relying on wasm-bindgen + define_generator! { pub struct TypescriptGenerator; } @@ -27,8 +27,8 @@ impl Generator for TypescriptGenerator { let file = file!().replace('\\', "/"); let mut contents = format!( "\ - // To edit this generated file you have to edit `{file}`\n\ - // Auto-generated code, DO NOT EDIT DIRECTLY!\n\n" + // To edit this generated file you have to edit `{file}`\n\ + // Auto-generated code, DO NOT EDIT DIRECTLY!\n\n" ); for def in ctx.schema() { diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index 50ffbc0f2ef2e..7ddb787c2fb6c 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -24,7 +24,7 @@ use derives::{ use fmt::cargo_fmt; use generators::{ AssertLayouts, AstBuilderGenerator, AstKindGenerator, Generator, GeneratorOutput, - TypescriptGenerator, VisitGenerator, VisitMutGenerator, + VisitGenerator, VisitMutGenerator, }; use passes::{CalcLayout, Linker}; use util::{write_all_to, NormalizeError}; @@ -42,7 +42,7 @@ static SOURCE_PATHS: &[&str] = &[ ]; const AST_CRATE: &str = "crates/oxc_ast"; -const TYPESCRIPT_PACKAGE: &str = "npm/oxc-types"; +// const TYPESCRIPT_PACKAGE: &str = "npm/oxc-types"; type Result = std::result::Result; type TypeId = usize; @@ -84,7 +84,6 @@ fn main() -> std::result::Result<(), Box> { .generate(AstBuilderGenerator) .generate(VisitGenerator) .generate(VisitMutGenerator) - .generate(TypescriptGenerator) .run()?; if !cli_options.dry_run { diff --git a/tasks/ast_tools/src/markers.rs b/tasks/ast_tools/src/markers.rs index 91cccdda9e960..9827ee0fbe9fe 100644 --- a/tasks/ast_tools/src/markers.rs +++ b/tasks/ast_tools/src/markers.rs @@ -96,9 +96,10 @@ impl From<&Ident> for CloneInAttribute { } } -/// An enum representing the serde attributes (`$[serde(...)]`) that we implement for structs. -#[derive(Debug, Serialize)] +/// An enum representing the serde attributes (`#[estree(...)]`) that we implement for structs. +#[derive(Debug, Serialize, PartialEq, Eq)] pub enum ESTreeStructAttribute { + CustomSerialize, NoType, Type(String), } @@ -112,16 +113,16 @@ impl Parse for ESTreeStructAttribute { Ok(Self::Type(input.parse::()?.value())) } else { let ident = input.call(Ident::parse_any).unwrap().to_string(); - if ident == "no_type" { - Ok(Self::NoType) - } else { - panic!("Unsupported #[estree(...)] argument: {ident}"); + match ident.as_str() { + "no_type" => Ok(Self::NoType), + "custom_serialize" => Ok(Self::CustomSerialize), + _ => panic!("Unsupported #[estree(...)] argument: {ident}"), } } } } -/// A struct representing the serde attributes (`$[serde(...)]`) that we implement for enums. +/// A struct representing the serde attributes (`#[estree(...)]`) that we implement for enums. #[derive(Debug, Serialize, Default)] pub struct ESTreeEnumAttribute { pub rename_all: Option, diff --git a/tasks/ast_tools/src/schema/serialize.rs b/tasks/ast_tools/src/schema/serialize.rs index bb6532477003f..7238b6a355b72 100644 --- a/tasks/ast_tools/src/schema/serialize.rs +++ b/tasks/ast_tools/src/schema/serialize.rs @@ -17,7 +17,7 @@ pub fn enum_variant_name(var: &VariantDef, enm: &EnumDef) -> String { pub fn get_type_tag(def: &StructDef) -> Option { match def.markers.estree { - Some(ESTreeStructAttribute::NoType) => None, + Some(ESTreeStructAttribute::NoType | ESTreeStructAttribute::CustomSerialize) => None, Some(ESTreeStructAttribute::Type(ref type_name)) => Some(type_name.clone()), None => { let has_type_field = From 6db2a1ca61aaa7a42044fd26bc646fe459e52562 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 17 Oct 2024 12:42:25 -0700 Subject: [PATCH 15/28] no type on Span --- crates/oxc_span/src/generated/derive_estree.rs | 3 +-- crates/oxc_span/src/span/types.rs | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/oxc_span/src/generated/derive_estree.rs b/crates/oxc_span/src/generated/derive_estree.rs index 362b4e21e1724..8955ff0566d37 100644 --- a/crates/oxc_span/src/generated/derive_estree.rs +++ b/crates/oxc_span/src/generated/derive_estree.rs @@ -17,7 +17,6 @@ impl Serialize for Span { S: Serializer, { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "Span")?; map.serialize_entry("start", &self.start)?; map.serialize_entry("end", &self.end)?; map.end() @@ -25,7 +24,7 @@ impl Serialize for Span { } #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = - "export type Span = ({\n\ttype: 'Span';\n\tstart: number;\n\tend: number;\n});"; + "export type Span = ({\n\tstart: number;\n\tend: number;\n});"; impl Serialize for SourceType { #[allow(clippy::match_same_arms, unused_mut)] diff --git a/crates/oxc_span/src/span/types.rs b/crates/oxc_span/src/span/types.rs index 3ad8615273508..c6f5c04037b1d 100644 --- a/crates/oxc_span/src/span/types.rs +++ b/crates/oxc_span/src/span/types.rs @@ -27,6 +27,7 @@ use oxc_estree::ESTree; #[generate_derive(ESTree)] #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] // Disallow struct expression constructor `Span {}` +#[estree(no_type)] pub struct Span { pub start: u32, pub end: u32, From 422e4dce51891fc3d376eb4ba3268cba9946cfe4 Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 17 Oct 2024 13:39:31 -0700 Subject: [PATCH 16/28] remove tsify from ast features --- crates/oxc_ast/Cargo.toml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index d99e3ca3f86cf..f14a42a4df18b 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -38,13 +38,12 @@ wasm-bindgen = { workspace = true, optional = true } [features] default = [] serialize = [ - "dep:serde", - "dep:serde_json", - "dep:tsify", - "dep:wasm-bindgen", - "oxc_allocator/serialize", - "oxc_regular_expression/serialize", - "oxc_span/serialize", - "oxc_syntax/serialize", - "oxc_syntax/to_js_string", + "dep:serde", + "dep:serde_json", + "dep:wasm-bindgen", + "oxc_allocator/serialize", + "oxc_regular_expression/serialize", + "oxc_span/serialize", + "oxc_syntax/serialize", + "oxc_syntax/to_js_string", ] From 284d736585f80995477df2ab6a78aa286555387e Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 17 Oct 2024 13:41:21 -0700 Subject: [PATCH 17/28] remove tsify dep from oxc_syntax --- Cargo.lock | 2 -- crates/oxc_ast/Cargo.toml | 2 -- crates/oxc_syntax/Cargo.toml | 8 ++++++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9a990c5dccfd..5be7a4effc988 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1453,7 +1453,6 @@ dependencies = [ "oxc_syntax", "serde", "serde_json", - "tsify", "wasm-bindgen", ] @@ -1964,7 +1963,6 @@ dependencies = [ "rustc-hash", "ryu-js", "serde", - "tsify", "unicode-id-start", "wasm-bindgen", ] diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index f14a42a4df18b..643cfd23b980c 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -31,8 +31,6 @@ num-bigint = { workspace = true } serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } - -tsify = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } [features] diff --git a/crates/oxc_syntax/Cargo.toml b/crates/oxc_syntax/Cargo.toml index ac548f3bbcfc6..e07d4ddf597a5 100644 --- a/crates/oxc_syntax/Cargo.toml +++ b/crates/oxc_syntax/Cargo.toml @@ -36,13 +36,17 @@ unicode-id-start = { workspace = true } ryu-js = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"], optional = true } -tsify = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } [features] default = [] to_js_string = ["dep:ryu-js"] -serialize = ["bitflags/serde", "dep:serde", "dep:tsify", "dep:wasm-bindgen", "oxc_index/serialize"] +serialize = [ + "bitflags/serde", + "dep:serde", + "dep:wasm-bindgen", + "oxc_index/serialize", +] [package.metadata.cargo-shear] # We use `oxc_ast_macros::CloneIn` which expands to use `oxc_allocator`. From 9e4332fc645c103293e06f68271e11926b688a2a Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 20:42:24 +0000 Subject: [PATCH 18/28] [autofix.ci] apply automated fixes --- Cargo.toml | 33 +++++++++++++++------------------ crates/oxc_ast/Cargo.toml | 16 ++++++++-------- crates/oxc_syntax/Cargo.toml | 8 ++++---- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 257cc629eda1e..a5dccdfe86c55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ homepage = "https://oxc.rs" keywords = ["JavaScript", "TypeScript", "linter", "minifier", "parser"] license = "MIT" repository = "https://github.com/oxc-project/oxc" -rust-version = "1.76" # Support last 6 minor versions. +rust-version = "1.76" # Support last 6 minor versions. description = "A collection of JavaScript tools written in Rust." # @@ -19,10 +19,7 @@ description = "A collection of JavaScript tools written in Rust." absolute_paths_not_starting_with_crate = "warn" non_ascii_idents = "warn" unit-bindings = "warn" -unexpected_cfgs = { level = "warn", check-cfg = [ - 'cfg(coverage)', - 'cfg(coverage_nightly)', -] } +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)', 'cfg(coverage_nightly)'] } [workspace.lints.clippy] all = { level = "warn", priority = -1 } @@ -31,14 +28,14 @@ empty_docs = { level = "allow", priority = 1 } # From `Tsify` dbg_macro = "warn" todo = "warn" unimplemented = "warn" -print_stdout = "warn" # Must be opt-in -print_stderr = "warn" # Must be opt-in +print_stdout = "warn" # Must be opt-in +print_stderr = "warn" # Must be opt-in allow_attributes = "warn" # I like the explicitness of this rule as it removes confusion around `clone`. # This increases readability, avoids `clone` mindlessly and heap allocating by accident. clone_on_ref_ptr = "warn" # These two are mutually exclusive, I like `mod.rs` files for better fuzzy searches on module entries. -self_named_module_files = "warn" # "-Wclippy::mod_module_files" +self_named_module_files = "warn" # "-Wclippy::mod_module_files" empty_drop = "warn" empty_structs_with_brackets = "warn" exit = "warn" @@ -74,8 +71,8 @@ missing_const_for_fn = "allow" # cargo cargo = { level = "warn", priority = -1 } multiple_crate_versions = "allow" -cargo_common_metadata = "allow" # FIXME -doc_lazy_continuation = "allow" # FIXME +cargo_common_metadata = "allow" # FIXME +doc_lazy_continuation = "allow" # FIXME [workspace.dependencies] # publish = true @@ -231,22 +228,22 @@ opt-level = 3 lto = "fat" codegen-units = 1 strip = "symbols" # Set to `false` for debug information -debug = false # Set to `true` for debug information -panic = "abort" # Let it crash and force ourselves to write safe Rust +debug = false # Set to `true` for debug information +panic = "abort" # Let it crash and force ourselves to write safe Rust # Profile used for release mode, but with debugging information for profiling # and debugging. Use `cargo build --profile=release-with-debug` to build with this profile. [profile.release-with-debug] inherits = "release" -strip = false # Keep debug information in binary -debug = true # Include maximum amount of debug information +strip = false # Keep debug information in binary +debug = true # Include maximum amount of debug information # Profile for `cargo coverage` [profile.coverage] inherits = "release" -opt-level = 2 # Compile faster -codegen-units = 256 # Compile faster -lto = "thin" # Faster compile time with thin LTO +opt-level = 2 # Compile faster +codegen-units = 256 # Compile faster +lto = "thin" # Faster compile time with thin LTO debug-assertions = true # Make sure `debug_assert!`s pass -overflow-checks = true # Catch arithmetic overflow errors +overflow-checks = true # Catch arithmetic overflow errors incremental = true diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 643cfd23b980c..9d15b32dce077 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -36,12 +36,12 @@ wasm-bindgen = { workspace = true, optional = true } [features] default = [] serialize = [ - "dep:serde", - "dep:serde_json", - "dep:wasm-bindgen", - "oxc_allocator/serialize", - "oxc_regular_expression/serialize", - "oxc_span/serialize", - "oxc_syntax/serialize", - "oxc_syntax/to_js_string", + "dep:serde", + "dep:serde_json", + "dep:wasm-bindgen", + "oxc_allocator/serialize", + "oxc_regular_expression/serialize", + "oxc_span/serialize", + "oxc_syntax/serialize", + "oxc_syntax/to_js_string", ] diff --git a/crates/oxc_syntax/Cargo.toml b/crates/oxc_syntax/Cargo.toml index e07d4ddf597a5..2afef8a5f577b 100644 --- a/crates/oxc_syntax/Cargo.toml +++ b/crates/oxc_syntax/Cargo.toml @@ -42,10 +42,10 @@ wasm-bindgen = { workspace = true, optional = true } default = [] to_js_string = ["dep:ryu-js"] serialize = [ - "bitflags/serde", - "dep:serde", - "dep:wasm-bindgen", - "oxc_index/serialize", + "bitflags/serde", + "dep:serde", + "dep:wasm-bindgen", + "oxc_index/serialize", ] [package.metadata.cargo-shear] From 544dead29fb279c5821fa25bade8aff5d4cc035b Mon Sep 17 00:00:00 2001 From: Ottomated Date: Thu, 17 Oct 2024 13:55:48 -0700 Subject: [PATCH 19/28] add CompactStr type --- crates/oxc_semantic/src/symbol.rs | 1 + tasks/ast_tools/src/generators/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/crates/oxc_semantic/src/symbol.rs b/crates/oxc_semantic/src/symbol.rs index 111f03340649e..b58ea210f26d6 100644 --- a/crates/oxc_semantic/src/symbol.rs +++ b/crates/oxc_semantic/src/symbol.rs @@ -22,6 +22,7 @@ use crate::{ #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export type IndexVec = Array; +export type CompactStr = string; "#; /// Symbol Table diff --git a/tasks/ast_tools/src/generators/mod.rs b/tasks/ast_tools/src/generators/mod.rs index b9b0c0f369405..4cbca6652ae2f 100644 --- a/tasks/ast_tools/src/generators/mod.rs +++ b/tasks/ast_tools/src/generators/mod.rs @@ -28,6 +28,7 @@ pub trait Generator { fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput; } +#[expect(dead_code)] #[derive(Debug, Clone)] pub enum GeneratorOutput { Rust(/* output path */ PathBuf, TokenStream), From 9e22bfe8d32daa9f36658cc13f16c766065fe380 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 08:50:11 +0100 Subject: [PATCH 20/28] fix: restore `features = ["derive"]` for `serde` in `oxc_ast` crate --- crates/oxc_ast/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_ast/Cargo.toml b/crates/oxc_ast/Cargo.toml index 9d15b32dce077..83887147130d8 100644 --- a/crates/oxc_ast/Cargo.toml +++ b/crates/oxc_ast/Cargo.toml @@ -29,7 +29,7 @@ oxc_syntax = { workspace = true } bitflags = { workspace = true } num-bigint = { workspace = true } -serde = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"], optional = true } serde_json = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } From 5065bf3c38a0c1385e275159b0c288aaf56182f2 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 08:54:32 +0100 Subject: [PATCH 21/28] style: restore `Cargo.toml` formatting --- crates/oxc_regular_expression/Cargo.toml | 7 +------ crates/oxc_syntax/Cargo.toml | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/crates/oxc_regular_expression/Cargo.toml b/crates/oxc_regular_expression/Cargo.toml index 7603151d3d425..b4f092286c340 100644 --- a/crates/oxc_regular_expression/Cargo.toml +++ b/crates/oxc_regular_expression/Cargo.toml @@ -35,9 +35,4 @@ wasm-bindgen = { workspace = true, optional = true } [features] default = [] -serialize = [ - "dep:serde", - "dep:wasm-bindgen", - "oxc_allocator/serialize", - "oxc_span/serialize", -] +serialize = ["dep:serde", "dep:wasm-bindgen", "oxc_allocator/serialize", "oxc_span/serialize"] diff --git a/crates/oxc_syntax/Cargo.toml b/crates/oxc_syntax/Cargo.toml index 2afef8a5f577b..3a26101356bae 100644 --- a/crates/oxc_syntax/Cargo.toml +++ b/crates/oxc_syntax/Cargo.toml @@ -41,12 +41,7 @@ wasm-bindgen = { workspace = true, optional = true } [features] default = [] to_js_string = ["dep:ryu-js"] -serialize = [ - "bitflags/serde", - "dep:serde", - "dep:wasm-bindgen", - "oxc_index/serialize", -] +serialize = ["bitflags/serde", "dep:serde", "dep:wasm-bindgen", "oxc_index/serialize"] [package.metadata.cargo-shear] # We use `oxc_ast_macros::CloneIn` which expands to use `oxc_allocator`. From 6a3fb3ebaaebe7863bd043a3d01914480b7f042d Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 08:55:14 +0100 Subject: [PATCH 22/28] style: order `#[generate_derive]` after `#[derive]` --- crates/oxc_span/src/source_type/mod.rs | 8 ++++---- crates/oxc_span/src/span/types.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/oxc_span/src/source_type/mod.rs b/crates/oxc_span/src/source_type/mod.rs index af82baa3a195a..76049d02f70b2 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -11,8 +11,8 @@ pub use error::UnknownExtension; /// Source Type for JavaScript vs TypeScript / Script vs Module / JSX #[ast] -#[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[generate_derive(ESTree)] #[estree(no_type)] pub struct SourceType { /// JavaScript or TypeScript, default JavaScript @@ -27,8 +27,8 @@ pub struct SourceType { /// JavaScript or TypeScript #[ast] -#[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[generate_derive(ESTree)] pub enum Language { /// Indicates a JavaScript or JSX file #[estree(rename = "javascript")] @@ -43,8 +43,8 @@ pub enum Language { /// Script or Module #[ast] -#[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[generate_derive(ESTree)] #[estree(rename_all = "camelCase")] pub enum ModuleKind { /// Regular JS script or CommonJS file @@ -64,8 +64,8 @@ pub enum ModuleKind { /// JSX for JavaScript and TypeScript #[ast] -#[generate_derive(ESTree)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[generate_derive(ESTree)] #[estree(rename_all = "camelCase")] pub enum LanguageVariant { /// Standard JavaScript or TypeScript without any language extensions. Stage diff --git a/crates/oxc_span/src/span/types.rs b/crates/oxc_span/src/span/types.rs index b4baae5471af4..9ab08bfde8118 100644 --- a/crates/oxc_span/src/span/types.rs +++ b/crates/oxc_span/src/span/types.rs @@ -12,8 +12,8 @@ use oxc_estree::ESTree; /// AST nodes without considering their locations (e.g. to see if they have the /// same content), use [`ContentHash`](crate::hash::ContentHash) instead. #[ast] -#[generate_derive(ESTree)] #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[generate_derive(ESTree)] #[non_exhaustive] // Disallow struct expression constructor `Span {}` #[estree(no_type)] pub struct Span { From 6db7396d1cc02aa91290de59ede5a7cc0959b482 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 08:55:49 +0100 Subject: [PATCH 23/28] style: fix indentation --- tasks/ast_tools/src/derives/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tasks/ast_tools/src/derives/mod.rs b/tasks/ast_tools/src/derives/mod.rs index 018c37ec94583..e285652372745 100644 --- a/tasks/ast_tools/src/derives/mod.rs +++ b/tasks/ast_tools/src/derives/mod.rs @@ -108,11 +108,12 @@ macro_rules! define_derive { .fold(Vec::new(), |mut acc, (path, (modules, streams))| { let mut modules = Vec::from_iter(modules); modules.sort(); - let file_name = Self::trait_name().to_case(Case::Snake); - let file_name = match file_name.as_str() { - "es_tree" => "estree", - f => f, - }; + + let file_name = Self::trait_name().to_case(Case::Snake); + let file_name = match file_name.as_str() { + "es_tree" => "estree", + f => f, + }; acc.push(( $crate::output( From 566eb50864c7c1d73603acbc143368eef4b3dcb7 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 08:56:52 +0100 Subject: [PATCH 24/28] refactor: remove unused `TypescriptGenerator` --- Cargo.lock | 4 - tasks/ast_tools/Cargo.toml | 4 - tasks/ast_tools/src/generators/mod.rs | 2 - tasks/ast_tools/src/generators/typescript.rs | 135 ------------------- tasks/ast_tools/src/main.rs | 1 - 5 files changed, 146 deletions(-) delete mode 100644 tasks/ast_tools/src/generators/typescript.rs diff --git a/Cargo.lock b/Cargo.lock index 5be7a4effc988..13b3922440cb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1473,10 +1473,6 @@ dependencies = [ "convert_case", "itertools", "lazy_static", - "oxc_allocator", - "oxc_parser", - "oxc_prettier", - "oxc_span", "prettyplease", "proc-macro2", "quote", diff --git a/tasks/ast_tools/Cargo.toml b/tasks/ast_tools/Cargo.toml index 23924e64ff1ce..427ac0533ac7d 100644 --- a/tasks/ast_tools/Cargo.toml +++ b/tasks/ast_tools/Cargo.toml @@ -18,10 +18,6 @@ bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"] convert_case = { workspace = true } itertools = { workspace = true } lazy_static = { workspace = true } -oxc_allocator.workspace = true -oxc_parser.workspace = true -oxc_prettier.workspace = true -oxc_span.workspace = true prettyplease = { workspace = true } proc-macro2 = { workspace = true } quote = { workspace = true } diff --git a/tasks/ast_tools/src/generators/mod.rs b/tasks/ast_tools/src/generators/mod.rs index 4cbca6652ae2f..833df76af9e9a 100644 --- a/tasks/ast_tools/src/generators/mod.rs +++ b/tasks/ast_tools/src/generators/mod.rs @@ -7,13 +7,11 @@ use crate::codegen::LateCtx; mod assert_layouts; mod ast_builder; mod ast_kind; -// mod typescript; mod visit; pub use assert_layouts::AssertLayouts; pub use ast_builder::AstBuilderGenerator; pub use ast_kind::AstKindGenerator; -// pub use typescript::TypescriptGenerator; pub use visit::{VisitGenerator, VisitMutGenerator}; /// Inserts a newline in the `TokenStream`. diff --git a/tasks/ast_tools/src/generators/typescript.rs b/tasks/ast_tools/src/generators/typescript.rs deleted file mode 100644 index 2699b21813c8c..0000000000000 --- a/tasks/ast_tools/src/generators/typescript.rs +++ /dev/null @@ -1,135 +0,0 @@ -use convert_case::{Case, Casing}; -use itertools::Itertools; -use oxc_allocator::Allocator; -use oxc_parser::{ParseOptions, Parser}; -use oxc_prettier::{Prettier, PrettierOptions, TrailingComma}; -use oxc_span::SourceType; - -use super::define_generator; -use crate::{ - codegen::LateCtx, - output, - schema::{ - serialize::{enum_variant_name, get_type_tag}, - EnumDef, GetIdent, StructDef, TypeDef, TypeName, - }, - Generator, GeneratorOutput, -}; - -// TODO: Generate directly to types.d.ts instead of relying on wasm-bindgen - -define_generator! { - pub struct TypescriptGenerator; -} - -impl Generator for TypescriptGenerator { - fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput { - let file = file!().replace('\\', "/"); - let mut contents = format!( - "\ - // To edit this generated file you have to edit `{file}`\n\ - // Auto-generated code, DO NOT EDIT DIRECTLY!\n\n" - ); - - for def in ctx.schema() { - if !def.generates_derive("ESTree") { - continue; - } - let type_def = match def { - TypeDef::Struct(it) => generate_struct(it), - TypeDef::Enum(it) => generate_enum(it), - }; - contents.push_str(&type_def); - contents.push_str("\n\n"); - } - - GeneratorOutput::Raw(output(crate::TYPESCRIPT_PACKAGE, "types.d.ts"), contents) - } -} - -// Untagged enums: "type Expression = BooleanLiteral | NullLiteral" -// Tagged enums: "type PropertyKind = 'init' | 'get' | 'set'" -fn generate_enum(def: &EnumDef) -> String { - let union = if def.markers.estree.untagged { - def.all_variants().map(|var| type_to_string(var.fields[0].typ.name())).join(" | ") - } else { - def.all_variants().map(|var| format!("'{}'", enum_variant_name(var, def))).join(" | ") - }; - let ident = def.ident(); - format!("export type {ident} = {union};") -} - -fn generate_struct(def: &StructDef) -> String { - let ident = def.ident(); - let mut fields = String::new(); - let mut extends = vec![]; - - if let Some(type_tag) = get_type_tag(def) { - fields.push_str(&format!("\n\ttype: '{type_tag}';")); - } - - for field in &def.fields { - if field.markers.derive_attributes.estree.skip { - continue; - } - let ty = match &field.markers.derive_attributes.tsify_type { - Some(ty) => ty.clone(), - None => type_to_string(field.typ.name()), - }; - - if field.markers.derive_attributes.estree.flatten { - extends.push(ty); - continue; - } - - let name = match &field.markers.derive_attributes.estree.rename { - Some(rename) => rename.to_string(), - None => field.name.clone().unwrap().to_case(Case::Camel), - }; - - fields.push_str(&format!("\n\t{name}: {ty};")); - } - let extends = - if extends.is_empty() { String::new() } else { format!(" & {}", extends.join(" & ")) }; - format!("export type {ident} = ({{{fields}\n}}){extends};") -} - -fn type_to_string(ty: &TypeName) -> String { - match ty { - TypeName::Ident(ident) => match ident.as_str() { - "f64" | "f32" | "usize" | "u64" | "u32" | "u16" | "u8" | "i64" | "i32" | "i16" - | "i8" => "number", - "bool" => "boolean", - "str" | "String" | "Atom" | "CompactStr" => "string", - ty => ty, - } - .to_string(), - TypeName::Vec(type_name) => format!("Array<{}>", type_to_string(type_name)), - TypeName::Box(type_name) | TypeName::Ref(type_name) | TypeName::Complex(type_name) => { - type_to_string(type_name) - } - TypeName::Opt(type_name) => format!("({}) | null", type_to_string(type_name)), - } -} - -/// Unusable until oxc_prettier supports comments -#[allow(dead_code)] -fn format_typescript(source_text: &str) -> String { - let allocator = Allocator::default(); - let source_type = SourceType::ts(); - let ret = Parser::new(&allocator, source_text, source_type) - .with_options(ParseOptions { preserve_parens: false, ..ParseOptions::default() }) - .parse(); - Prettier::new( - &allocator, - source_text, - ret.trivias, - PrettierOptions { - semi: true, - trailing_comma: TrailingComma::All, - single_quote: true, - ..PrettierOptions::default() - }, - ) - .build(&ret.program) -} diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index f5b3756c7bce3..c500924f418c4 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -43,7 +43,6 @@ static SOURCE_PATHS: &[&str] = &[ ]; const AST_CRATE: &str = "crates/oxc_ast"; -// const TYPESCRIPT_PACKAGE: &str = "npm/oxc-types"; type Result = std::result::Result; type TypeId = usize; From 5f9d39844f4337878f0e376f61be9ecfe77798e3 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 08:57:32 +0100 Subject: [PATCH 25/28] refactor: revert `GeneratorOutput` --- tasks/ast_tools/src/codegen.rs | 5 +---- tasks/ast_tools/src/generators/assert_layouts.rs | 2 +- tasks/ast_tools/src/generators/ast_builder.rs | 2 +- tasks/ast_tools/src/generators/ast_kind.rs | 2 +- tasks/ast_tools/src/generators/mod.rs | 6 +----- tasks/ast_tools/src/generators/visit.rs | 4 ++-- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/tasks/ast_tools/src/codegen.rs b/tasks/ast_tools/src/codegen.rs index 8232459898d61..582c278115a4a 100644 --- a/tasks/ast_tools/src/codegen.rs +++ b/tasks/ast_tools/src/codegen.rs @@ -57,10 +57,7 @@ impl From<(PathBuf, TokenStream)> for SideEffect { impl From for SideEffect { fn from(output: GeneratorOutput) -> Self { - match output { - GeneratorOutput::Rust(path, stream) => Self::from((path, stream)), - GeneratorOutput::Raw(path, content) => Self(path, content.into()), - } + Self::from((output.0, output.1)) } } diff --git a/tasks/ast_tools/src/generators/assert_layouts.rs b/tasks/ast_tools/src/generators/assert_layouts.rs index 2a8c042fec5c0..6e58c7a176f92 100644 --- a/tasks/ast_tools/src/generators/assert_layouts.rs +++ b/tasks/ast_tools/src/generators/assert_layouts.rs @@ -28,7 +28,7 @@ impl Generator for AssertLayouts { let header = generated_header!(); - GeneratorOutput::Rust( + GeneratorOutput( output(crate::AST_CRATE, "assert_layouts.rs"), quote! { #header diff --git a/tasks/ast_tools/src/generators/ast_builder.rs b/tasks/ast_tools/src/generators/ast_builder.rs index b31004547a81f..d3ec9bcd8dc68 100644 --- a/tasks/ast_tools/src/generators/ast_builder.rs +++ b/tasks/ast_tools/src/generators/ast_builder.rs @@ -34,7 +34,7 @@ impl Generator for AstBuilderGenerator { let header = generated_header!(); - GeneratorOutput::Rust( + GeneratorOutput( output(crate::AST_CRATE, "ast_builder.rs"), quote! { #header diff --git a/tasks/ast_tools/src/generators/ast_kind.rs b/tasks/ast_tools/src/generators/ast_kind.rs index 77be365818be8..088e43053fc6f 100644 --- a/tasks/ast_tools/src/generators/ast_kind.rs +++ b/tasks/ast_tools/src/generators/ast_kind.rs @@ -175,7 +175,7 @@ impl Generator for AstKindGenerator { let header = generated_header!(); - GeneratorOutput::Rust( + GeneratorOutput( output(crate::AST_CRATE, "ast_kind.rs"), quote! { #header diff --git a/tasks/ast_tools/src/generators/mod.rs b/tasks/ast_tools/src/generators/mod.rs index 833df76af9e9a..e16f356d06f41 100644 --- a/tasks/ast_tools/src/generators/mod.rs +++ b/tasks/ast_tools/src/generators/mod.rs @@ -26,12 +26,8 @@ pub trait Generator { fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput; } -#[expect(dead_code)] #[derive(Debug, Clone)] -pub enum GeneratorOutput { - Rust(/* output path */ PathBuf, TokenStream), - Raw(/* output path */ PathBuf, String), -} +pub struct GeneratorOutput(/* output path */ pub PathBuf, pub TokenStream); macro_rules! define_generator { ($vis:vis struct $ident:ident $($lifetime:lifetime)? $($rest:tt)*) => { diff --git a/tasks/ast_tools/src/generators/visit.rs b/tasks/ast_tools/src/generators/visit.rs index b30270bcb0efe..b017f04ad835e 100644 --- a/tasks/ast_tools/src/generators/visit.rs +++ b/tasks/ast_tools/src/generators/visit.rs @@ -28,13 +28,13 @@ define_generator! { impl Generator for VisitGenerator { fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput { - GeneratorOutput::Rust(output(crate::AST_CRATE, "visit.rs"), generate_visit::(ctx)) + GeneratorOutput(output(crate::AST_CRATE, "visit.rs"), generate_visit::(ctx)) } } impl Generator for VisitMutGenerator { fn generate(&mut self, ctx: &LateCtx) -> GeneratorOutput { - GeneratorOutput::Rust(output(crate::AST_CRATE, "visit_mut.rs"), generate_visit::(ctx)) + GeneratorOutput(output(crate::AST_CRATE, "visit_mut.rs"), generate_visit::(ctx)) } } From 4d71118910c0a5470d9c832935e1ec6680a251da Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 08:58:12 +0100 Subject: [PATCH 26/28] fix: correct comments --- tasks/ast_tools/src/markers.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/ast_tools/src/markers.rs b/tasks/ast_tools/src/markers.rs index 9827ee0fbe9fe..9b3996383fcf9 100644 --- a/tasks/ast_tools/src/markers.rs +++ b/tasks/ast_tools/src/markers.rs @@ -96,7 +96,7 @@ impl From<&Ident> for CloneInAttribute { } } -/// An enum representing the serde attributes (`#[estree(...)]`) that we implement for structs. +/// An enum representing the `#[estree(...)]` attributes that we implement for structs. #[derive(Debug, Serialize, PartialEq, Eq)] pub enum ESTreeStructAttribute { CustomSerialize, @@ -122,7 +122,7 @@ impl Parse for ESTreeStructAttribute { } } -/// A struct representing the serde attributes (`#[estree(...)]`) that we implement for enums. +/// A struct representing the `#[estree(...)]` attributes that we implement for enums. #[derive(Debug, Serialize, Default)] pub struct ESTreeEnumAttribute { pub rename_all: Option, @@ -164,7 +164,7 @@ impl Parse for ESTreeEnumAttribute { } } -/// A struct representing the serde attributes (`$[serde(...)]`) that we implement for fields. +/// A struct representing the `#[estree(...)]` attributes that we implement for fields. #[derive(Debug, Serialize, Default)] pub struct ESTreeFieldAttribute { pub flatten: bool, From b78e854b32d1debf9769075333b1a8ea34c4ce5b Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 09:02:10 +0100 Subject: [PATCH 27/28] fix: `type` field in TS defs on structs with `#[estree(custom_serialize)]` attr --- crates/oxc_ast/src/generated/derive_estree.rs | 13 ++++++------- tasks/ast_tools/src/schema/serialize.rs | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs index 9827555df49fc..05f63a70110d4 100644 --- a/crates/oxc_ast/src/generated/derive_estree.rs +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -1027,10 +1027,10 @@ const TS_APPEND_CONTENT: &'static str = "export type AssignmentTargetPattern = ArrayAssignmentTarget | ObjectAssignmentTarget;"; #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = "export type ArrayAssignmentTarget = ({\n\telements: Array;\n}) & Span;"; +const TS_APPEND_CONTENT: &'static str = "export type ArrayAssignmentTarget = ({\n\ttype: 'ArrayAssignmentTarget';\n\telements: Array;\n}) & Span;"; #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = "export type ObjectAssignmentTarget = ({\n\tproperties: Array;\n}) & Span;"; +const TS_APPEND_CONTENT: &'static str = "export type ObjectAssignmentTarget = ({\n\ttype: 'ObjectAssignmentTarget';\n\tproperties: Array;\n}) & Span;"; impl<'a> Serialize for AssignmentTargetRest<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1927,7 +1927,7 @@ impl<'a> Serialize for AssignmentPattern<'a> { const TS_APPEND_CONTENT: &'static str = "export type AssignmentPattern = ({\n\ttype: 'AssignmentPattern';\n\tleft: BindingPattern;\n\tright: Expression;\n}) & Span;"; #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = "export type ObjectPattern = ({\n\tproperties: Array;\n}) & Span;"; +const TS_APPEND_CONTENT: &'static str = "export type ObjectPattern = ({\n\ttype: 'ObjectPattern';\n\tproperties: Array;\n}) & Span;"; impl<'a> Serialize for BindingProperty<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -1949,7 +1949,7 @@ impl<'a> Serialize for BindingProperty<'a> { const TS_APPEND_CONTENT: &'static str = "export type BindingProperty = ({\n\ttype: 'BindingProperty';\n\tkey: PropertyKey;\n\tvalue: BindingPattern;\n\tshorthand: boolean;\n\tcomputed: boolean;\n}) & Span;"; #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = "export type ArrayPattern = ({\n\telements: Array;\n}) & Span;"; +const TS_APPEND_CONTENT: &'static str = "export type ArrayPattern = ({\n\ttype: 'ArrayPattern';\n\telements: Array;\n}) & Span;"; impl<'a> Serialize for BindingRestElement<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -2019,7 +2019,7 @@ impl Serialize for FunctionType { const TS_APPEND_CONTENT: &'static str = "export type FunctionType = 'FunctionDeclaration' | 'FunctionExpression' | 'TSDeclareFunction' | 'TSEmptyBodyFunctionExpression';"; #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = "export type FormalParameters = ({\n\tkind: FormalParameterKind;\n\titems: Array;\n}) & Span;"; +const TS_APPEND_CONTENT: &'static str = "export type FormalParameters = ({\n\ttype: 'FormalParameters';\n\tkind: FormalParameterKind;\n\titems: Array;\n}) & Span;"; impl<'a> Serialize for FormalParameter<'a> { #[allow(clippy::match_same_arms, unused_mut)] @@ -4010,8 +4010,7 @@ const TS_APPEND_CONTENT: &'static str = "export type TSModuleDeclarationBody = TSModuleDeclaration | TSModuleBlock;"; #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] -const TS_APPEND_CONTENT: &'static str = - "export type TSModuleBlock = ({\n\tbody: Array;\n}) & Span;"; +const TS_APPEND_CONTENT: &'static str = "export type TSModuleBlock = ({\n\ttype: 'TSModuleBlock';\n\tbody: Array;\n}) & Span;"; impl<'a> Serialize for TSTypeLiteral<'a> { #[allow(clippy::match_same_arms, unused_mut)] diff --git a/tasks/ast_tools/src/schema/serialize.rs b/tasks/ast_tools/src/schema/serialize.rs index 7238b6a355b72..abd61ce7cc98b 100644 --- a/tasks/ast_tools/src/schema/serialize.rs +++ b/tasks/ast_tools/src/schema/serialize.rs @@ -17,9 +17,9 @@ pub fn enum_variant_name(var: &VariantDef, enm: &EnumDef) -> String { pub fn get_type_tag(def: &StructDef) -> Option { match def.markers.estree { - Some(ESTreeStructAttribute::NoType | ESTreeStructAttribute::CustomSerialize) => None, + Some(ESTreeStructAttribute::NoType) => None, Some(ESTreeStructAttribute::Type(ref type_name)) => Some(type_name.clone()), - None => { + Some(ESTreeStructAttribute::CustomSerialize) | None => { let has_type_field = def.fields.iter().any(|f| matches!(f.name.as_deref(), Some("type"))); if has_type_field { From 7639831457d05401863ca8846599d81aa0e8da0a Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 19 Oct 2024 09:06:08 +0100 Subject: [PATCH 28/28] fix: use `| null` to match other type defs for `FormalParameterRest` --- crates/oxc_ast/src/serialize.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_ast/src/serialize.rs b/crates/oxc_ast/src/serialize.rs index 4e3adacd49733..a797dfdd2c05c 100644 --- a/crates/oxc_ast/src/serialize.rs +++ b/crates/oxc_ast/src/serialize.rs @@ -165,7 +165,7 @@ const TS_APPEND_CONTENT: &'static str = r#" export type FormalParameterRest = ({ type: "RestElement", argument: BindingPatternKind, - typeAnnotation?: TSTypeAnnotation, + typeAnnotation: TSTypeAnnotation | null, optional: boolean, }) & Span; "#;