diff --git a/.github/.generated_ast_watch_list.yml b/.github/.generated_ast_watch_list.yml index b801c6d9f9d89..542c3a26c2b48 100644 --- a/.github/.generated_ast_watch_list.yml +++ b/.github/.generated_ast_watch_list.yml @@ -23,6 +23,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_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 8214921227c8e..13b3922440cb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1447,12 +1447,12 @@ dependencies = [ "num-bigint", "oxc_allocator", "oxc_ast_macros", + "oxc_estree", "oxc_regular_expression", "oxc_span", "oxc_syntax", "serde", "serde_json", - "tsify", "wasm-bindgen", ] @@ -1596,6 +1596,10 @@ dependencies = [ "oxc_syntax", ] +[[package]] +name = "oxc_estree" +version = "0.31.0" + [[package]] name = "oxc_index" version = "0.31.0" @@ -1857,11 +1861,11 @@ dependencies = [ "oxc_allocator", "oxc_ast_macros", "oxc_diagnostics", + "oxc_estree", "oxc_span", "phf 0.11.2", "rustc-hash", "serde", - "tsify", "unicode-id-start", "wasm-bindgen", ] @@ -1932,9 +1936,9 @@ dependencies = [ "miette", "oxc_allocator", "oxc_ast_macros", + "oxc_estree", "schemars", "serde", - "tsify", "wasm-bindgen", ] @@ -1948,13 +1952,13 @@ dependencies = [ "nonmax", "oxc_allocator", "oxc_ast_macros", + "oxc_estree", "oxc_index", "oxc_span", "phf 0.11.2", "rustc-hash", "ryu-js", "serde", - "tsify", "unicode-id-start", "wasm-bindgen", ] diff --git a/Cargo.toml b/Cargo.toml index 27c34a29cce6e..a5dccdfe86c55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,6 +85,7 @@ 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_ecmascript = { version = "0.31.0", path = "crates/oxc_ecmascript" } +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 8680c7e2a1325..83887147130d8 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 } @@ -30,8 +31,6 @@ num-bigint = { workspace = true } serde = { workspace = true, features = ["derive"], optional = true } serde_json = { workspace = true, optional = true } - -tsify = { workspace = true, optional = true } wasm-bindgen = { workspace = true, optional = true } [features] @@ -39,7 +38,6 @@ default = [] serialize = [ "dep:serde", "dep:serde_json", - "dep:tsify", "dep:wasm-bindgen", "oxc_allocator/serialize", "oxc_regular_expression/serialize", diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 719e69c543ba7..2ee58141e8d61 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -2,13 +2,11 @@ // 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}; 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::{ @@ -18,10 +16,6 @@ use oxc_syntax::{ scope::ScopeId, symbol::SymbolId, }; -#[cfg(feature = "serialize")] -use serde::Serialize; -#[cfg(feature = "serialize")] -use tsify::Tsify; use super::{macros::inherit_variants, *}; @@ -32,22 +26,20 @@ 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)] pub struct Program<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub source_type: SourceType, - #[serde(skip)] + #[estree(skip)] pub source_text: &'a str, /// Sorted comments - #[serde(skip)] + #[estree(skip)] pub comments: Vec<'a, Comment>, 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>, } @@ -60,9 +52,8 @@ 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)] +#[estree(untagged)] pub enum Expression<'a> { /// See [`BooleanLiteral`] for AST node details. BooleanLiteral(Box<'a, BooleanLiteral>) = 0, @@ -210,11 +201,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(type = "Identifier")] pub struct IdentifierName<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, } @@ -226,11 +216,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(type = "Identifier")] pub struct IdentifierReference<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the identifier being referenced. pub name: Atom<'a>, @@ -239,7 +228,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>, } @@ -251,11 +240,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(type = "Identifier")] pub struct BindingIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The identifier name being bound. pub name: Atom<'a>, @@ -265,7 +253,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>, } @@ -277,11 +265,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(type = "Identifier")] pub struct LabelIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, } @@ -291,11 +278,9 @@ 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)] pub struct ThisExpression { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -304,17 +289,15 @@ 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)] 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, } @@ -326,9 +309,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, @@ -358,24 +340,21 @@ 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)] 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)] +#[estree(untagged)] pub enum ObjectPropertyKind<'a> { /// `a: 1` in `const obj = { a: 1 };` ObjectProperty(Box<'a, ObjectProperty<'a>>) = 0, @@ -388,11 +367,9 @@ 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)] pub struct ObjectProperty<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: PropertyKind, pub key: PropertyKey<'a>, @@ -411,9 +388,8 @@ 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)] +#[estree(untagged)] pub enum PropertyKey<'a> { /// `a` in `const obj = { a: 1 }; obj.a;` StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64, @@ -427,9 +403,8 @@ 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)] +#[estree(rename_all = "camelCase")] pub enum PropertyKind { /// `a: 1` in `const obj = { a: 1 };` Init = 0, @@ -444,11 +419,9 @@ 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)] pub struct TemplateLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub quasis: Vec<'a, TemplateElement<'a>>, pub expressions: Vec<'a, Expression<'a>>, @@ -459,11 +432,9 @@ 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)] pub struct TaggedTemplateExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub tag: Expression<'a>, pub quasi: TemplateLiteral<'a>, @@ -475,11 +446,9 @@ 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)] pub struct TemplateElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub tail: bool, pub value: TemplateElementValue<'a>, @@ -488,8 +457,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)] +#[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. @@ -507,9 +476,8 @@ 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)] +#[estree(untagged)] pub enum MemberExpression<'a> { /// `ar[0]` in `const ar = [1, 2]; ar[0];` ComputedMemberExpression(Box<'a, ComputedMemberExpression<'a>>) = 48, @@ -535,11 +503,9 @@ 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)] pub struct ComputedMemberExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object: Expression<'a>, pub expression: Expression<'a>, @@ -551,11 +517,9 @@ 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)] pub struct StaticMemberExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object: Expression<'a>, pub property: IdentifierName<'a>, @@ -567,11 +531,9 @@ 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)] pub struct PrivateFieldExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object: Expression<'a>, pub field: PrivateIdentifier<'a>, @@ -596,11 +558,9 @@ 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)] pub struct CallExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub callee: Expression<'a>, pub type_parameters: Option>>, @@ -622,11 +582,9 @@ 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)] pub struct NewExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub callee: Expression<'a>, pub arguments: Vec<'a, Argument<'a>>, @@ -638,11 +596,9 @@ 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)] pub struct MetaProperty<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub meta: IdentifierName<'a>, pub property: IdentifierName<'a>, @@ -653,11 +609,9 @@ 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)] pub struct SpreadElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The expression being spread. pub argument: Expression<'a>, @@ -671,9 +625,8 @@ 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)] +#[estree(untagged)] pub enum Argument<'a> { /// `...[1, 2]` in `const arr = [...[1, 2]];` SpreadElement(Box<'a, SpreadElement<'a>>) = 64, @@ -687,11 +640,9 @@ 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)] pub struct UpdateExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub operator: UpdateOperator, pub prefix: bool, @@ -703,11 +654,9 @@ 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)] pub struct UnaryExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub operator: UnaryOperator, pub argument: Expression<'a>, @@ -718,11 +667,9 @@ 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)] pub struct BinaryExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: Expression<'a>, pub operator: BinaryOperator, @@ -734,11 +681,9 @@ 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)] pub struct PrivateInExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: PrivateIdentifier<'a>, pub operator: BinaryOperator, // BinaryOperator::In @@ -750,11 +695,9 @@ 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)] pub struct LogicalExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: Expression<'a>, pub operator: LogicalOperator, @@ -766,11 +709,9 @@ 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)] pub struct ConditionalExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub test: Expression<'a>, pub consequent: Expression<'a>, @@ -782,11 +723,9 @@ 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)] pub struct AssignmentExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub operator: AssignmentOperator, pub left: AssignmentTarget<'a>, @@ -802,9 +741,8 @@ 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)] +#[estree(untagged)] pub enum AssignmentTarget<'a> { // `SimpleAssignmentTarget` variants added here by `inherit_variants!` macro @inherit SimpleAssignmentTarget @@ -821,9 +759,8 @@ 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)] +#[estree(untagged)] pub enum SimpleAssignmentTarget<'a> { AssignmentTargetIdentifier(Box<'a, IdentifierReference<'a>>) = 0, TSAsExpression(Box<'a, TSAsExpression<'a>>) = 1, @@ -876,9 +813,8 @@ 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)] +#[estree(untagged)] pub enum AssignmentTargetPattern<'a> { ArrayAssignmentTarget(Box<'a, ArrayAssignmentTarget<'a>>) = 8, ObjectAssignmentTarget(Box<'a, ObjectAssignmentTarget<'a>>) = 9, @@ -898,17 +834,16 @@ 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))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] 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, } @@ -917,15 +852,14 @@ 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))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] 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>, } @@ -934,13 +868,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(type = "RestElement")] pub struct AssignmentTargetRest<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, - #[serde(rename = "argument")] + #[estree(rename = "argument")] pub target: AssignmentTarget<'a>, } @@ -952,9 +885,8 @@ 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)] +#[estree(untagged)] pub enum AssignmentTargetMaybeDefault<'a> { AssignmentTargetWithDefault(Box<'a, AssignmentTargetWithDefault<'a>>) = 16, // `AssignmentTarget` variants added here by `inherit_variants!` macro @@ -964,11 +896,9 @@ 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)] pub struct AssignmentTargetWithDefault<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub binding: AssignmentTarget<'a>, pub init: Expression<'a>, @@ -976,9 +906,8 @@ 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)] +#[estree(untagged)] pub enum AssignmentTargetProperty<'a> { AssignmentTargetPropertyIdentifier(Box<'a, AssignmentTargetPropertyIdentifier<'a>>) = 0, AssignmentTargetPropertyProperty(Box<'a, AssignmentTargetPropertyProperty<'a>>) = 1, @@ -989,11 +918,9 @@ 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)] pub struct AssignmentTargetPropertyIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub binding: IdentifierReference<'a>, pub init: Option>, @@ -1004,11 +931,9 @@ 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)] pub struct AssignmentTargetPropertyProperty<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: PropertyKey<'a>, pub binding: AssignmentTargetMaybeDefault<'a>, @@ -1019,11 +944,9 @@ 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)] pub struct SequenceExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expressions: Vec<'a, Expression<'a>>, } @@ -1033,11 +956,9 @@ 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)] pub struct Super { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -1046,11 +967,9 @@ 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)] pub struct AwaitExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub argument: Expression<'a>, } @@ -1060,11 +979,9 @@ 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)] pub struct ChainExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: ChainElement<'a>, } @@ -1077,9 +994,8 @@ 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)] +#[estree(untagged)] pub enum ChainElement<'a> { CallExpression(Box<'a, CallExpression<'a>>) = 0, // `MemberExpression` variants added here by `inherit_variants!` macro @@ -1092,11 +1008,9 @@ 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)] pub struct ParenthesizedExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1110,9 +1024,8 @@ 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)] +#[estree(untagged)] pub enum Statement<'a> { // Statements BlockStatement(Box<'a, BlockStatement<'a>>) = 0, @@ -1145,11 +1058,9 @@ 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)] pub struct Directive<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Directive with any escapes unescaped pub expression: StringLiteral<'a>, @@ -1162,11 +1073,9 @@ 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)] pub struct Hashbang<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub value: Atom<'a>, } @@ -1177,14 +1086,12 @@ 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)] 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>, } @@ -1192,9 +1099,8 @@ 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)] +#[estree(untagged)] pub enum Declaration<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32, #[visit(args(flags = ScopeFlags::Function))] @@ -1229,11 +1135,9 @@ 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)] pub struct VariableDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: VariableDeclarationKind, pub declarations: Vec<'a, VariableDeclarator<'a>>, @@ -1242,15 +1146,14 @@ 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)] +#[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, } @@ -1264,13 +1167,11 @@ 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)] 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>, @@ -1280,22 +1181,18 @@ 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)] 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)] pub struct ExpressionStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1303,11 +1200,9 @@ 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)] pub struct IfStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub test: Expression<'a>, pub consequent: Statement<'a>, @@ -1317,11 +1212,9 @@ 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)] pub struct DoWhileStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Statement<'a>, pub test: Expression<'a>, @@ -1330,11 +1223,9 @@ 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)] pub struct WhileStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub test: Expression<'a>, pub body: Statement<'a>, @@ -1344,17 +1235,15 @@ 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)] 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>, } @@ -1367,9 +1256,8 @@ 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)] +#[estree(untagged)] pub enum ForStatementInit<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 64, // `Expression` variants added here by `inherit_variants!` macro @@ -1381,16 +1269,14 @@ 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)] 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>, } @@ -1403,9 +1289,8 @@ 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)] +#[estree(untagged)] pub enum ForStatementLeft<'a> { VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 16, // `AssignmentTarget` variants added here by `inherit_variants!` macro @@ -1416,17 +1301,15 @@ 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)] 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>, } @@ -1434,11 +1317,9 @@ 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)] pub struct ContinueStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub label: Option>, } @@ -1446,11 +1327,9 @@ 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)] pub struct BreakStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub label: Option>, } @@ -1458,11 +1337,9 @@ 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)] pub struct ReturnStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub argument: Option>, } @@ -1470,11 +1347,9 @@ 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)] pub struct WithStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object: Expression<'a>, pub body: Statement<'a>, @@ -1484,27 +1359,23 @@ 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)] 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)] pub struct SwitchCase<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub test: Option>, pub consequent: Vec<'a, Statement<'a>>, @@ -1513,11 +1384,9 @@ 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)] pub struct LabeledStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub label: LabelIdentifier<'a>, pub body: Statement<'a>, @@ -1532,11 +1401,9 @@ 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)] 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>, @@ -1559,11 +1426,9 @@ 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)] pub struct TryStatement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Statements in the `try` block pub block: Box<'a, BlockStatement<'a>>, @@ -1589,17 +1454,15 @@ 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)] 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>, } @@ -1619,11 +1482,9 @@ 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)] pub struct CatchParameter<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The bound error pub pattern: BindingPattern<'a>, @@ -1638,11 +1499,9 @@ 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)] pub struct DebuggerStatement { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -1650,12 +1509,11 @@ 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)] +#[estree(no_type)] 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>, @@ -1665,9 +1523,8 @@ 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)] +#[estree(untagged)] pub enum BindingPatternKind<'a> { /// `const a = 1` BindingIdentifier(Box<'a, BindingIdentifier<'a>>) = 0, @@ -1684,11 +1541,9 @@ 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)] pub struct AssignmentPattern<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: BindingPattern<'a>, pub right: Expression<'a>, @@ -1697,25 +1552,22 @@ 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))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] 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)] pub struct BindingProperty<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub key: PropertyKey<'a>, pub value: BindingPattern<'a>, @@ -1726,15 +1578,14 @@ 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))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] 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>>, } @@ -1749,11 +1600,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(type = "RestElement")] pub struct BindingRestElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub argument: BindingPattern<'a>, } @@ -1800,12 +1650,10 @@ 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)] 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>, @@ -1855,15 +1703,14 @@ 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)] pub enum FunctionType { FunctionDeclaration = 0, FunctionExpression = 1, @@ -1876,26 +1723,23 @@ 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))] -#[serde(tag = "type")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] 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)] pub struct FormalParameter<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub decorators: Vec<'a, Decorator<'a>>, pub pattern: BindingPattern<'a>, @@ -1906,8 +1750,7 @@ 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)] pub enum FormalParameterKind { /// FormalParameter = 0, @@ -1922,11 +1765,9 @@ 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)] pub struct FunctionBody<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub directives: Vec<'a, Directive<'a>>, pub statements: Vec<'a, Statement<'a>>, @@ -1939,11 +1780,9 @@ 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)] 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, @@ -1953,7 +1792,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>, } @@ -1961,11 +1800,9 @@ 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)] pub struct YieldExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub delegate: bool, pub argument: Option>, @@ -1975,12 +1812,10 @@ 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)] pub struct Class<'a> { pub r#type: ClassType, - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Decorators applied to the class. /// @@ -2041,15 +1876,14 @@ 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)] pub enum ClassType { /// Class declaration statement /// ```ts @@ -2066,11 +1900,9 @@ 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)] pub struct ClassBody<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, ClassElement<'a>>, } @@ -2095,9 +1927,8 @@ 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)] +#[estree(untagged)] pub enum ClassElement<'a> { StaticBlock(Box<'a, StaticBlock<'a>>) = 0, /// Class Methods @@ -2119,15 +1950,13 @@ 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)] 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>, @@ -2148,8 +1977,7 @@ 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)] pub enum MethodDefinitionType { MethodDefinition = 0, TSAbstractMethodDefinition = 1, @@ -2157,12 +1985,10 @@ 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)] pub struct PropertyDefinition<'a> { pub r#type: PropertyDefinitionType, - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Decorators applied to the property. /// @@ -2239,8 +2065,7 @@ 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)] pub enum PropertyDefinitionType { PropertyDefinition = 0, TSAbstractPropertyDefinition = 1, @@ -2248,9 +2073,8 @@ 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)] +#[estree(rename_all = "camelCase")] pub enum MethodDefinitionKind { /// Class constructor Constructor = 0, @@ -2267,11 +2091,9 @@ 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)] pub struct PrivateIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, } @@ -2292,14 +2114,12 @@ 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)] 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>, } @@ -2329,9 +2149,8 @@ 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)] +#[estree(untagged)] pub enum ModuleDeclaration<'a> { /// `import hello from './world.js';` /// `import * as t from './world.js';` @@ -2366,8 +2185,7 @@ 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)] pub enum AccessorPropertyType { AccessorProperty = 0, TSAbstractAccessorProperty = 1, @@ -2383,12 +2201,10 @@ 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)] pub struct AccessorProperty<'a> { pub r#type: AccessorPropertyType, - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Decorators applied to the accessor property. /// @@ -2427,11 +2243,9 @@ 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)] pub struct ImportExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub source: Expression<'a>, pub arguments: Vec<'a, Expression<'a>>, @@ -2439,11 +2253,9 @@ 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)] pub struct ImportDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `None` for `import 'foo'`, `Some([])` for `import {} from 'foo'` pub specifiers: Option>>, @@ -2456,9 +2268,8 @@ 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)] +#[estree(untagged)] pub enum ImportDeclarationSpecifier<'a> { /// import {imported} from "source" /// import {imported as local} from "source" @@ -2473,11 +2284,9 @@ 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)] pub struct ImportSpecifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub imported: ModuleExportName<'a>, /// The name of the imported symbol. @@ -2504,11 +2313,9 @@ 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)] pub struct ImportDefaultSpecifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the imported symbol. pub local: BindingIdentifier<'a>, @@ -2522,22 +2329,18 @@ 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)] 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)] 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>>, @@ -2545,11 +2348,9 @@ 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)] pub struct ImportAttribute<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub key: ImportAttributeKey<'a>, pub value: StringLiteral<'a>, @@ -2557,9 +2358,8 @@ 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)] +#[estree(untagged)] pub enum ImportAttributeKey<'a> { Identifier(IdentifierName<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -2578,11 +2378,9 @@ 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)] pub struct ExportNamedDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub declaration: Option>, pub specifiers: Vec<'a, ExportSpecifier<'a>>, @@ -2604,11 +2402,9 @@ 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)] pub struct ExportDefaultDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub declaration: ExportDefaultDeclarationKind<'a>, pub exported: ModuleExportName<'a>, // the `default` Keyword @@ -2625,11 +2421,9 @@ 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)] pub struct ExportAllDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// If this declaration is re-named pub exported: Option>, @@ -2652,11 +2446,9 @@ 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)] pub struct ExportSpecifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub local: ModuleExportName<'a>, pub exported: ModuleExportName<'a>, @@ -2671,9 +2463,8 @@ 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)] +#[estree(untagged)] pub enum ExportDefaultDeclarationKind<'a> { #[visit(args(flags = ScopeFlags::Function))] FunctionDeclaration(Box<'a, Function<'a>>) = 64, @@ -2695,9 +2486,8 @@ 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)] +#[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..289be4f57b4ff 100644 --- a/crates/oxc_ast/src/ast/jsx.rs +++ b/crates/oxc_ast/src/ast/jsx.rs @@ -4,16 +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 serde::Serialize; -#[cfg(feature = "serialize")] -use tsify::Tsify; use super::{inherit_variants, js::*, literal::*, ts::*}; @@ -38,11 +32,9 @@ 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)] 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 +61,9 @@ 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)] pub struct JSXOpeningElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Is this tag self-closing? /// @@ -103,11 +93,9 @@ 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)] pub struct JSXClosingElement<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: JSXElementName<'a>, } @@ -122,11 +110,9 @@ 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)] pub struct JSXFragment<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `<>` pub opening_fragment: JSXOpeningFragment, @@ -139,22 +125,18 @@ 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)] 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)] pub struct JSXClosingFragment { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -162,7 +144,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 +167,9 @@ 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)] 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 +194,9 @@ 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)] 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 +207,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 +229,9 @@ 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)] pub struct JSXExpressionContainer<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The expression inside the container. pub expression: JSXExpression<'a>, @@ -270,9 +246,8 @@ 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)] +#[estree(untagged)] pub enum JSXExpression<'a> { EmptyExpression(JSXEmptyExpression) = 64, // `Expression` variants added here by `inherit_variants!` macro @@ -283,11 +258,9 @@ 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)] pub struct JSXEmptyExpression { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -304,9 +277,8 @@ 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)] +#[estree(untagged)] pub enum JSXAttributeItem<'a> { /// A `key="value"` attribute Attribute(Box<'a, JSXAttribute<'a>>) = 0, @@ -327,11 +299,9 @@ 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)] 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 +320,9 @@ 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)] pub struct JSXSpreadAttribute<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub argument: Expression<'a>, } @@ -376,9 +344,8 @@ 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)] +#[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 +373,8 @@ 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)] +#[estree(untagged)] pub enum JSXAttributeValue<'a> { StringLiteral(Box<'a, StringLiteral<'a>>) = 0, ExpressionContainer(Box<'a, JSXExpressionContainer<'a>>) = 1, @@ -423,11 +389,9 @@ 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)] pub struct JSXIdentifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the identifier. pub name: Atom<'a>, @@ -440,9 +404,8 @@ 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)] +#[estree(untagged)] pub enum JSXChild<'a> { /// `Some Text` Text(Box<'a, JSXText<'a>>) = 0, @@ -461,11 +424,9 @@ 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)] pub struct JSXSpreadChild<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The expression being spread. pub expression: Expression<'a>, @@ -483,11 +444,9 @@ 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)] 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..04da8bc414388 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -4,32 +4,24 @@ // 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; 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 /// /// #[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)] pub struct BooleanLiteral { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub value: bool, } @@ -39,11 +31,9 @@ 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)] pub struct NullLiteral { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -52,34 +42,30 @@ 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)] 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)] 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 +74,9 @@ 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)] 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 +89,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)] +#[estree(no_type)] pub struct RegExp<'a> { /// The regex pattern between the slashes pub pattern: RegExpPattern<'a>, @@ -119,8 +103,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)] +#[estree(untagged)] pub enum RegExpPattern<'a> { /// Unparsed pattern. Contains string slice of the pattern. /// Pattern was not parsed, so may be valid or invalid. @@ -135,8 +119,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)] +#[estree(no_type)] pub struct EmptyObject; /// String literal @@ -144,11 +128,9 @@ 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)] pub struct StringLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub value: Atom<'a>, } diff --git a/crates/oxc_ast/src/ast/mod.rs b/crates/oxc_ast/src/ast/mod.rs index 19a3c0b505cbe..25fe7c3092598 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 1555888052394..97ae5f09c4bbb 100644 --- a/crates/oxc_ast/src/ast/ts.rs +++ b/crates/oxc_ast/src/ast/ts.rs @@ -7,32 +7,16 @@ // 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}; 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::*}; -#[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 @@ -45,11 +29,9 @@ 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)] 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 +61,9 @@ 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)] pub struct TSEnumDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub id: BindingIdentifier<'a>, #[scope(enter_before)] @@ -91,7 +71,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 +95,9 @@ 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)] pub struct TSEnumMember<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub id: TSEnumMemberName<'a>, pub initializer: Option>, @@ -134,9 +112,8 @@ 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)] +#[estree(untagged)] pub enum TSEnumMemberName<'a> { StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64, StaticStringLiteral(Box<'a, StringLiteral<'a>>) = 65, @@ -163,11 +140,9 @@ 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)] 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 +165,9 @@ 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)] pub struct TSLiteralType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub literal: TSLiteral<'a>, } @@ -202,9 +175,8 @@ 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)] +#[estree(untagged)] pub enum TSLiteral<'a> { BooleanLiteral(Box<'a, BooleanLiteral>) = 0, NullLiteral(Box<'a, NullLiteral>) = 1, @@ -229,9 +201,8 @@ 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)] +#[estree(untagged)] pub enum TSType<'a> { // Keyword TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0, @@ -338,11 +309,9 @@ 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)] 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 +323,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 +339,9 @@ 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)] pub struct TSUnionType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The types in the union. pub types: Vec<'a, TSType<'a>>, @@ -395,11 +362,9 @@ 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)] pub struct TSIntersectionType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub types: Vec<'a, TSType<'a>>, } @@ -415,11 +380,9 @@ 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)] pub struct TSParenthesizedType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, } @@ -435,11 +398,9 @@ 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)] pub struct TSTypeOperator<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub operator: TSTypeOperatorOperator, /// The type being operated on @@ -449,9 +410,8 @@ 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)] +#[estree(rename_all = "camelCase")] pub enum TSTypeOperatorOperator { Keyof = 0, Unique = 1, @@ -471,11 +431,9 @@ 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)] pub struct TSArrayType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub element_type: TSType<'a>, } @@ -493,11 +451,9 @@ 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)] pub struct TSIndexedAccessType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub object_type: TSType<'a>, pub index_type: TSType<'a>, @@ -514,11 +470,9 @@ 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)] pub struct TSTupleType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub element_types: Vec<'a, TSTupleElement<'a>>, } @@ -535,11 +489,9 @@ 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)] pub struct TSNamedTupleMember<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub element_type: TSTupleElement<'a>, pub label: IdentifierName<'a>, @@ -557,11 +509,9 @@ 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)] pub struct TSOptionalType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, } @@ -576,11 +526,9 @@ 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)] pub struct TSRestType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, } @@ -595,9 +543,8 @@ 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)] +#[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`). @@ -619,11 +566,9 @@ 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)] pub struct TSAnyKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -638,11 +583,9 @@ 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)] pub struct TSStringKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -657,11 +600,9 @@ 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)] pub struct TSBooleanKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -676,11 +617,9 @@ 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)] pub struct TSNumberKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -696,11 +635,9 @@ 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)] pub struct TSNeverKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -716,11 +653,9 @@ 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)] pub struct TSIntrinsicKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -737,11 +672,9 @@ 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)] pub struct TSUnknownKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -757,11 +690,9 @@ 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)] pub struct TSNullKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -779,61 +710,49 @@ 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)] 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)] 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)] 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)] 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)] 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)] pub struct TSBigIntKeyword { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -847,11 +766,9 @@ 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)] pub struct TSTypeReference<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_name: TSTypeName<'a>, pub type_parameters: Option>>, @@ -862,9 +779,8 @@ 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)] +#[estree(untagged)] pub enum TSTypeName<'a> { IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0, QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1, @@ -889,11 +805,9 @@ 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)] pub struct TSQualifiedName<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub left: TSTypeName<'a>, pub right: IdentifierName<'a>, @@ -901,11 +815,9 @@ 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)] pub struct TSTypeParameterInstantiation<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub params: Vec<'a, TSType<'a>>, } @@ -929,11 +841,9 @@ 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)] 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 +861,9 @@ 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)] pub struct TSTypeParameterDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub params: Vec<'a, TSTypeParameter<'a>>, } @@ -971,11 +879,9 @@ 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)] 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 +889,15 @@ 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)] +#[estree(rename_all = "camelCase")] pub enum TSAccessibility { Private = 0, Protected = 1, @@ -1011,11 +916,9 @@ 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)] pub struct TSClassImplements<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: TSTypeName<'a>, pub type_parameters: Option>>, @@ -1039,11 +942,9 @@ 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)] pub struct TSInterfaceDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The identifier (name) of the interface. pub id: BindingIdentifier<'a>, @@ -1055,7 +956,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 +964,9 @@ 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)] pub struct TSInterfaceBody<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, TSSignature<'a>>, } @@ -1089,11 +988,9 @@ 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)] pub struct TSPropertySignature<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub computed: bool, pub optional: bool, @@ -1104,9 +1001,8 @@ 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)] +#[estree(untagged)] pub enum TSSignature<'a> { TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0, TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1, @@ -1128,11 +1024,9 @@ 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)] 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 +1035,9 @@ 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)] pub struct TSCallSignatureDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_parameters: Option>>, pub this_param: Option>, @@ -1155,9 +1047,8 @@ 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)] +#[estree(rename_all = "camelCase")] pub enum TSMethodSignatureKind { Method = 0, Get = 1, @@ -1178,11 +1069,9 @@ 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)] pub struct TSMethodSignature<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub key: PropertyKey<'a>, pub computed: bool, @@ -1192,7 +1081,7 @@ pub struct TSMethodSignature<'a> { pub this_param: Option>>, pub params: Box<'a, FormalParameters<'a>>, pub return_type: Option>>, - #[serde(skip)] + #[estree(skip)] #[clone_in(default)] pub scope_id: Cell>, } @@ -1201,27 +1090,24 @@ 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)] pub struct TSConstructSignatureDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_parameters: Option>>, pub params: Box<'a, FormalParameters<'a>>, pub return_type: 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(type = "Identifier")] pub struct TSIndexSignatureName<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: Atom<'a>, pub type_annotation: Box<'a, TSTypeAnnotation<'a>>, @@ -1229,11 +1115,9 @@ 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)] pub struct TSInterfaceHeritage<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, pub type_parameters: Option>>, @@ -1261,11 +1145,9 @@ 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)] pub struct TSTypePredicate<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The identifier the predicate operates on pub parameter_name: TSTypePredicateName<'a>, @@ -1281,9 +1163,8 @@ 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)] +#[estree(untagged)] pub enum TSTypePredicateName<'a> { Identifier(Box<'a, IdentifierName<'a>>) = 0, This(TSThisType) = 1, @@ -1321,11 +1202,9 @@ 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)] pub struct TSModuleDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The name of the module/namespace being declared. /// @@ -1348,16 +1227,15 @@ 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)] +#[estree(rename_all = "camelCase")] pub enum TSModuleDeclarationKind { /// `declare global {}` Global = 0, @@ -1389,9 +1267,8 @@ 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)] +#[estree(untagged)] pub enum TSModuleDeclarationName<'a> { Identifier(BindingIdentifier<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -1399,9 +1276,8 @@ 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)] +#[estree(untagged)] pub enum TSModuleDeclarationBody<'a> { TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0, TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1, @@ -1410,24 +1286,21 @@ 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))] -#[serde(tag = "type", rename_all = "camelCase")] +#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] +#[estree(custom_serialize)] 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)] pub struct TSTypeLiteral<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub members: Vec<'a, TSSignature<'a>>, } @@ -1447,11 +1320,9 @@ 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)] 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 +1339,9 @@ 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)] pub struct TSTypeQuery<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expr_name: TSTypeQueryExprName<'a>, pub type_parameters: Option>>, @@ -1486,9 +1355,8 @@ 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)] +#[estree(untagged)] pub enum TSTypeQueryExprName<'a> { TSImportType(Box<'a, TSImportType<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1498,11 +1366,9 @@ 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)] pub struct TSImportType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// `true` for `typeof import("foo")` pub is_type_of: bool, @@ -1514,11 +1380,9 @@ 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)] 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 +1390,9 @@ 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)] pub struct TSImportAttribute<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub name: TSImportAttributeName<'a>, pub value: Expression<'a>, @@ -1538,9 +1400,8 @@ 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)] +#[estree(untagged)] pub enum TSImportAttributeName<'a> { Identifier(IdentifierName<'a>) = 0, StringLiteral(StringLiteral<'a>) = 1, @@ -1556,11 +1417,9 @@ 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)] pub struct TSFunctionType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Generic type parameters /// @@ -1588,11 +1447,9 @@ 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)] pub struct TSConstructorType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub r#abstract: bool, pub type_parameters: Option>>, @@ -1624,11 +1481,9 @@ 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)] 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 +1513,23 @@ 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)] +#[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 +1548,9 @@ 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)] 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 +1560,9 @@ 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)] pub struct TSAsExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, pub type_annotation: TSType<'a>, @@ -1732,11 +1582,9 @@ 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)] pub struct TSSatisfiesExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// The value expression being constrained. pub expression: Expression<'a>, @@ -1746,11 +1594,9 @@ 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)] pub struct TSTypeAssertion<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, pub type_annotation: TSType<'a>, @@ -1758,11 +1604,9 @@ 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)] pub struct TSImportEqualsDeclaration<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub id: BindingIdentifier<'a>, pub module_reference: TSModuleReference<'a>, @@ -1777,9 +1621,8 @@ 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)] +#[estree(untagged)] pub enum TSModuleReference<'a> { ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2, // `TSTypeName` variants added here by `inherit_variants!` macro @@ -1789,22 +1632,18 @@ 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)] 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)] pub struct TSNonNullExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1835,11 +1674,9 @@ 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)] pub struct Decorator<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1849,11 +1686,9 @@ 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)] pub struct TSExportAssignment<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, } @@ -1863,22 +1698,18 @@ 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)] 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)] pub struct TSInstantiationExpression<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub expression: Expression<'a>, pub type_parameters: Box<'a, TSTypeParameterInstantiation<'a>>, @@ -1887,9 +1718,8 @@ 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)] +#[estree(rename_all = "camelCase")] pub enum ImportOrExportKind { /// `import { foo } from './foo'`; Value = 0, @@ -1902,11 +1732,9 @@ 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)] pub struct JSDocNullableType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, /// Was `?` after the type annotation? @@ -1916,11 +1744,9 @@ 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)] pub struct JSDocNonNullableType<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub type_annotation: TSType<'a>, pub postfix: bool, @@ -1928,10 +1754,8 @@ 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)] pub struct JSDocUnknownType { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index 7ec9a77ec9bbd..7f98292edf9e6 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 is_empty(&self) -> bool { self.body.is_empty() && self.directives.is_empty() 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 new file mode 100644 index 0000000000000..05f63a70110d4 --- /dev/null +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -0,0 +1,4879 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` + +#[allow(unused_imports)] +use serde::{ser::SerializeMap, 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 { + #[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", "BooleanLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("value", &self.value)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "NullLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("pattern", &self.pattern)?; + map.serialize_entry("flags", &self.flags)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Program")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)?; + 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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "ThisExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + 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) + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + ObjectPropertyKind::ObjectProperty(ref x) => Serialize::serialize(x, serializer), + ObjectPropertyKind::SpreadProperty(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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"), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("raw", &self.raw)?; + map.serialize_entry("cooked", &self.cooked)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + map.serialize_entry("arguments", &self.arguments)?; + map.serialize_entry("optional", &self.optional)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + 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) + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + AssignmentTargetPattern::ArrayAssignmentTarget(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetPattern::ObjectAssignmentTarget(ref x) => { + Serialize::serialize(x, serializer) + } + } + } +} +#[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\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\ttype: 'ObjectAssignmentTarget';\n\tproperties: Array;\n}) & Span;"; + +impl<'a> Serialize for AssignmentTargetRest<'a> { + #[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", "RestElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.target)?; + 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)] + 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) + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + AssignmentTargetProperty::AssignmentTargetPropertyIdentifier(ref x) => { + Serialize::serialize(x, serializer) + } + AssignmentTargetProperty::AssignmentTargetPropertyProperty(ref x) => { + Serialize::serialize(x, serializer) + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Super")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "EmptyStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "DebuggerStatement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + self.kind.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + map.serialize_entry("optional", &self.optional)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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\ttype: 'ObjectPattern';\n\tproperties: Array;\n}) & Span;"; + +impl<'a> Serialize for BindingProperty<'a> { + #[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", "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() + } +} +#[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\ttype: 'ArrayPattern';\n\telements: Array;\n}) & Span;"; + +impl<'a> Serialize for BindingRestElement<'a> { + #[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", "RestElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.argument)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + map.serialize_entry("thisParam", &self.this_param)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("returnType", &self.return_type)?; + map.serialize_entry("body", &self.body)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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", + ), + } + } +} +#[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\ttype: 'FormalParameters';\n\tkind: FormalParameterKind;\n\titems: Array;\n}) & Span;"; + +impl<'a> Serialize for FormalParameter<'a> { + #[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", "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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("returnType", &self.return_type)?; + map.serialize_entry("body", &self.body)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("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)?; + map.serialize_entry("declare", &self.declare)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + ClassType::ClassDeclaration => { + serializer.serialize_unit_variant("ClassType", 0u32, "ClassDeclaration") + } + ClassType::ClassExpression => { + serializer.serialize_unit_variant("ClassType", 1u32, "ClassExpression") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + MethodDefinitionType::MethodDefinition => { + serializer.serialize_unit_variant("MethodDefinitionType", 0u32, "MethodDefinition") + } + MethodDefinitionType::TSAbstractMethodDefinition => serializer.serialize_unit_variant( + "MethodDefinitionType", + 1u32, + "TSAbstractMethodDefinition", + ), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeAnnotation", &self.type_annotation)?; + map.serialize_entry("accessibility", &self.accessibility)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + PropertyDefinitionType::PropertyDefinition => serializer.serialize_unit_variant( + "PropertyDefinitionType", + 0u32, + "PropertyDefinition", + ), + PropertyDefinitionType::TSAbstractPropertyDefinition => serializer + .serialize_unit_variant( + "PropertyDefinitionType", + 1u32, + "TSAbstractPropertyDefinition", + ), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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) + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + AccessorPropertyType::AccessorProperty => { + serializer.serialize_unit_variant("AccessorPropertyType", 0u32, "AccessorProperty") + } + AccessorPropertyType::TSAbstractAccessorProperty => serializer.serialize_unit_variant( + "AccessorPropertyType", + 1u32, + "TSAbstractAccessorProperty", + ), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeAnnotation", &self.type_annotation)?; + map.serialize_entry("accessibility", &self.accessibility)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("withClause", &self.with_clause)?; + map.serialize_entry("importKind", &self.import_kind)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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) + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("importKind", &self.import_kind)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "WithClause")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("attributesKeyword", &self.attributes_keyword)?; + map.serialize_entry("withEntries", &self.with_entries)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + ImportAttributeKey::Identifier(ref x) => Serialize::serialize(x, serializer), + ImportAttributeKey::StringLiteral(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("exportKind", &self.export_kind)?; + map.serialize_entry("withClause", &self.with_clause)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("withClause", &self.with_clause)?; + map.serialize_entry("exportKind", &self.export_kind)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("exportKind", &self.export_kind)?; + 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)] + 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) + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSThisParameter")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("thisSpan", &self.this_span)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeAnnotation")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSConditionalType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSParenthesizedType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSArrayType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("elementType", &self.element_type)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSIndexedAccessType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("objectType", &self.object_type)?; + map.serialize_entry("indexType", &self.index_type)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTupleType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("elementTypes", &self.element_types)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNamedTupleMember")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("elementType", &self.element_type)?; + map.serialize_entry("label", &self.label)?; + map.serialize_entry("optional", &self.optional)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSOptionalType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSRestType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + 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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSAnyKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSStringKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSBooleanKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNumberKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNeverKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSIntrinsicKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSUnknownKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSNullKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSUndefinedKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSVoidKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSSymbolKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSThisType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSObjectKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSBigIntKeyword")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeReference")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeName", &self.type_name)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + TSTypeName::IdentifierReference(ref x) => Serialize::serialize(x, serializer), + TSTypeName::QualifiedName(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + map.serialize_entry("declare", &self.declare)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + map.serialize_entry("body", &self.body)?; + map.serialize_entry("declare", &self.declare)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeAnnotation", &self.type_annotation)?; + map.serialize_entry("readonly", &self.readonly)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSCallSignatureDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + map.serialize_entry("thisParam", &self.this_param)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("returnType", &self.return_type)?; + map.end() + } +} +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSCallSignatureDeclaration = ({\n\ttype: 'TSCallSignatureDeclaration';\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tthisParam: (TSThisParameter) | null;\n\tparams: FormalParameters;\n\treturnType: (TSTypeAnnotation) | null;\n}) & Span;"; + +impl Serialize for TSMethodSignatureKind { + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + map.serialize_entry("thisParam", &self.this_param)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("returnType", &self.return_type)?; + 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\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tthisParam: (TSThisParameter) | null;\n\tparams: FormalParameters;\n\treturnType: (TSTypeAnnotation) | null;\n}) & Span;"; + +impl<'a> Serialize for TSConstructSignatureDeclaration<'a> { + #[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", "TSConstructSignatureDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("returnType", &self.return_type)?; + map.end() + } +} +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSConstructSignatureDeclaration = ({\n\ttype: 'TSConstructSignatureDeclaration';\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tparams: FormalParameters;\n\treturnType: (TSTypeAnnotation) | null;\n}) & Span;"; + +impl<'a> Serialize for TSIndexSignatureName<'a> { + #[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", "Identifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypePredicate")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("parameterName", &self.parameter_name)?; + map.serialize_entry("asserts", &self.asserts)?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + TSTypePredicateName::Identifier(ref x) => Serialize::serialize(x, serializer), + TSTypePredicateName::This(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + TSModuleDeclarationName::Identifier(ref x) => Serialize::serialize(x, serializer), + TSModuleDeclarationName::StringLiteral(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + TSModuleDeclarationBody::TSModuleDeclaration(ref x) => { + Serialize::serialize(x, serializer) + } + TSModuleDeclarationBody::TSModuleBlock(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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\ttype: 'TSModuleBlock';\n\tbody: Array;\n}) & Span;"; + +impl<'a> Serialize for TSTypeLiteral<'a> { + #[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", "TSTypeLiteral")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("members", &self.members)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSInferType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeParameter", &self.type_parameter)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSTypeQuery")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("exprName", &self.expr_name)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSImportType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSImportAttributes")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("attributesKeyword", &self.attributes_keyword)?; + map.serialize_entry("elements", &self.elements)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + TSImportAttributeName::Identifier(ref x) => Serialize::serialize(x, serializer), + TSImportAttributeName::StringLiteral(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSFunctionType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + map.serialize_entry("thisParam", &self.this_param)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("returnType", &self.return_type)?; + map.end() + } +} +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type TSFunctionType = ({\n\ttype: 'TSFunctionType';\n\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tthisParam: (TSThisParameter) | null;\n\tparams: FormalParameters;\n\treturnType: TSTypeAnnotation;\n}) & Span;"; + +impl<'a> Serialize for TSConstructorType<'a> { + #[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", "TSConstructorType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("abstract", &self.r#abstract)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + map.serialize_entry("params", &self.params)?; + map.serialize_entry("returnType", &self.return_type)?; + 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\ttypeParameters: (TSTypeParameterDeclaration) | null;\n\tparams: FormalParameters;\n\treturnType: TSTypeAnnotation;\n}) & Span;"; + +impl<'a> Serialize for TSMappedType<'a> { + #[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", "TSMappedType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeAnnotation", &self.type_annotation)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("moduleReference", &self.module_reference)?; + map.serialize_entry("importKind", &self.import_kind)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + ImportOrExportKind::Value => { + serializer.serialize_unit_variant("ImportOrExportKind", 0u32, "value") + } + ImportOrExportKind::Type => { + serializer.serialize_unit_variant("ImportOrExportKind", 1u32, "type") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSDocNullableType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + map.serialize_entry("postfix", &self.postfix)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSDocNonNullableType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + map.serialize_entry("postfix", &self.postfix)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSDocUnknownType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("openingElement", &self.opening_element)?; + map.serialize_entry("closingElement", &self.closing_element)?; + map.serialize_entry("children", &self.children)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXOpeningElement")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("selfClosing", &self.self_closing)?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("attributes", &self.attributes)?; + map.serialize_entry("typeParameters", &self.type_parameters)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXFragment")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("openingFragment", &self.opening_fragment)?; + map.serialize_entry("closingFragment", &self.closing_fragment)?; + map.serialize_entry("children", &self.children)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXOpeningFragment")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXClosingFragment")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXEmptyExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + JSXAttributeItem::Attribute(ref x) => Serialize::serialize(x, serializer), + JSXAttributeItem::SpreadAttribute(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + JSXAttributeName::Identifier(ref x) => Serialize::serialize(x, serializer), + JSXAttributeName::NamespacedName(ref x) => Serialize::serialize(x, serializer), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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/lib.rs b/crates/oxc_ast/src/lib.rs index eab91afe0b717..a5527fa3f0618 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/src/serialize.rs b/crates/oxc_ast/src/serialize.rs index 12b3b4fcfa8f3..a797dfdd2c05c 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. @@ -156,6 +159,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 type FormalParameterRest = ({ + type: "RestElement", + argument: BindingPatternKind, + typeAnnotation: TSTypeAnnotation | null, + optional: boolean, +}) & Span; +"#; + #[derive(Serialize)] #[serde(tag = "type", rename = "FormalParameters")] struct SerFormalParameters<'a, 'b> { diff --git a/crates/oxc_ast_macros/src/ast.rs b/crates/oxc_ast_macros/src/ast.rs index 083233f874390..3354fd07017ab 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 == "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..9841846ee7278 --- /dev/null +++ b/crates/oxc_estree/src/lib.rs @@ -0,0 +1,3 @@ +/// Empty trait that will be used later for custom serialization and TypeScript +/// generation for AST nodes. +pub trait ESTree {} diff --git a/crates/oxc_regular_expression/Cargo.toml b/crates/oxc_regular_expression/Cargo.toml index 1917f3c2d7b16..b4f092286c340 100644 --- a/crates/oxc_regular_expression/Cargo.toml +++ b/crates/oxc_regular_expression/Cargo.toml @@ -23,19 +23,16 @@ 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"] } 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 } 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 +serialize = ["dep:serde", "dep:wasm-bindgen", "oxc_allocator/serialize", "oxc_span/serialize"] diff --git a/crates/oxc_regular_expression/src/ast.rs b/crates/oxc_regular_expression/src/ast.rs index b31961d714eff..96bba7434769f 100644 --- a/crates/oxc_regular_expression/src/ast.rs +++ b/crates/oxc_regular_expression/src/ast.rs @@ -1,21 +1,14 @@ -// 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 serde::Serialize; -#[cfg(feature = "serialize")] -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, ESTree)] pub struct Pattern<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Disjunction<'a>, } @@ -23,10 +16,9 @@ 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, ESTree)] pub struct Disjunction<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, Alternative<'a>>, } @@ -34,10 +26,9 @@ 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, ESTree)] pub struct Alternative<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub body: Vec<'a, Term<'a>>, } @@ -45,8 +36,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, ESTree)] +#[estree(untagged)] pub enum Term<'a> { // Assertion, QuantifiableAssertion BoundaryAssertion(Box<'a, BoundaryAssertion>) = 0, @@ -89,8 +80,7 @@ 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, ESTree)] pub struct BoundaryAssertion { pub span: Span, pub kind: BoundaryAssertionKind, @@ -98,8 +88,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, ESTree)] +#[estree(rename_all = "camelCase")] pub enum BoundaryAssertionKind { Start = 0, End = 1, @@ -111,10 +101,9 @@ pub enum BoundaryAssertionKind { /// e.g. `(?=...)`, `(?!...)`, `(?<=...)`, `(? { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: LookAroundAssertionKind, pub body: Disjunction<'a>, @@ -122,8 +111,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, ESTree)] +#[estree(rename_all = "camelCase")] pub enum LookAroundAssertionKind { Lookahead = 0, NegativeLookahead = 1, @@ -135,10 +124,9 @@ 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, ESTree)] pub struct Quantifier<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub min: u64, /// `None` means no upper bound. @@ -150,11 +138,10 @@ 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, ESTree)] 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 +150,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, ESTree)] +#[estree(rename_all = "camelCase")] pub enum CharacterKind { ControlLetter = 0, HexadecimalEscape = 1, @@ -183,18 +170,17 @@ 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, ESTree)] pub struct CharacterClassEscape { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub kind: CharacterClassEscapeKind, } #[ast] #[derive(Debug, Clone, Copy, PartialEq)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[estree(rename_all = "camelCase")] pub enum CharacterClassEscapeKind { D = 0, NegativeD = 1, @@ -208,10 +194,9 @@ 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, ESTree)] 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 +208,9 @@ 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, ESTree)] pub struct Dot { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, } @@ -234,10 +218,9 @@ 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, ESTree)] pub struct CharacterClass<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub negative: bool, /// `true` if: @@ -250,8 +233,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, ESTree)] +#[estree(rename_all = "camelCase")] pub enum CharacterClassContentsKind { Union = 0, /// `UnicodeSetsMode` only. @@ -262,8 +245,8 @@ pub enum CharacterClassContentsKind { #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] +#[estree(untagged)] pub enum CharacterClassContents<'a> { CharacterClassRange(Box<'a, CharacterClassRange>) = 0, CharacterClassEscape(Box<'a, CharacterClassEscape>) = 1, @@ -293,10 +276,9 @@ 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, ESTree)] pub struct CharacterClassRange { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub min: Character, pub max: Character, @@ -305,10 +287,9 @@ 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, ESTree)] 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 +299,9 @@ 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, ESTree)] 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 +312,9 @@ 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, ESTree)] pub struct CapturingGroup<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, /// Group name to be referenced by [`NamedReference`]. pub name: Option>, @@ -346,10 +325,9 @@ 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, ESTree)] pub struct IgnoreGroup<'a> { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub modifiers: Option, pub body: Disjunction<'a>, @@ -359,10 +337,9 @@ pub struct IgnoreGroup<'a> { /// e.g. `i` in `(?i:...)`, `-s` in `(?-s:...)` #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] pub struct Modifiers { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub enabling: Option, pub disabling: Option, @@ -371,8 +348,7 @@ pub struct Modifiers { /// Each part of modifier in [`Modifiers`]. #[ast] #[derive(Debug)] -#[generate_derive(CloneIn, ContentEq, ContentHash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(CloneIn, ContentEq, ContentHash, ESTree)] pub struct Modifier { pub ignore_case: bool, pub multiline: bool, @@ -383,10 +359,9 @@ pub struct Modifier { /// 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, ESTree)] pub struct IndexedReference { - #[serde(flatten)] + #[estree(flatten)] pub span: Span, pub index: u32, } @@ -395,10 +370,9 @@ 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, ESTree)] 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_estree.rs b/crates/oxc_regular_expression/src/generated/derive_estree.rs new file mode 100644 index 0000000000000..09080b58f3519 --- /dev/null +++ b/crates/oxc_regular_expression/src/generated/derive_estree.rs @@ -0,0 +1,556 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` + +#[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, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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", + ), + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "Dot")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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) + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "IgnoreGroup")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("modifiers", &self.modifiers)?; + map.serialize_entry("body", &self.body)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut map = serializer.serialize_map(None)?; + 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() + } +} +#[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)] + 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("multiline", &self.multiline)?; + map.serialize_entry("sticky", &self.sticky)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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() + } +} +#[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_regular_expression/src/lib.rs b/crates/oxc_regular_expression/src/lib.rs index c7c42f290537c..5b22c6408168a 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_estree; } pub mod ast; 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/crates/oxc_span/Cargo.toml b/crates/oxc_span/Cargo.toml index 1936bb2536d73..11cc1f0314e82 100644 --- a/crates/oxc_span/Cargo.toml +++ b/crates/oxc_span/Cargo.toml @@ -22,16 +22,16 @@ doctest = false [dependencies] oxc_allocator = { workspace = true } oxc_ast_macros = { workspace = true } +oxc_estree = { workspace = true } compact_str = { workspace = true } 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/atom.rs b/crates/oxc_span/src/atom.rs index b9363cc4e5efb..9a424d49af4b0 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/crates/oxc_span/src/generated/derive_estree.rs b/crates/oxc_span/src/generated/derive_estree.rs new file mode 100644 index 0000000000000..8955ff0566d37 --- /dev/null +++ b/crates/oxc_span/src/generated/derive_estree.rs @@ -0,0 +1,104 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` + +#[allow(unused_imports)] +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("start", &self.start)?; + map.serialize_entry("end", &self.end)?; + map.end() + } +} +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = + "export type Span = ({\n\tstart: number;\n\tend: number;\n});"; + +impl Serialize for SourceType { + #[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("language", &self.language)?; + map.serialize_entry("moduleKind", &self.module_kind)?; + map.serialize_entry("variant", &self.variant)?; + 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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + LanguageVariant::Standard => { + serializer.serialize_unit_variant("LanguageVariant", 0u32, "standard") + } + LanguageVariant::Jsx => { + serializer.serialize_unit_variant("LanguageVariant", 1u32, "jsx") + } + } + } +} +#[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/lib.rs b/crates/oxc_span/src/lib.rs index 1bed34cd32d62..2ad1c4dddd941 100644 --- a/crates/oxc_span/src/lib.rs +++ b/crates/oxc_span/src/lib.rs @@ -21,6 +21,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 f8fe5bca56732..76049d02f70b2 100644 --- a/crates/oxc_span/src/source_type/mod.rs +++ b/crates/oxc_span/src/source_type/mod.rs @@ -1,14 +1,10 @@ -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - mod error; use std::{hash::Hash, path::Path}; use oxc_allocator::{Allocator, CloneIn}; use oxc_ast_macros::ast; -#[cfg(feature = "serialize")] -use {serde::Serialize, tsify::Tsify}; +use oxc_estree::ESTree; use crate::{cmp::ContentEq, hash::ContentHash}; pub use error::UnknownExtension; @@ -16,8 +12,8 @@ pub use error::UnknownExtension; /// Source Type for JavaScript vs TypeScript / Script vs Module / JSX #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(ESTree)] +#[estree(no_type)] pub struct SourceType { /// JavaScript or TypeScript, default JavaScript pub(super) language: Language, @@ -32,23 +28,24 @@ pub struct SourceType { /// JavaScript or TypeScript #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "lowercase")] +#[generate_derive(ESTree)] pub enum Language { /// Indicates a JavaScript or JSX file + #[estree(rename = "javascript")] JavaScript = 0, /// Indicates a TypeScript file + #[estree(rename = "typescript")] TypeScript = 1, /// Indicates a TypeScript definition file (`*.d.ts`) - #[serde(rename = "typescriptDefinition")] + #[estree(rename = "typescriptDefinition")] TypeScriptDefinition = 2, } /// Script or Module #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(ESTree)] +#[estree(rename_all = "camelCase")] pub enum ModuleKind { /// Regular JS script or CommonJS file Script = 0, @@ -68,8 +65,8 @@ pub enum ModuleKind { /// JSX for JavaScript and TypeScript #[ast] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] -#[serde(rename_all = "camelCase")] +#[generate_derive(ESTree)] +#[estree(rename_all = "camelCase")] pub enum LanguageVariant { /// Standard JavaScript or TypeScript without any language extensions. Stage /// 3 proposals do not count as language extensions. diff --git a/crates/oxc_span/src/span/mod.rs b/crates/oxc_span/src/span/mod.rs index ab6e4ea432d89..8fb94109cd6e2 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 cc57edf6dfb95..9ab08bfde8118 100644 --- a/crates/oxc_span/src/span/types.rs +++ b/crates/oxc_span/src/span/types.rs @@ -1,9 +1,5 @@ -// Silence erroneous warnings from Rust Analyser for `#[derive(Tsify)]` -#![allow(non_snake_case)] - use oxc_ast_macros::ast; -#[cfg(feature = "serialize")] -use ::{serde::Serialize, tsify::Tsify}; +use oxc_estree::ESTree; /// Newtype for working with text ranges /// @@ -17,8 +13,9 @@ use ::{serde::Serialize, tsify::Tsify}; /// same content), use [`ContentHash`](crate::hash::ContentHash) instead. #[ast] #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] +#[generate_derive(ESTree)] #[non_exhaustive] // Disallow struct expression constructor `Span {}` +#[estree(no_type)] pub struct Span { /// The zero-based start offset of the span pub start: u32, diff --git a/crates/oxc_syntax/Cargo.toml b/crates/oxc_syntax/Cargo.toml index 03901101e7caa..3a26101356bae 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 } @@ -35,13 +36,12 @@ 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`. 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..8a61f93311c9b --- /dev/null +++ b/crates/oxc_syntax/src/generated/derive_estree.rs @@ -0,0 +1,218 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_tools/src/derives/estree.rs` + +#[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, + { + 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, "**=") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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, "**") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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, "??") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + 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") + } + } + } +} +#[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)] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match *self { + UpdateOperator::Increment => { + serializer.serialize_unit_variant("UpdateOperator", 0u32, "++") + } + UpdateOperator::Decrement => { + serializer.serialize_unit_variant("UpdateOperator", 1u32, "--") + } + } + } +} +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_APPEND_CONTENT: &'static str = "export type UpdateOperator = '++' | '--';"; diff --git a/crates/oxc_syntax/src/lib.rs b/crates/oxc_syntax/src/lib.rs index 8e5388f5190f3..b1efc6889c05b 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 c52d75a929446..7a47493eadbdc 100644 --- a/crates/oxc_syntax/src/operator.rs +++ b/crates/oxc_syntax/src/operator.rs @@ -6,9 +6,8 @@ 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 crate::precedence::{GetPrecedence, Precedence}; @@ -18,56 +17,56 @@ use crate::precedence::{GetPrecedence, Precedence}; /// - [13.15 Assignment Operators](https://tc39.es/ecma262/#sec-assignment-operators) #[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)] +#[estree(rename_all = "camelCase")] 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, } @@ -125,74 +124,74 @@ impl AssignmentOperator { /// - [12.10 Binary Logical Operators](https://tc39.es/ecma262/#sec-binary-logical-operators) #[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)] +#[estree(rename_all = "camelCase")] 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, /// `in` - #[serde(rename = "in")] + #[estree(rename = "in")] In = 19, /// `instanceof` - #[serde(rename = "instanceof")] + #[estree(rename = "instanceof")] Instanceof = 20, /// `**` - #[serde(rename = "**")] + #[estree(rename = "**")] Exponential = 21, } @@ -356,17 +355,17 @@ impl GetPrecedence for BinaryOperator { /// Logical binary operators #[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)] +#[estree(rename_all = "camelCase")] pub enum LogicalOperator { /// `||` - #[serde(rename = "||")] + #[estree(rename = "||")] Or = 0, /// `&&` - #[serde(rename = "&&")] + #[estree(rename = "&&")] And = 1, /// `??` - #[serde(rename = "??")] + #[estree(rename = "??")] Coalesce = 2, } @@ -410,29 +409,29 @@ impl GetPrecedence for LogicalOperator { /// - [12.5 Unary Operators](https://tc39.es/ecma262/#sec-unary-operators) #[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)] +#[estree(rename_all = "camelCase")] 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, /// `typeof` - #[serde(rename = "typeof")] + #[estree(rename = "typeof")] Typeof = 4, /// `void` - #[serde(rename = "void")] + #[estree(rename = "void")] Void = 5, /// `delete` - #[serde(rename = "delete")] + #[estree(rename = "delete")] Delete = 6, } @@ -481,14 +480,14 @@ impl UnaryOperator { /// Unary update operators. #[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)] +#[estree(rename_all = "camelCase")] 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 new file mode 100644 index 0000000000000..2ec0f91511581 --- /dev/null +++ b/tasks/ast_tools/src/derives/estree.rs @@ -0,0 +1,241 @@ +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, TypeName, + }, +}; + +define_derive! { + pub struct DeriveESTree; +} + +impl Derive for DeriveESTree { + fn trait_name() -> &'static str { + "ESTree" + } + + fn derive(&mut self, def: &TypeDef, _: &LateCtx) -> TokenStream { + 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! { + impl<'a> Serialize for #ident<'a> { + #[allow(clippy::match_same_arms, unused_mut)] + fn serialize(&self, serializer: S) -> Result + where S: Serializer, + { + #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 + } + } + #type_def + } + } + } + + fn prelude() -> TokenStream { + quote! { + #[allow(unused_imports)] + use serde::{Serialize, Serializer, ser::SerializeMap}; + } + } +} + +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 = get_type_tag(def); + + 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().to_case(Case::Camel), + }; + 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 = enum_variant_name(var, def); + 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),* + } + } + } +} + +// 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/derives/mod.rs b/tasks/ast_tools/src/derives/mod.rs index f6617b34cc399..e285652372745 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 { @@ -43,7 +45,7 @@ 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("::"); let use_module: syn::ItemUse = @@ -106,10 +108,17 @@ 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 dc9e3595dfef2..c500924f418c4 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, @@ -75,6 +78,7 @@ fn main() -> std::result::Result<(), Box> { .derive(DeriveGetSpanMut) .derive(DeriveContentEq) .derive(DeriveContentHash) + .derive(DeriveESTree) .generate(AssertLayouts) .generate(AstKindGenerator) .generate(AstBuilderGenerator) diff --git a/tasks/ast_tools/src/markers.rs b/tasks/ast_tools/src/markers.rs index 7d634c8bd8a00..9b3996383fcf9 100644 --- a/tasks/ast_tools/src/markers.rs +++ b/tasks/ast_tools/src/markers.rs @@ -7,7 +7,7 @@ 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; @@ -74,6 +74,8 @@ pub struct ScopeMarkers { #[derive(Debug, Default, Serialize)] 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. @@ -94,6 +96,137 @@ impl From<&Ident> for CloneInAttribute { } } +/// An enum representing the `#[estree(...)]` attributes that we implement for structs. +#[derive(Debug, Serialize, PartialEq, Eq)] +pub enum ESTreeStructAttribute { + CustomSerialize, + 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(); + match ident.as_str() { + "no_type" => Ok(Self::NoType), + "custom_serialize" => Ok(Self::CustomSerialize), + _ => panic!("Unsupported #[estree(...)] argument: {ident}"), + } + } + } +} + +/// A struct representing the `#[estree(...)]` attributes that we implement for enums. +#[derive(Debug, Serialize, Default)] +pub struct ESTreeEnumAttribute { + pub rename_all: Option, + pub untagged: bool, +} + +impl Parse for ESTreeEnumAttribute { + fn parse(input: ParseStream) -> Result { + let mut rename_all = None; + let mut untagged = false; + + loop { + let ident = input.call(Ident::parse_any).unwrap().to_string(); + match ident.as_str() { + "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}"), + } + let comma = input.peek(Token![,]); + if comma { + input.parse::().unwrap(); + } else { + break; + } + } + Ok(Self { rename_all, untagged }) + } +} + +/// A struct representing the `#[estree(...)]` attributes that we implement for fields. +#[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 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 }) + } +} + +/// 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 { @@ -228,13 +361,44 @@ where Ok(None) } } + 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) + } + } + 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."); } + 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() }) + Ok(DeriveAttributes { + clone_in: clone_in.unwrap_or_default(), + estree: estree.unwrap_or_default(), + tsify_type, + }) } pub fn get_scope_attribute<'a, I>(attrs: I) -> Option> @@ -254,3 +418,15 @@ where result.normalize() }) } + +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(T::parse).normalize() + }) +} diff --git a/tasks/ast_tools/src/schema/defs.rs b/tasks/ast_tools/src/schema/defs.rs index 4625599165477..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, 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, } @@ -84,6 +87,8 @@ pub struct EnumDef { pub generated_derives: Vec, #[serde(skip)] pub module_path: String, + #[serde(skip)] + pub markers: EnumOuterMarkers, } impl EnumDef { @@ -226,8 +231,14 @@ impl TypeRef { } #[derive(Debug)] -pub struct OuterMarkers { +pub struct StructOuterMarkers { pub scope: Option, + 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 67e005326f318..fc7df13766558 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, @@ -14,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; @@ -103,8 +107,15 @@ impl<'a> IntoIterator for &'a Schema { } } -fn parse_outer_markers(attrs: &Vec) -> Result { - Ok(OuterMarkers { scope: get_scope_attribute(attrs).transpose()? }) +fn parse_struct_outer_markers(attrs: &Vec) -> Result { + Ok(StructOuterMarkers { + scope: get_scope_attribute(attrs).transpose()?, + 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 { @@ -167,6 +178,7 @@ fn lower_ast_enum(it @ rust::Enum { item, meta }: &rust::Enum, ctx: &codegen::Ea align_32, offsets_32, + markers: parse_enum_outer_markers(&item.attrs).unwrap(), generated_derives: parse_generate_derive(&item.attrs), module_path: meta.module_path.clone(), @@ -201,7 +213,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(), diff --git a/tasks/ast_tools/src/schema/serialize.rs b/tasks/ast_tools/src/schema/serialize.rs new file mode 100644 index 0000000000000..abd61ce7cc98b --- /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()), + Some(ESTreeStructAttribute::CustomSerialize) | 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()) + } + } + } +}