diff --git a/crates/oxc_ast/src/generated/assert_layouts.rs b/crates/oxc_ast/src/generated/assert_layouts.rs index 6bae73ef2fe45..b8b8980de7449 100644 --- a/crates/oxc_ast/src/generated/assert_layouts.rs +++ b/crates/oxc_ast/src/generated/assert_layouts.rs @@ -9,48 +9,6 @@ use crate::ast::*; #[cfg(target_pointer_width = "64")] const _: () = { - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(BooleanLiteral, span) == 0usize); - assert!(offset_of!(BooleanLiteral, value) == 8usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(NullLiteral, span) == 0usize); - - assert!(size_of::() == 40usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(NumericLiteral, span) == 0usize); - assert!(offset_of!(NumericLiteral, value) == 8usize); - assert!(offset_of!(NumericLiteral, raw) == 16usize); - assert!(offset_of!(NumericLiteral, base) == 32usize); - - assert!(size_of::() == 40usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(StringLiteral, span) == 0usize); - assert!(offset_of!(StringLiteral, value) == 8usize); - assert!(offset_of!(StringLiteral, raw) == 24usize); - - assert!(size_of::() == 32usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(BigIntLiteral, span) == 0usize); - assert!(offset_of!(BigIntLiteral, raw) == 8usize); - assert!(offset_of!(BigIntLiteral, base) == 24usize); - - assert!(size_of::() == 56usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(RegExpLiteral, span) == 0usize); - assert!(offset_of!(RegExpLiteral, regex) == 8usize); - assert!(offset_of!(RegExpLiteral, raw) == 40usize); - - assert!(size_of::() == 32usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(RegExp, pattern) == 0usize); - assert!(offset_of!(RegExp, flags) == 24usize); - - assert!(size_of::() == 24usize); - assert!(align_of::() == 8usize); - assert!(size_of::() == 160usize); assert!(align_of::() == 8usize); assert!(offset_of!(Program, span) == 0usize); @@ -788,6 +746,151 @@ const _: () = { assert!(size_of::() == 48usize); assert!(align_of::() == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BooleanLiteral, span) == 0usize); + assert!(offset_of!(BooleanLiteral, value) == 8usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(NullLiteral, span) == 0usize); + + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(NumericLiteral, span) == 0usize); + assert!(offset_of!(NumericLiteral, value) == 8usize); + assert!(offset_of!(NumericLiteral, raw) == 16usize); + assert!(offset_of!(NumericLiteral, base) == 32usize); + + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(StringLiteral, span) == 0usize); + assert!(offset_of!(StringLiteral, value) == 8usize); + assert!(offset_of!(StringLiteral, raw) == 24usize); + + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BigIntLiteral, span) == 0usize); + assert!(offset_of!(BigIntLiteral, raw) == 8usize); + assert!(offset_of!(BigIntLiteral, base) == 24usize); + + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(RegExpLiteral, span) == 0usize); + assert!(offset_of!(RegExpLiteral, regex) == 8usize); + assert!(offset_of!(RegExpLiteral, raw) == 40usize); + + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(RegExp, pattern) == 0usize); + assert!(offset_of!(RegExp, flags) == 24usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXElement, span) == 0usize); + assert!(offset_of!(JSXElement, opening_element) == 8usize); + assert!(offset_of!(JSXElement, closing_element) == 16usize); + assert!(offset_of!(JSXElement, children) == 24usize); + + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXOpeningElement, span) == 0usize); + assert!(offset_of!(JSXOpeningElement, self_closing) == 8usize); + assert!(offset_of!(JSXOpeningElement, name) == 16usize); + assert!(offset_of!(JSXOpeningElement, attributes) == 32usize); + assert!(offset_of!(JSXOpeningElement, type_parameters) == 64usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXClosingElement, span) == 0usize); + assert!(offset_of!(JSXClosingElement, name) == 8usize); + + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXFragment, span) == 0usize); + assert!(offset_of!(JSXFragment, opening_fragment) == 8usize); + assert!(offset_of!(JSXFragment, closing_fragment) == 16usize); + assert!(offset_of!(JSXFragment, children) == 24usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXOpeningFragment, span) == 0usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXClosingFragment, span) == 0usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXNamespacedName, span) == 0usize); + assert!(offset_of!(JSXNamespacedName, namespace) == 8usize); + assert!(offset_of!(JSXNamespacedName, property) == 32usize); + + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXMemberExpression, span) == 0usize); + assert!(offset_of!(JSXMemberExpression, object) == 8usize); + assert!(offset_of!(JSXMemberExpression, property) == 24usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXExpressionContainer, span) == 0usize); + assert!(offset_of!(JSXExpressionContainer, expression) == 8usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXEmptyExpression, span) == 0usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXAttribute, span) == 0usize); + assert!(offset_of!(JSXAttribute, name) == 8usize); + assert!(offset_of!(JSXAttribute, value) == 24usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXSpreadAttribute, span) == 0usize); + assert!(offset_of!(JSXSpreadAttribute, argument) == 8usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXIdentifier, span) == 0usize); + assert!(offset_of!(JSXIdentifier, name) == 8usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXSpreadChild, span) == 0usize); + assert!(offset_of!(JSXSpreadChild, expression) == 8usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXText, span) == 0usize); + assert!(offset_of!(JSXText, value) == 8usize); + assert!(size_of::() == 24usize); assert!(align_of::() == 8usize); assert!(offset_of!(TSThisParameter, span) == 0usize); @@ -1275,144 +1378,41 @@ const _: () = { assert!(align_of::() == 8usize); assert!(offset_of!(JSDocUnknownType, span) == 0usize); - assert!(size_of::() == 56usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXElement, span) == 0usize); - assert!(offset_of!(JSXElement, opening_element) == 8usize); - assert!(offset_of!(JSXElement, closing_element) == 16usize); - assert!(offset_of!(JSXElement, children) == 24usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); - assert!(size_of::() == 72usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXOpeningElement, span) == 0usize); - assert!(offset_of!(JSXOpeningElement, self_closing) == 8usize); - assert!(offset_of!(JSXOpeningElement, name) == 16usize); - assert!(offset_of!(JSXOpeningElement, attributes) == 32usize); - assert!(offset_of!(JSXOpeningElement, type_parameters) == 64usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); - assert!(size_of::() == 24usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXClosingElement, span) == 0usize); - assert!(offset_of!(JSXClosingElement, name) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(Comment, span) == 0usize); + assert!(offset_of!(Comment, attached_to) == 8usize); + assert!(offset_of!(Comment, kind) == 12usize); + assert!(offset_of!(Comment, position) == 13usize); + assert!(offset_of!(Comment, preceded_by_newline) == 14usize); + assert!(offset_of!(Comment, followed_by_newline) == 15usize); - assert!(size_of::() == 56usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXFragment, span) == 0usize); - assert!(offset_of!(JSXFragment, opening_fragment) == 8usize); - assert!(offset_of!(JSXFragment, closing_fragment) == 16usize); - assert!(offset_of!(JSXFragment, children) == 24usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); - assert!(size_of::() == 8usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXOpeningFragment, span) == 0usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); - assert!(size_of::() == 8usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXClosingFragment, span) == 0usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); - assert!(size_of::() == 56usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXNamespacedName, span) == 0usize); - assert!(offset_of!(JSXNamespacedName, namespace) == 8usize); - assert!(offset_of!(JSXNamespacedName, property) == 32usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); - assert!(size_of::() == 48usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXMemberExpression, span) == 0usize); - assert!(offset_of!(JSXMemberExpression, object) == 8usize); - assert!(offset_of!(JSXMemberExpression, property) == 24usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); - - assert!(size_of::() == 24usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXExpressionContainer, span) == 0usize); - assert!(offset_of!(JSXExpressionContainer, expression) == 8usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXEmptyExpression, span) == 0usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); - - assert!(size_of::() == 40usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXAttribute, span) == 0usize); - assert!(offset_of!(JSXAttribute, name) == 8usize); - assert!(offset_of!(JSXAttribute, value) == 24usize); - - assert!(size_of::() == 24usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXSpreadAttribute, span) == 0usize); - assert!(offset_of!(JSXSpreadAttribute, argument) == 8usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); - - assert!(size_of::() == 24usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXIdentifier, span) == 0usize); - assert!(offset_of!(JSXIdentifier, name) == 8usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); - - assert!(size_of::() == 24usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXSpreadChild, span) == 0usize); - assert!(offset_of!(JSXSpreadChild, expression) == 8usize); - - assert!(size_of::() == 24usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(JSXText, span) == 0usize); - assert!(offset_of!(JSXText, value) == 8usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(Comment, span) == 0usize); - assert!(offset_of!(Comment, attached_to) == 8usize); - assert!(offset_of!(Comment, kind) == 12usize); - assert!(offset_of!(Comment, position) == 13usize); - assert!(offset_of!(Comment, preceded_by_newline) == 14usize); - assert!(offset_of!(Comment, followed_by_newline) == 15usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); - - assert!(size_of::() == 1usize); - assert!(align_of::() == 1usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); assert!(size_of::() == 8usize); assert!(align_of::() == 8usize); @@ -1575,48 +1575,6 @@ const _: () = { #[cfg(target_pointer_width = "32")] const _: () = { - assert!(size_of::() == 12usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(BooleanLiteral, span) == 0usize); - assert!(offset_of!(BooleanLiteral, value) == 8usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(NullLiteral, span) == 0usize); - - assert!(size_of::() == 32usize); - assert!(align_of::() == 8usize); - assert!(offset_of!(NumericLiteral, span) == 0usize); - assert!(offset_of!(NumericLiteral, value) == 8usize); - assert!(offset_of!(NumericLiteral, raw) == 16usize); - assert!(offset_of!(NumericLiteral, base) == 24usize); - - assert!(size_of::() == 24usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(StringLiteral, span) == 0usize); - assert!(offset_of!(StringLiteral, value) == 8usize); - assert!(offset_of!(StringLiteral, raw) == 16usize); - - assert!(size_of::() == 20usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(BigIntLiteral, span) == 0usize); - assert!(offset_of!(BigIntLiteral, raw) == 8usize); - assert!(offset_of!(BigIntLiteral, base) == 16usize); - - assert!(size_of::() == 32usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(RegExpLiteral, span) == 0usize); - assert!(offset_of!(RegExpLiteral, regex) == 8usize); - assert!(offset_of!(RegExpLiteral, raw) == 24usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(RegExp, pattern) == 0usize); - assert!(offset_of!(RegExp, flags) == 12usize); - - assert!(size_of::() == 12usize); - assert!(align_of::() == 4usize); - assert!(size_of::() == 88usize); assert!(align_of::() == 4usize); assert!(offset_of!(Program, span) == 0usize); @@ -2354,6 +2312,151 @@ const _: () = { assert!(size_of::() == 28usize); assert!(align_of::() == 4usize); + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BooleanLiteral, span) == 0usize); + assert!(offset_of!(BooleanLiteral, value) == 8usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(NullLiteral, span) == 0usize); + + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(NumericLiteral, span) == 0usize); + assert!(offset_of!(NumericLiteral, value) == 8usize); + assert!(offset_of!(NumericLiteral, raw) == 16usize); + assert!(offset_of!(NumericLiteral, base) == 24usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(StringLiteral, span) == 0usize); + assert!(offset_of!(StringLiteral, value) == 8usize); + assert!(offset_of!(StringLiteral, raw) == 16usize); + + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BigIntLiteral, span) == 0usize); + assert!(offset_of!(BigIntLiteral, raw) == 8usize); + assert!(offset_of!(BigIntLiteral, base) == 16usize); + + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(RegExpLiteral, span) == 0usize); + assert!(offset_of!(RegExpLiteral, regex) == 8usize); + assert!(offset_of!(RegExpLiteral, raw) == 24usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(RegExp, pattern) == 0usize); + assert!(offset_of!(RegExp, flags) == 12usize); + + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXElement, span) == 0usize); + assert!(offset_of!(JSXElement, opening_element) == 8usize); + assert!(offset_of!(JSXElement, closing_element) == 12usize); + assert!(offset_of!(JSXElement, children) == 16usize); + + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXOpeningElement, span) == 0usize); + assert!(offset_of!(JSXOpeningElement, self_closing) == 8usize); + assert!(offset_of!(JSXOpeningElement, name) == 12usize); + assert!(offset_of!(JSXOpeningElement, attributes) == 20usize); + assert!(offset_of!(JSXOpeningElement, type_parameters) == 36usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXClosingElement, span) == 0usize); + assert!(offset_of!(JSXClosingElement, name) == 8usize); + + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXFragment, span) == 0usize); + assert!(offset_of!(JSXFragment, opening_fragment) == 8usize); + assert!(offset_of!(JSXFragment, closing_fragment) == 16usize); + assert!(offset_of!(JSXFragment, children) == 24usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXOpeningFragment, span) == 0usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXClosingFragment, span) == 0usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXNamespacedName, span) == 0usize); + assert!(offset_of!(JSXNamespacedName, namespace) == 8usize); + assert!(offset_of!(JSXNamespacedName, property) == 24usize); + + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXMemberExpression, span) == 0usize); + assert!(offset_of!(JSXMemberExpression, object) == 8usize); + assert!(offset_of!(JSXMemberExpression, property) == 16usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXExpressionContainer, span) == 0usize); + assert!(offset_of!(JSXExpressionContainer, expression) == 8usize); + + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXEmptyExpression, span) == 0usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXAttribute, span) == 0usize); + assert!(offset_of!(JSXAttribute, name) == 8usize); + assert!(offset_of!(JSXAttribute, value) == 16usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXSpreadAttribute, span) == 0usize); + assert!(offset_of!(JSXSpreadAttribute, argument) == 8usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXIdentifier, span) == 0usize); + assert!(offset_of!(JSXIdentifier, name) == 8usize); + + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXSpreadChild, span) == 0usize); + assert!(offset_of!(JSXSpreadChild, expression) == 8usize); + + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXText, span) == 0usize); + assert!(offset_of!(JSXText, value) == 8usize); + assert!(size_of::() == 20usize); assert!(align_of::() == 4usize); assert!(offset_of!(TSThisParameter, span) == 0usize); @@ -2841,109 +2944,6 @@ const _: () = { assert!(align_of::() == 4usize); assert!(offset_of!(JSDocUnknownType, span) == 0usize); - assert!(size_of::() == 32usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXElement, span) == 0usize); - assert!(offset_of!(JSXElement, opening_element) == 8usize); - assert!(offset_of!(JSXElement, closing_element) == 12usize); - assert!(offset_of!(JSXElement, children) == 16usize); - - assert!(size_of::() == 40usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXOpeningElement, span) == 0usize); - assert!(offset_of!(JSXOpeningElement, self_closing) == 8usize); - assert!(offset_of!(JSXOpeningElement, name) == 12usize); - assert!(offset_of!(JSXOpeningElement, attributes) == 20usize); - assert!(offset_of!(JSXOpeningElement, type_parameters) == 36usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXClosingElement, span) == 0usize); - assert!(offset_of!(JSXClosingElement, name) == 8usize); - - assert!(size_of::() == 40usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXFragment, span) == 0usize); - assert!(offset_of!(JSXFragment, opening_fragment) == 8usize); - assert!(offset_of!(JSXFragment, closing_fragment) == 16usize); - assert!(offset_of!(JSXFragment, children) == 24usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXOpeningFragment, span) == 0usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXClosingFragment, span) == 0usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - - assert!(size_of::() == 40usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXNamespacedName, span) == 0usize); - assert!(offset_of!(JSXNamespacedName, namespace) == 8usize); - assert!(offset_of!(JSXNamespacedName, property) == 24usize); - - assert!(size_of::() == 32usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXMemberExpression, span) == 0usize); - assert!(offset_of!(JSXMemberExpression, object) == 8usize); - assert!(offset_of!(JSXMemberExpression, property) == 16usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - - assert!(size_of::() == 20usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXExpressionContainer, span) == 0usize); - assert!(offset_of!(JSXExpressionContainer, expression) == 8usize); - - assert!(size_of::() == 12usize); - assert!(align_of::() == 4usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXEmptyExpression, span) == 0usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - - assert!(size_of::() == 24usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXAttribute, span) == 0usize); - assert!(offset_of!(JSXAttribute, name) == 8usize); - assert!(offset_of!(JSXAttribute, value) == 16usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXSpreadAttribute, span) == 0usize); - assert!(offset_of!(JSXSpreadAttribute, argument) == 8usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXIdentifier, span) == 0usize); - assert!(offset_of!(JSXIdentifier, name) == 8usize); - - assert!(size_of::() == 8usize); - assert!(align_of::() == 4usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXSpreadChild, span) == 0usize); - assert!(offset_of!(JSXSpreadChild, expression) == 8usize); - - assert!(size_of::() == 16usize); - assert!(align_of::() == 4usize); - assert!(offset_of!(JSXText, span) == 0usize); - assert!(offset_of!(JSXText, value) == 8usize); - assert!(size_of::() == 1usize); assert!(align_of::() == 1usize); diff --git a/crates/oxc_ast/src/generated/ast_builder.rs b/crates/oxc_ast/src/generated/ast_builder.rs index 31e2a7e1d5986..7da9e7d02491f 100644 --- a/crates/oxc_ast/src/generated/ast_builder.rs +++ b/crates/oxc_ast/src/generated/ast_builder.rs @@ -24,202 +24,6 @@ pub struct AstBuilder<'a> { } impl<'a> AstBuilder<'a> { - /// Build a [`BooleanLiteral`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_boolean_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The boolean value itself - #[inline] - pub fn boolean_literal(self, span: Span, value: bool) -> BooleanLiteral { - BooleanLiteral { span, value } - } - - /// Build a [`BooleanLiteral`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::boolean_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The boolean value itself - #[inline] - pub fn alloc_boolean_literal(self, span: Span, value: bool) -> Box<'a, BooleanLiteral> { - Box::new_in(self.boolean_literal(span, value), self.allocator) - } - - /// Build a [`NullLiteral`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_null_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - #[inline] - pub fn null_literal(self, span: Span) -> NullLiteral { - NullLiteral { span } - } - - /// Build a [`NullLiteral`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::null_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - #[inline] - pub fn alloc_null_literal(self, span: Span) -> Box<'a, NullLiteral> { - Box::new_in(self.null_literal(span), self.allocator) - } - - /// Build a [`NumericLiteral`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_numeric_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The value of the number, converted into base 10 - /// * `raw`: The number as it appears in source code - /// * `base`: The base representation used by the literal in source code - #[inline] - pub fn numeric_literal( - self, - span: Span, - value: f64, - raw: Option>, - base: NumberBase, - ) -> NumericLiteral<'a> { - NumericLiteral { span, value, raw, base } - } - - /// Build a [`NumericLiteral`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::numeric_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The value of the number, converted into base 10 - /// * `raw`: The number as it appears in source code - /// * `base`: The base representation used by the literal in source code - #[inline] - pub fn alloc_numeric_literal( - self, - span: Span, - value: f64, - raw: Option>, - base: NumberBase, - ) -> Box<'a, NumericLiteral<'a>> { - Box::new_in(self.numeric_literal(span, value, raw, base), self.allocator) - } - - /// Build a [`StringLiteral`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_string_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The value of the string. - /// * `raw`: The raw string as it appears in source code. - #[inline] - pub fn string_literal(self, span: Span, value: A, raw: Option>) -> StringLiteral<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - StringLiteral { span, value: value.into_in(self.allocator), raw } - } - - /// Build a [`StringLiteral`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::string_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The value of the string. - /// * `raw`: The raw string as it appears in source code. - #[inline] - pub fn alloc_string_literal( - self, - span: Span, - value: A, - raw: Option>, - ) -> Box<'a, StringLiteral<'a>> - where - A: IntoIn<'a, Atom<'a>>, - { - Box::new_in(self.string_literal(span, value, raw), self.allocator) - } - - /// Build a [`BigIntLiteral`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_big_int_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `raw`: The bigint as it appears in source code - /// * `base`: The base representation used by the literal in source code - #[inline] - pub fn big_int_literal(self, span: Span, raw: A, base: BigintBase) -> BigIntLiteral<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - BigIntLiteral { span, raw: raw.into_in(self.allocator), base } - } - - /// Build a [`BigIntLiteral`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::big_int_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `raw`: The bigint as it appears in source code - /// * `base`: The base representation used by the literal in source code - #[inline] - pub fn alloc_big_int_literal( - self, - span: Span, - raw: A, - base: BigintBase, - ) -> Box<'a, BigIntLiteral<'a>> - where - A: IntoIn<'a, Atom<'a>>, - { - Box::new_in(self.big_int_literal(span, raw, base), self.allocator) - } - - /// Build a [`RegExpLiteral`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_reg_exp_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `regex`: The parsed regular expression. See [`oxc_regular_expression`] for more - /// * `raw`: The regular expression as it appears in source code - #[inline] - pub fn reg_exp_literal( - self, - span: Span, - regex: RegExp<'a>, - raw: Option>, - ) -> RegExpLiteral<'a> { - RegExpLiteral { span, regex, raw } - } - - /// Build a [`RegExpLiteral`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::reg_exp_literal`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `regex`: The parsed regular expression. See [`oxc_regular_expression`] for more - /// * `raw`: The regular expression as it appears in source code - #[inline] - pub fn alloc_reg_exp_literal( - self, - span: Span, - regex: RegExp<'a>, - raw: Option>, - ) -> Box<'a, RegExpLiteral<'a>> { - Box::new_in(self.reg_exp_literal(span, regex, raw), self.allocator) - } - /// Build a [`Program`]. /// /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_program`] instead. @@ -7585,5473 +7389,5669 @@ impl<'a> AstBuilder<'a> { ModuleExportName::StringLiteral(self.string_literal(span, value, raw)) } - /// Build a [`TSThisParameter`]. + /// Build a [`BooleanLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_this_parameter`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_boolean_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `this_span` - /// * `type_annotation`: Type type the `this` keyword will have in the function + /// * `span`: Node location in source code + /// * `value`: The boolean value itself #[inline] - pub fn ts_this_parameter( - self, - span: Span, - this_span: Span, - type_annotation: T1, - ) -> TSThisParameter<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSThisParameter { - span, - this_span, - type_annotation: type_annotation.into_in(self.allocator), - } + pub fn boolean_literal(self, span: Span, value: bool) -> BooleanLiteral { + BooleanLiteral { span, value } } - /// Build a [`TSThisParameter`], and store it in the memory arena. + /// Build a [`BooleanLiteral`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_this_parameter`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::boolean_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `this_span` - /// * `type_annotation`: Type type the `this` keyword will have in the function + /// * `span`: Node location in source code + /// * `value`: The boolean value itself #[inline] - pub fn alloc_ts_this_parameter( - self, - span: Span, - this_span: Span, - type_annotation: T1, - ) -> Box<'a, TSThisParameter<'a>> - where - T1: IntoIn<'a, Option>>>, - { - Box::new_in(self.ts_this_parameter(span, this_span, type_annotation), self.allocator) + pub fn alloc_boolean_literal(self, span: Span, value: bool) -> Box<'a, BooleanLiteral> { + Box::new_in(self.boolean_literal(span, value), self.allocator) } - /// Build a [`TSEnumDeclaration`]. + /// Build a [`NullLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_enum_declaration`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_null_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `id` - /// * `members` - /// * `const`: `true` for const enums - /// * `declare` + /// * `span`: Node location in source code #[inline] - pub fn ts_enum_declaration( - self, - span: Span, - id: BindingIdentifier<'a>, - members: Vec<'a, TSEnumMember<'a>>, - r#const: bool, - declare: bool, - ) -> TSEnumDeclaration<'a> { - TSEnumDeclaration { span, id, members, r#const, declare, scope_id: Default::default() } + pub fn null_literal(self, span: Span) -> NullLiteral { + NullLiteral { span } } - /// Build a [`TSEnumDeclaration`], and store it in the memory arena. + /// Build a [`NullLiteral`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_enum_declaration`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::null_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `id` - /// * `members` - /// * `const`: `true` for const enums - /// * `declare` + /// * `span`: Node location in source code #[inline] - pub fn alloc_ts_enum_declaration( - self, - span: Span, - id: BindingIdentifier<'a>, - members: Vec<'a, TSEnumMember<'a>>, - r#const: bool, - declare: bool, - ) -> Box<'a, TSEnumDeclaration<'a>> { - Box::new_in(self.ts_enum_declaration(span, id, members, r#const, declare), self.allocator) + pub fn alloc_null_literal(self, span: Span) -> Box<'a, NullLiteral> { + Box::new_in(self.null_literal(span), self.allocator) } - /// Build a [`TSEnumDeclaration`] with `ScopeId`. + /// Build a [`NumericLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_enum_declaration_with_scope_id`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_numeric_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `id` - /// * `members` - /// * `const`: `true` for const enums - /// * `declare` - /// * `scope_id` + /// * `span`: Node location in source code + /// * `value`: The value of the number, converted into base 10 + /// * `raw`: The number as it appears in source code + /// * `base`: The base representation used by the literal in source code #[inline] - pub fn ts_enum_declaration_with_scope_id( + pub fn numeric_literal( self, span: Span, - id: BindingIdentifier<'a>, - members: Vec<'a, TSEnumMember<'a>>, - r#const: bool, - declare: bool, - scope_id: ScopeId, - ) -> TSEnumDeclaration<'a> { - TSEnumDeclaration { - span, - id, - members, - r#const, - declare, - scope_id: Cell::new(Some(scope_id)), - } + value: f64, + raw: Option>, + base: NumberBase, + ) -> NumericLiteral<'a> { + NumericLiteral { span, value, raw, base } } - /// Build a [`TSEnumDeclaration`] with `ScopeId`, and store it in the memory arena. + /// Build a [`NumericLiteral`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_enum_declaration_with_scope_id`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::numeric_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `id` - /// * `members` - /// * `const`: `true` for const enums - /// * `declare` - /// * `scope_id` + /// * `span`: Node location in source code + /// * `value`: The value of the number, converted into base 10 + /// * `raw`: The number as it appears in source code + /// * `base`: The base representation used by the literal in source code #[inline] - pub fn alloc_ts_enum_declaration_with_scope_id( + pub fn alloc_numeric_literal( self, span: Span, - id: BindingIdentifier<'a>, - members: Vec<'a, TSEnumMember<'a>>, - r#const: bool, - declare: bool, - scope_id: ScopeId, - ) -> Box<'a, TSEnumDeclaration<'a>> { - Box::new_in( - self.ts_enum_declaration_with_scope_id(span, id, members, r#const, declare, scope_id), - self.allocator, - ) + value: f64, + raw: Option>, + base: NumberBase, + ) -> Box<'a, NumericLiteral<'a>> { + Box::new_in(self.numeric_literal(span, value, raw, base), self.allocator) } - /// Build a [`TSEnumMember`]. + /// Build a [`StringLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_enum_member`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_string_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `id` - /// * `initializer` + /// * `span`: Node location in source code + /// * `value`: The value of the string. + /// * `raw`: The raw string as it appears in source code. #[inline] - pub fn ts_enum_member( - self, - span: Span, - id: TSEnumMemberName<'a>, - initializer: Option>, - ) -> TSEnumMember<'a> { - TSEnumMember { span, id, initializer } + pub fn string_literal(self, span: Span, value: A, raw: Option>) -> StringLiteral<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + StringLiteral { span, value: value.into_in(self.allocator), raw } } - /// Build a [`TSEnumMember`], and store it in the memory arena. + /// Build a [`StringLiteral`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_enum_member`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::string_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `id` - /// * `initializer` + /// * `span`: Node location in source code + /// * `value`: The value of the string. + /// * `raw`: The raw string as it appears in source code. #[inline] - pub fn alloc_ts_enum_member( + pub fn alloc_string_literal( self, span: Span, - id: TSEnumMemberName<'a>, - initializer: Option>, - ) -> Box<'a, TSEnumMember<'a>> { - Box::new_in(self.ts_enum_member(span, id, initializer), self.allocator) + value: A, + raw: Option>, + ) -> Box<'a, StringLiteral<'a>> + where + A: IntoIn<'a, Atom<'a>>, + { + Box::new_in(self.string_literal(span, value, raw), self.allocator) } - /// Build a [`TSEnumMemberName::Identifier`]. + /// Build a [`BigIntLiteral`]. /// - /// This node contains an [`IdentifierName`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_big_int_literal`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `name` + /// * `span`: Node location in source code + /// * `raw`: The bigint as it appears in source code + /// * `base`: The base representation used by the literal in source code #[inline] - pub fn ts_enum_member_name_identifier_name(self, span: Span, name: A) -> TSEnumMemberName<'a> + pub fn big_int_literal(self, span: Span, raw: A, base: BigintBase) -> BigIntLiteral<'a> where A: IntoIn<'a, Atom<'a>>, { - TSEnumMemberName::Identifier(self.alloc_identifier_name(span, name)) + BigIntLiteral { span, raw: raw.into_in(self.allocator), base } } - /// Build a [`TSEnumMemberName::String`]. + /// Build a [`BigIntLiteral`], and store it in the memory arena. /// - /// This node contains a [`StringLiteral`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::big_int_literal`] instead. /// /// ## Parameters /// * `span`: Node location in source code - /// * `value`: The value of the string. - /// * `raw`: The raw string as it appears in source code. + /// * `raw`: The bigint as it appears in source code + /// * `base`: The base representation used by the literal in source code #[inline] - pub fn ts_enum_member_name_string_literal( + pub fn alloc_big_int_literal( self, span: Span, - value: A, - raw: Option>, - ) -> TSEnumMemberName<'a> + raw: A, + base: BigintBase, + ) -> Box<'a, BigIntLiteral<'a>> where A: IntoIn<'a, Atom<'a>>, { - TSEnumMemberName::String(self.alloc_string_literal(span, value, raw)) + Box::new_in(self.big_int_literal(span, raw, base), self.allocator) } - /// Build a [`TSTypeAnnotation`]. + /// Build a [`RegExpLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_annotation`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_reg_exp_literal`] instead. /// /// ## Parameters - /// * `span`: starts at the `:` token and ends at the end of the type annotation - /// * `type_annotation`: The actual type in the annotation + /// * `span`: Node location in source code + /// * `regex`: The parsed regular expression. See [`oxc_regular_expression`] for more + /// * `raw`: The regular expression as it appears in source code #[inline] - pub fn ts_type_annotation( + pub fn reg_exp_literal( self, span: Span, - type_annotation: TSType<'a>, - ) -> TSTypeAnnotation<'a> { - TSTypeAnnotation { span, type_annotation } + regex: RegExp<'a>, + raw: Option>, + ) -> RegExpLiteral<'a> { + RegExpLiteral { span, regex, raw } } - /// Build a [`TSTypeAnnotation`], and store it in the memory arena. + /// Build a [`RegExpLiteral`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_annotation`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::reg_exp_literal`] instead. /// /// ## Parameters - /// * `span`: starts at the `:` token and ends at the end of the type annotation - /// * `type_annotation`: The actual type in the annotation + /// * `span`: Node location in source code + /// * `regex`: The parsed regular expression. See [`oxc_regular_expression`] for more + /// * `raw`: The regular expression as it appears in source code #[inline] - pub fn alloc_ts_type_annotation( + pub fn alloc_reg_exp_literal( self, span: Span, - type_annotation: TSType<'a>, - ) -> Box<'a, TSTypeAnnotation<'a>> { - Box::new_in(self.ts_type_annotation(span, type_annotation), self.allocator) - } - - /// Build a [`TSLiteralType`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_literal_type`] instead. - /// - /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `literal` - #[inline] - pub fn ts_literal_type(self, span: Span, literal: TSLiteral<'a>) -> TSLiteralType<'a> { - TSLiteralType { span, literal } + regex: RegExp<'a>, + raw: Option>, + ) -> Box<'a, RegExpLiteral<'a>> { + Box::new_in(self.reg_exp_literal(span, regex, raw), self.allocator) } - /// Build a [`TSLiteralType`], and store it in the memory arena. + /// Build a [`JSXElement`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_literal_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_element`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `literal` + /// * `span`: Node location in source code + /// * `opening_element`: Opening tag of the element. + /// * `closing_element`: Closing tag of the element. Will be [`None`] for self-closing tags. + /// * `children`: Children of the element. This can be text, other elements, or expressions. #[inline] - pub fn alloc_ts_literal_type( + pub fn jsx_element( self, span: Span, - literal: TSLiteral<'a>, - ) -> Box<'a, TSLiteralType<'a>> { - Box::new_in(self.ts_literal_type(span, literal), self.allocator) + opening_element: T1, + closing_element: T2, + children: Vec<'a, JSXChild<'a>>, + ) -> JSXElement<'a> + where + T1: IntoIn<'a, Box<'a, JSXOpeningElement<'a>>>, + T2: IntoIn<'a, Option>>>, + { + JSXElement { + span, + opening_element: opening_element.into_in(self.allocator), + closing_element: closing_element.into_in(self.allocator), + children, + } } - /// Build a [`TSLiteral::BooleanLiteral`]. + /// Build a [`JSXElement`], and store it in the memory arena. /// - /// This node contains a [`BooleanLiteral`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_element`] instead. /// /// ## Parameters /// * `span`: Node location in source code - /// * `value`: The boolean value itself + /// * `opening_element`: Opening tag of the element. + /// * `closing_element`: Closing tag of the element. Will be [`None`] for self-closing tags. + /// * `children`: Children of the element. This can be text, other elements, or expressions. #[inline] - pub fn ts_literal_boolean_literal(self, span: Span, value: bool) -> TSLiteral<'a> { - TSLiteral::BooleanLiteral(self.alloc_boolean_literal(span, value)) - } - - /// Build a [`TSLiteral::NullLiteral`]. - /// - /// This node contains a [`NullLiteral`] that will be stored in the memory arena. - /// - /// ## Parameters - /// * `span`: Node location in source code - #[inline] - pub fn ts_literal_null_literal(self, span: Span) -> TSLiteral<'a> { - TSLiteral::NullLiteral(self.alloc_null_literal(span)) + pub fn alloc_jsx_element( + self, + span: Span, + opening_element: T1, + closing_element: T2, + children: Vec<'a, JSXChild<'a>>, + ) -> Box<'a, JSXElement<'a>> + where + T1: IntoIn<'a, Box<'a, JSXOpeningElement<'a>>>, + T2: IntoIn<'a, Option>>>, + { + Box::new_in( + self.jsx_element(span, opening_element, closing_element, children), + self.allocator, + ) } - /// Build a [`TSLiteral::NumericLiteral`]. + /// Build a [`JSXOpeningElement`]. /// - /// This node contains a [`NumericLiteral`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_opening_element`] instead. /// /// ## Parameters /// * `span`: Node location in source code - /// * `value`: The value of the number, converted into base 10 - /// * `raw`: The number as it appears in source code - /// * `base`: The base representation used by the literal in source code + /// * `self_closing`: Is this tag self-closing? + /// * `name`: The possibly-namespaced tag name, e.g. `Foo` in ``. + /// * `attributes`: List of JSX attributes. In React-like applications, these become props. + /// * `type_parameters`: Type parameters for generic JSX elements. #[inline] - pub fn ts_literal_numeric_literal( + pub fn jsx_opening_element( self, span: Span, - value: f64, - raw: Option>, - base: NumberBase, - ) -> TSLiteral<'a> { - TSLiteral::NumericLiteral(self.alloc_numeric_literal(span, value, raw, base)) + self_closing: bool, + name: JSXElementName<'a>, + attributes: Vec<'a, JSXAttributeItem<'a>>, + type_parameters: T1, + ) -> JSXOpeningElement<'a> + where + T1: IntoIn<'a, Option>>>, + { + JSXOpeningElement { + span, + self_closing, + name, + attributes, + type_parameters: type_parameters.into_in(self.allocator), + } } - /// Build a [`TSLiteral::BigIntLiteral`]. + /// Build a [`JSXOpeningElement`], and store it in the memory arena. /// - /// This node contains a [`BigIntLiteral`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_opening_element`] instead. /// /// ## Parameters /// * `span`: Node location in source code - /// * `raw`: The bigint as it appears in source code - /// * `base`: The base representation used by the literal in source code + /// * `self_closing`: Is this tag self-closing? + /// * `name`: The possibly-namespaced tag name, e.g. `Foo` in ``. + /// * `attributes`: List of JSX attributes. In React-like applications, these become props. + /// * `type_parameters`: Type parameters for generic JSX elements. #[inline] - pub fn ts_literal_big_int_literal( + pub fn alloc_jsx_opening_element( self, span: Span, - raw: A, - base: BigintBase, - ) -> TSLiteral<'a> + self_closing: bool, + name: JSXElementName<'a>, + attributes: Vec<'a, JSXAttributeItem<'a>>, + type_parameters: T1, + ) -> Box<'a, JSXOpeningElement<'a>> where - A: IntoIn<'a, Atom<'a>>, + T1: IntoIn<'a, Option>>>, { - TSLiteral::BigIntLiteral(self.alloc_big_int_literal(span, raw, base)) + Box::new_in( + self.jsx_opening_element(span, self_closing, name, attributes, type_parameters), + self.allocator, + ) } - /// Build a [`TSLiteral::RegExpLiteral`]. + /// Build a [`JSXClosingElement`]. /// - /// This node contains a [`RegExpLiteral`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_closing_element`] instead. /// /// ## Parameters /// * `span`: Node location in source code - /// * `regex`: The parsed regular expression. See [`oxc_regular_expression`] for more - /// * `raw`: The regular expression as it appears in source code + /// * `name`: The tag name, e.g. `Foo` in ``. #[inline] - pub fn ts_literal_reg_exp_literal( + pub fn jsx_closing_element( self, span: Span, - regex: RegExp<'a>, - raw: Option>, - ) -> TSLiteral<'a> { - TSLiteral::RegExpLiteral(self.alloc_reg_exp_literal(span, regex, raw)) + name: JSXElementName<'a>, + ) -> JSXClosingElement<'a> { + JSXClosingElement { span, name } } - /// Build a [`TSLiteral::StringLiteral`]. + /// Build a [`JSXClosingElement`], and store it in the memory arena. /// - /// This node contains a [`StringLiteral`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_closing_element`] instead. /// /// ## Parameters /// * `span`: Node location in source code - /// * `value`: The value of the string. - /// * `raw`: The raw string as it appears in source code. + /// * `name`: The tag name, e.g. `Foo` in ``. #[inline] - pub fn ts_literal_string_literal( + pub fn alloc_jsx_closing_element( self, span: Span, - value: A, - raw: Option>, - ) -> TSLiteral<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - TSLiteral::StringLiteral(self.alloc_string_literal(span, value, raw)) + name: JSXElementName<'a>, + ) -> Box<'a, JSXClosingElement<'a>> { + Box::new_in(self.jsx_closing_element(span, name), self.allocator) } - /// Build a [`TSLiteral::TemplateLiteral`]. + /// Build a [`JSXFragment`]. /// - /// This node contains a [`TemplateLiteral`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_fragment`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `quasis` - /// * `expressions` + /// * `span`: Node location in source code + /// * `opening_fragment`: `<>` + /// * `closing_fragment`: `` + /// * `children`: Elements inside the fragment. #[inline] - pub fn ts_literal_template_literal( + pub fn jsx_fragment( self, span: Span, - quasis: Vec<'a, TemplateElement<'a>>, - expressions: Vec<'a, Expression<'a>>, - ) -> TSLiteral<'a> { - TSLiteral::TemplateLiteral(self.alloc_template_literal(span, quasis, expressions)) + opening_fragment: JSXOpeningFragment, + closing_fragment: JSXClosingFragment, + children: Vec<'a, JSXChild<'a>>, + ) -> JSXFragment<'a> { + JSXFragment { span, opening_fragment, closing_fragment, children } } - /// Build a [`TSLiteral::UnaryExpression`]. + /// Build a [`JSXFragment`], and store it in the memory arena. /// - /// This node contains an [`UnaryExpression`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_fragment`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `operator` - /// * `argument` + /// * `span`: Node location in source code + /// * `opening_fragment`: `<>` + /// * `closing_fragment`: `` + /// * `children`: Elements inside the fragment. #[inline] - pub fn ts_literal_unary_expression( + pub fn alloc_jsx_fragment( self, span: Span, - operator: UnaryOperator, - argument: Expression<'a>, - ) -> TSLiteral<'a> { - TSLiteral::UnaryExpression(self.alloc_unary_expression(span, operator, argument)) + opening_fragment: JSXOpeningFragment, + closing_fragment: JSXClosingFragment, + children: Vec<'a, JSXChild<'a>>, + ) -> Box<'a, JSXFragment<'a>> { + Box::new_in( + self.jsx_fragment(span, opening_fragment, closing_fragment, children), + self.allocator, + ) } - /// Build a [`TSType::TSAnyKeyword`]. + /// Build a [`JSXElementName::Identifier`]. /// - /// This node contains a [`TSAnyKeyword`] that will be stored in the memory arena. + /// This node contains a [`JSXIdentifier`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `name`: The name of the identifier. #[inline] - pub fn ts_type_any_keyword(self, span: Span) -> TSType<'a> { - TSType::TSAnyKeyword(self.alloc_ts_any_keyword(span)) + pub fn jsx_element_name_jsx_identifier(self, span: Span, name: A) -> JSXElementName<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + JSXElementName::Identifier(self.alloc_jsx_identifier(span, name)) } - /// Build a [`TSType::TSBigIntKeyword`]. + /// Build a [`JSXElementName::IdentifierReference`]. /// - /// This node contains a [`TSBigIntKeyword`] that will be stored in the memory arena. + /// This node contains an [`IdentifierReference`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `name`: The name of the identifier being referenced. #[inline] - pub fn ts_type_big_int_keyword(self, span: Span) -> TSType<'a> { - TSType::TSBigIntKeyword(self.alloc_ts_big_int_keyword(span)) + pub fn jsx_element_name_identifier_reference(self, span: Span, name: A) -> JSXElementName<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + JSXElementName::IdentifierReference(self.alloc_identifier_reference(span, name)) } - /// Build a [`TSType::TSBooleanKeyword`]. + /// Build a [`JSXElementName::NamespacedName`]. /// - /// This node contains a [`TSBooleanKeyword`] that will be stored in the memory arena. + /// This node contains a [`JSXNamespacedName`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `namespace`: Namespace portion of the name, e.g. `Apple` in `` + /// * `property`: Name portion of the name, e.g. `Orange` in `` #[inline] - pub fn ts_type_boolean_keyword(self, span: Span) -> TSType<'a> { - TSType::TSBooleanKeyword(self.alloc_ts_boolean_keyword(span)) + pub fn jsx_element_name_jsx_namespaced_name( + self, + span: Span, + namespace: JSXIdentifier<'a>, + property: JSXIdentifier<'a>, + ) -> JSXElementName<'a> { + JSXElementName::NamespacedName(self.alloc_jsx_namespaced_name(span, namespace, property)) } - /// Build a [`TSType::TSIntrinsicKeyword`]. + /// Build a [`JSXElementName::MemberExpression`]. /// - /// This node contains a [`TSIntrinsicKeyword`] that will be stored in the memory arena. + /// This node contains a [`JSXMemberExpression`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `object`: The object being accessed. This is everything before the last `.`. + /// * `property`: The property being accessed. This is everything after the last `.`. #[inline] - pub fn ts_type_intrinsic_keyword(self, span: Span) -> TSType<'a> { - TSType::TSIntrinsicKeyword(self.alloc_ts_intrinsic_keyword(span)) + pub fn jsx_element_name_jsx_member_expression( + self, + span: Span, + object: JSXMemberExpressionObject<'a>, + property: JSXIdentifier<'a>, + ) -> JSXElementName<'a> { + JSXElementName::MemberExpression(self.alloc_jsx_member_expression(span, object, property)) } - /// Build a [`TSType::TSNeverKeyword`]. + /// Build a [`JSXElementName::ThisExpression`]. /// - /// This node contains a [`TSNeverKeyword`] that will be stored in the memory arena. + /// This node contains a [`ThisExpression`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn ts_type_never_keyword(self, span: Span) -> TSType<'a> { - TSType::TSNeverKeyword(self.alloc_ts_never_keyword(span)) + pub fn jsx_element_name_this_expression(self, span: Span) -> JSXElementName<'a> { + JSXElementName::ThisExpression(self.alloc_this_expression(span)) } - /// Build a [`TSType::TSNullKeyword`]. + /// Build a [`JSXNamespacedName`]. /// - /// This node contains a [`TSNullKeyword`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_namespaced_name`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `namespace`: Namespace portion of the name, e.g. `Apple` in `` + /// * `property`: Name portion of the name, e.g. `Orange` in `` #[inline] - pub fn ts_type_null_keyword(self, span: Span) -> TSType<'a> { - TSType::TSNullKeyword(self.alloc_ts_null_keyword(span)) + pub fn jsx_namespaced_name( + self, + span: Span, + namespace: JSXIdentifier<'a>, + property: JSXIdentifier<'a>, + ) -> JSXNamespacedName<'a> { + JSXNamespacedName { span, namespace, property } } - /// Build a [`TSType::TSNumberKeyword`]. + /// Build a [`JSXNamespacedName`], and store it in the memory arena. /// - /// This node contains a [`TSNumberKeyword`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_namespaced_name`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `namespace`: Namespace portion of the name, e.g. `Apple` in `` + /// * `property`: Name portion of the name, e.g. `Orange` in `` #[inline] - pub fn ts_type_number_keyword(self, span: Span) -> TSType<'a> { - TSType::TSNumberKeyword(self.alloc_ts_number_keyword(span)) + pub fn alloc_jsx_namespaced_name( + self, + span: Span, + namespace: JSXIdentifier<'a>, + property: JSXIdentifier<'a>, + ) -> Box<'a, JSXNamespacedName<'a>> { + Box::new_in(self.jsx_namespaced_name(span, namespace, property), self.allocator) } - /// Build a [`TSType::TSObjectKeyword`]. + /// Build a [`JSXMemberExpression`]. /// - /// This node contains a [`TSObjectKeyword`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_member_expression`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `object`: The object being accessed. This is everything before the last `.`. + /// * `property`: The property being accessed. This is everything after the last `.`. #[inline] - pub fn ts_type_object_keyword(self, span: Span) -> TSType<'a> { - TSType::TSObjectKeyword(self.alloc_ts_object_keyword(span)) + pub fn jsx_member_expression( + self, + span: Span, + object: JSXMemberExpressionObject<'a>, + property: JSXIdentifier<'a>, + ) -> JSXMemberExpression<'a> { + JSXMemberExpression { span, object, property } } - /// Build a [`TSType::TSStringKeyword`]. + /// Build a [`JSXMemberExpression`], and store it in the memory arena. /// - /// This node contains a [`TSStringKeyword`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_member_expression`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `object`: The object being accessed. This is everything before the last `.`. + /// * `property`: The property being accessed. This is everything after the last `.`. #[inline] - pub fn ts_type_string_keyword(self, span: Span) -> TSType<'a> { - TSType::TSStringKeyword(self.alloc_ts_string_keyword(span)) + pub fn alloc_jsx_member_expression( + self, + span: Span, + object: JSXMemberExpressionObject<'a>, + property: JSXIdentifier<'a>, + ) -> Box<'a, JSXMemberExpression<'a>> { + Box::new_in(self.jsx_member_expression(span, object, property), self.allocator) } - /// Build a [`TSType::TSSymbolKeyword`]. + /// Build a [`JSXMemberExpressionObject::IdentifierReference`]. /// - /// This node contains a [`TSSymbolKeyword`] that will be stored in the memory arena. + /// This node contains an [`IdentifierReference`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `name`: The name of the identifier being referenced. #[inline] - pub fn ts_type_symbol_keyword(self, span: Span) -> TSType<'a> { - TSType::TSSymbolKeyword(self.alloc_ts_symbol_keyword(span)) + pub fn jsx_member_expression_object_identifier_reference( + self, + span: Span, + name: A, + ) -> JSXMemberExpressionObject<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + JSXMemberExpressionObject::IdentifierReference(self.alloc_identifier_reference(span, name)) } - /// Build a [`TSType::TSUndefinedKeyword`]. + /// Build a [`JSXMemberExpressionObject::MemberExpression`]. /// - /// This node contains a [`TSUndefinedKeyword`] that will be stored in the memory arena. + /// This node contains a [`JSXMemberExpression`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `object`: The object being accessed. This is everything before the last `.`. + /// * `property`: The property being accessed. This is everything after the last `.`. #[inline] - pub fn ts_type_undefined_keyword(self, span: Span) -> TSType<'a> { - TSType::TSUndefinedKeyword(self.alloc_ts_undefined_keyword(span)) + pub fn jsx_member_expression_object_jsx_member_expression( + self, + span: Span, + object: JSXMemberExpressionObject<'a>, + property: JSXIdentifier<'a>, + ) -> JSXMemberExpressionObject<'a> { + JSXMemberExpressionObject::MemberExpression( + self.alloc_jsx_member_expression(span, object, property), + ) } - /// Build a [`TSType::TSUnknownKeyword`]. + /// Build a [`JSXMemberExpressionObject::ThisExpression`]. /// - /// This node contains a [`TSUnknownKeyword`] that will be stored in the memory arena. + /// This node contains a [`ThisExpression`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn ts_type_unknown_keyword(self, span: Span) -> TSType<'a> { - TSType::TSUnknownKeyword(self.alloc_ts_unknown_keyword(span)) + pub fn jsx_member_expression_object_this_expression( + self, + span: Span, + ) -> JSXMemberExpressionObject<'a> { + JSXMemberExpressionObject::ThisExpression(self.alloc_this_expression(span)) } - /// Build a [`TSType::TSVoidKeyword`]. + /// Build a [`JSXExpressionContainer`]. /// - /// This node contains a [`TSVoidKeyword`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_expression_container`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `expression`: The expression inside the container. #[inline] - pub fn ts_type_void_keyword(self, span: Span) -> TSType<'a> { - TSType::TSVoidKeyword(self.alloc_ts_void_keyword(span)) + pub fn jsx_expression_container( + self, + span: Span, + expression: JSXExpression<'a>, + ) -> JSXExpressionContainer<'a> { + JSXExpressionContainer { span, expression } } - /// Build a [`TSType::TSArrayType`]. + /// Build a [`JSXExpressionContainer`], and store it in the memory arena. /// - /// This node contains a [`TSArrayType`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_expression_container`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `element_type` + /// * `span`: Node location in source code + /// * `expression`: The expression inside the container. #[inline] - pub fn ts_type_array_type(self, span: Span, element_type: TSType<'a>) -> TSType<'a> { - TSType::TSArrayType(self.alloc_ts_array_type(span, element_type)) + pub fn alloc_jsx_expression_container( + self, + span: Span, + expression: JSXExpression<'a>, + ) -> Box<'a, JSXExpressionContainer<'a>> { + Box::new_in(self.jsx_expression_container(span, expression), self.allocator) } - /// Build a [`TSType::TSConditionalType`]. + /// Build a [`JSXExpression::EmptyExpression`]. /// - /// This node contains a [`TSConditionalType`] that will be stored in the memory arena. + /// ## Parameters + /// * `span`: Node location in source code + #[inline] + pub fn jsx_expression_jsx_empty_expression(self, span: Span) -> JSXExpression<'a> { + JSXExpression::EmptyExpression(self.jsx_empty_expression(span)) + } + + /// Build a [`JSXEmptyExpression`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_empty_expression`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `check_type`: The type before `extends` in the test expression. - /// * `extends_type`: The type `check_type` is being tested against. - /// * `true_type`: The type evaluated to if the test is true. - /// * `false_type`: The type evaluated to if the test is false. + /// * `span`: Node location in source code #[inline] - pub fn ts_type_conditional_type( - self, - span: Span, - check_type: TSType<'a>, - extends_type: TSType<'a>, - true_type: TSType<'a>, - false_type: TSType<'a>, - ) -> TSType<'a> { - TSType::TSConditionalType(self.alloc_ts_conditional_type( - span, - check_type, - extends_type, - true_type, - false_type, - )) + pub fn jsx_empty_expression(self, span: Span) -> JSXEmptyExpression { + JSXEmptyExpression { span } } - /// Build a [`TSType::TSConstructorType`]. + /// Build a [`JSXEmptyExpression`], and store it in the memory arena. /// - /// This node contains a [`TSConstructorType`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_empty_expression`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `abstract` - /// * `type_parameters` - /// * `params` - /// * `return_type` + /// * `span`: Node location in source code #[inline] - pub fn ts_type_constructor_type( - self, - span: Span, - r#abstract: bool, - type_parameters: T1, - params: T2, - return_type: T3, - ) -> TSType<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, - { - TSType::TSConstructorType(self.alloc_ts_constructor_type( - span, - r#abstract, - type_parameters, - params, - return_type, - )) + pub fn alloc_jsx_empty_expression(self, span: Span) -> Box<'a, JSXEmptyExpression> { + Box::new_in(self.jsx_empty_expression(span), self.allocator) } - /// Build a [`TSType::TSFunctionType`]. + /// Build a [`JSXAttributeItem::Attribute`]. /// - /// This node contains a [`TSFunctionType`] that will be stored in the memory arena. + /// This node contains a [`JSXAttribute`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_parameters`: Generic type parameters - /// * `this_param`: `this` parameter - /// * `params`: Function parameters. Akin to [`Function::params`]. - /// * `return_type`: Return type of the function. + /// * `span`: Node location in source code + /// * `name`: The name of the attribute. This is a prop in React-like applications. + /// * `value`: The value of the attribute. This can be a string literal, an expression, #[inline] - pub fn ts_type_function_type( + pub fn jsx_attribute_item_jsx_attribute( self, span: Span, - type_parameters: T1, - this_param: T2, - params: T3, - return_type: T4, - ) -> TSType<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T4: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, - { - TSType::TSFunctionType(self.alloc_ts_function_type( - span, - type_parameters, - this_param, - params, - return_type, - )) + name: JSXAttributeName<'a>, + value: Option>, + ) -> JSXAttributeItem<'a> { + JSXAttributeItem::Attribute(self.alloc_jsx_attribute(span, name, value)) } - /// Build a [`TSType::TSImportType`]. + /// Build a [`JSXAttributeItem::SpreadAttribute`]. /// - /// This node contains a [`TSImportType`] that will be stored in the memory arena. + /// This node contains a [`JSXSpreadAttribute`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `is_type_of`: `true` for `typeof import("foo")` - /// * `parameter` - /// * `qualifier` - /// * `attributes` - /// * `type_parameters` + /// * `span`: Node location in source code + /// * `argument`: The expression being spread. #[inline] - pub fn ts_type_import_type( + pub fn jsx_attribute_item_jsx_spread_attribute( self, span: Span, - is_type_of: bool, - parameter: TSType<'a>, - qualifier: Option>, - attributes: T1, - type_parameters: T2, - ) -> TSType<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, - { - TSType::TSImportType(self.alloc_ts_import_type( - span, - is_type_of, - parameter, - qualifier, - attributes, - type_parameters, - )) + argument: Expression<'a>, + ) -> JSXAttributeItem<'a> { + JSXAttributeItem::SpreadAttribute(self.alloc_jsx_spread_attribute(span, argument)) } - /// Build a [`TSType::TSIndexedAccessType`]. + /// Build a [`JSXAttribute`]. /// - /// This node contains a [`TSIndexedAccessType`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_attribute`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `object_type` - /// * `index_type` + /// * `span`: Node location in source code + /// * `name`: The name of the attribute. This is a prop in React-like applications. + /// * `value`: The value of the attribute. This can be a string literal, an expression, #[inline] - pub fn ts_type_indexed_access_type( + pub fn jsx_attribute( self, span: Span, - object_type: TSType<'a>, - index_type: TSType<'a>, - ) -> TSType<'a> { - TSType::TSIndexedAccessType(self.alloc_ts_indexed_access_type( - span, - object_type, - index_type, - )) + name: JSXAttributeName<'a>, + value: Option>, + ) -> JSXAttribute<'a> { + JSXAttribute { span, name, value } } - /// Build a [`TSType::TSInferType`]. + /// Build a [`JSXAttribute`], and store it in the memory arena. /// - /// This node contains a [`TSInferType`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_attribute`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_parameter`: The type bound when the + /// * `span`: Node location in source code + /// * `name`: The name of the attribute. This is a prop in React-like applications. + /// * `value`: The value of the attribute. This can be a string literal, an expression, #[inline] - pub fn ts_type_infer_type(self, span: Span, type_parameter: T1) -> TSType<'a> - where - T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, - { - TSType::TSInferType(self.alloc_ts_infer_type(span, type_parameter)) + pub fn alloc_jsx_attribute( + self, + span: Span, + name: JSXAttributeName<'a>, + value: Option>, + ) -> Box<'a, JSXAttribute<'a>> { + Box::new_in(self.jsx_attribute(span, name, value), self.allocator) } - /// Build a [`TSType::TSIntersectionType`]. + /// Build a [`JSXSpreadAttribute`]. /// - /// This node contains a [`TSIntersectionType`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_spread_attribute`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `types` + /// * `span`: Node location in source code + /// * `argument`: The expression being spread. #[inline] - pub fn ts_type_intersection_type(self, span: Span, types: Vec<'a, TSType<'a>>) -> TSType<'a> { - TSType::TSIntersectionType(self.alloc_ts_intersection_type(span, types)) + pub fn jsx_spread_attribute( + self, + span: Span, + argument: Expression<'a>, + ) -> JSXSpreadAttribute<'a> { + JSXSpreadAttribute { span, argument } } - /// Build a [`TSType::TSLiteralType`]. + /// Build a [`JSXSpreadAttribute`], and store it in the memory arena. /// - /// This node contains a [`TSLiteralType`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_spread_attribute`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `literal` + /// * `span`: Node location in source code + /// * `argument`: The expression being spread. #[inline] - pub fn ts_type_literal_type(self, span: Span, literal: TSLiteral<'a>) -> TSType<'a> { - TSType::TSLiteralType(self.alloc_ts_literal_type(span, literal)) + pub fn alloc_jsx_spread_attribute( + self, + span: Span, + argument: Expression<'a>, + ) -> Box<'a, JSXSpreadAttribute<'a>> { + Box::new_in(self.jsx_spread_attribute(span, argument), self.allocator) } - /// Build a [`TSType::TSMappedType`]. + /// Build a [`JSXAttributeName::Identifier`]. /// - /// This node contains a [`TSMappedType`] that will be stored in the memory arena. + /// This node contains a [`JSXIdentifier`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. - /// * `name_type` - /// * `type_annotation` - /// * `optional`: Optional modifier on type annotation - /// * `readonly`: Readonly modifier before keyed index signature + /// * `span`: Node location in source code + /// * `name`: The name of the identifier. #[inline] - pub fn ts_type_mapped_type( - self, - span: Span, - type_parameter: T1, - name_type: Option>, - type_annotation: Option>, - optional: TSMappedTypeModifierOperator, - readonly: TSMappedTypeModifierOperator, - ) -> TSType<'a> + pub fn jsx_attribute_name_jsx_identifier(self, span: Span, name: A) -> JSXAttributeName<'a> where - T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + A: IntoIn<'a, Atom<'a>>, { - TSType::TSMappedType(self.alloc_ts_mapped_type( - span, - type_parameter, - name_type, - type_annotation, - optional, - readonly, - )) + JSXAttributeName::Identifier(self.alloc_jsx_identifier(span, name)) } - /// Build a [`TSType::TSNamedTupleMember`]. + /// Build a [`JSXAttributeName::NamespacedName`]. /// - /// This node contains a [`TSNamedTupleMember`] that will be stored in the memory arena. + /// This node contains a [`JSXNamespacedName`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `element_type` - /// * `label` - /// * `optional` + /// * `span`: Node location in source code + /// * `namespace`: Namespace portion of the name, e.g. `Apple` in `` + /// * `property`: Name portion of the name, e.g. `Orange` in `` #[inline] - pub fn ts_type_named_tuple_member( + pub fn jsx_attribute_name_jsx_namespaced_name( self, span: Span, - element_type: TSTupleElement<'a>, - label: IdentifierName<'a>, - optional: bool, - ) -> TSType<'a> { - TSType::TSNamedTupleMember(self.alloc_ts_named_tuple_member( - span, - element_type, - label, - optional, - )) + namespace: JSXIdentifier<'a>, + property: JSXIdentifier<'a>, + ) -> JSXAttributeName<'a> { + JSXAttributeName::NamespacedName(self.alloc_jsx_namespaced_name(span, namespace, property)) } - /// Build a [`TSType::TSQualifiedName`]. + /// Build a [`JSXAttributeValue::StringLiteral`]. /// - /// This node contains a [`TSQualifiedName`] that will be stored in the memory arena. + /// This node contains a [`StringLiteral`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `left` - /// * `right` + /// * `span`: Node location in source code + /// * `value`: The value of the string. + /// * `raw`: The raw string as it appears in source code. #[inline] - pub fn ts_type_qualified_name( + pub fn jsx_attribute_value_string_literal( self, span: Span, - left: TSTypeName<'a>, - right: IdentifierName<'a>, - ) -> TSType<'a> { - TSType::TSQualifiedName(self.alloc_ts_qualified_name(span, left, right)) + value: A, + raw: Option>, + ) -> JSXAttributeValue<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + JSXAttributeValue::StringLiteral(self.alloc_string_literal(span, value, raw)) } - /// Build a [`TSType::TSTemplateLiteralType`]. + /// Build a [`JSXAttributeValue::ExpressionContainer`]. /// - /// This node contains a [`TSTemplateLiteralType`] that will be stored in the memory arena. + /// This node contains a [`JSXExpressionContainer`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `quasis`: The string parts of the template literal. - /// * `types`: The interpolated expressions in the template literal. + /// * `span`: Node location in source code + /// * `expression`: The expression inside the container. #[inline] - pub fn ts_type_template_literal_type( + pub fn jsx_attribute_value_jsx_expression_container( self, span: Span, - quasis: Vec<'a, TemplateElement<'a>>, - types: Vec<'a, TSType<'a>>, - ) -> TSType<'a> { - TSType::TSTemplateLiteralType(self.alloc_ts_template_literal_type(span, quasis, types)) + expression: JSXExpression<'a>, + ) -> JSXAttributeValue<'a> { + JSXAttributeValue::ExpressionContainer( + self.alloc_jsx_expression_container(span, expression), + ) } - /// Build a [`TSType::TSThisType`]. + /// Build a [`JSXAttributeValue::Element`]. /// - /// This node contains a [`TSThisType`] that will be stored in the memory arena. + /// This node contains a [`JSXElement`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `opening_element`: Opening tag of the element. + /// * `closing_element`: Closing tag of the element. Will be [`None`] for self-closing tags. + /// * `children`: Children of the element. This can be text, other elements, or expressions. #[inline] - pub fn ts_type_this_type(self, span: Span) -> TSType<'a> { - TSType::TSThisType(self.alloc_ts_this_type(span)) + pub fn jsx_attribute_value_jsx_element( + self, + span: Span, + opening_element: T1, + closing_element: T2, + children: Vec<'a, JSXChild<'a>>, + ) -> JSXAttributeValue<'a> + where + T1: IntoIn<'a, Box<'a, JSXOpeningElement<'a>>>, + T2: IntoIn<'a, Option>>>, + { + JSXAttributeValue::Element(self.alloc_jsx_element( + span, + opening_element, + closing_element, + children, + )) } - /// Build a [`TSType::TSTupleType`]. + /// Build a [`JSXAttributeValue::Fragment`]. /// - /// This node contains a [`TSTupleType`] that will be stored in the memory arena. + /// This node contains a [`JSXFragment`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `element_types` + /// * `span`: Node location in source code + /// * `opening_fragment`: `<>` + /// * `closing_fragment`: `` + /// * `children`: Elements inside the fragment. #[inline] - pub fn ts_type_tuple_type( + pub fn jsx_attribute_value_jsx_fragment( self, span: Span, - element_types: Vec<'a, TSTupleElement<'a>>, - ) -> TSType<'a> { - TSType::TSTupleType(self.alloc_ts_tuple_type(span, element_types)) + opening_fragment: JSXOpeningFragment, + closing_fragment: JSXClosingFragment, + children: Vec<'a, JSXChild<'a>>, + ) -> JSXAttributeValue<'a> { + JSXAttributeValue::Fragment(self.alloc_jsx_fragment( + span, + opening_fragment, + closing_fragment, + children, + )) } - /// Build a [`TSType::TSTypeLiteral`]. + /// Build a [`JSXIdentifier`]. /// - /// This node contains a [`TSTypeLiteral`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_identifier`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `members` + /// * `span`: Node location in source code + /// * `name`: The name of the identifier. #[inline] - pub fn ts_type_type_literal(self, span: Span, members: Vec<'a, TSSignature<'a>>) -> TSType<'a> { - TSType::TSTypeLiteral(self.alloc_ts_type_literal(span, members)) - } - - /// Build a [`TSType::TSTypeOperatorType`]. - /// - /// This node contains a [`TSTypeOperator`] that will be stored in the memory arena. + pub fn jsx_identifier(self, span: Span, name: A) -> JSXIdentifier<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + JSXIdentifier { span, name: name.into_in(self.allocator) } + } + + /// Build a [`JSXIdentifier`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_identifier`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `operator` - /// * `type_annotation`: The type being operated on + /// * `span`: Node location in source code + /// * `name`: The name of the identifier. #[inline] - pub fn ts_type_type_operator( - self, - span: Span, - operator: TSTypeOperatorOperator, - type_annotation: TSType<'a>, - ) -> TSType<'a> { - TSType::TSTypeOperatorType(self.alloc_ts_type_operator(span, operator, type_annotation)) + pub fn alloc_jsx_identifier(self, span: Span, name: A) -> Box<'a, JSXIdentifier<'a>> + where + A: IntoIn<'a, Atom<'a>>, + { + Box::new_in(self.jsx_identifier(span, name), self.allocator) } - /// Build a [`TSType::TSTypePredicate`]. + /// Build a [`JSXChild::Text`]. /// - /// This node contains a [`TSTypePredicate`] that will be stored in the memory arena. + /// This node contains a [`JSXText`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `parameter_name`: The identifier the predicate operates on - /// * `asserts`: Does this predicate include an `asserts` modifier? - /// * `type_annotation` + /// * `span`: Node location in source code + /// * `value`: The text content. #[inline] - pub fn ts_type_type_predicate( - self, - span: Span, - parameter_name: TSTypePredicateName<'a>, - asserts: bool, - type_annotation: T1, - ) -> TSType<'a> + pub fn jsx_child_jsx_text(self, span: Span, value: A) -> JSXChild<'a> where - T1: IntoIn<'a, Option>>>, + A: IntoIn<'a, Atom<'a>>, { - TSType::TSTypePredicate(self.alloc_ts_type_predicate( - span, - parameter_name, - asserts, - type_annotation, - )) + JSXChild::Text(self.alloc_jsx_text(span, value)) } - /// Build a [`TSType::TSTypeQuery`]. + /// Build a [`JSXChild::Element`]. /// - /// This node contains a [`TSTypeQuery`] that will be stored in the memory arena. + /// This node contains a [`JSXElement`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `expr_name` - /// * `type_parameters` + /// * `span`: Node location in source code + /// * `opening_element`: Opening tag of the element. + /// * `closing_element`: Closing tag of the element. Will be [`None`] for self-closing tags. + /// * `children`: Children of the element. This can be text, other elements, or expressions. #[inline] - pub fn ts_type_type_query( + pub fn jsx_child_jsx_element( self, span: Span, - expr_name: TSTypeQueryExprName<'a>, - type_parameters: T1, - ) -> TSType<'a> + opening_element: T1, + closing_element: T2, + children: Vec<'a, JSXChild<'a>>, + ) -> JSXChild<'a> where - T1: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Box<'a, JSXOpeningElement<'a>>>, + T2: IntoIn<'a, Option>>>, { - TSType::TSTypeQuery(self.alloc_ts_type_query(span, expr_name, type_parameters)) + JSXChild::Element(self.alloc_jsx_element(span, opening_element, closing_element, children)) } - /// Build a [`TSType::TSTypeReference`]. + /// Build a [`JSXChild::Fragment`]. /// - /// This node contains a [`TSTypeReference`] that will be stored in the memory arena. + /// This node contains a [`JSXFragment`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_name` - /// * `type_parameters` + /// * `span`: Node location in source code + /// * `opening_fragment`: `<>` + /// * `closing_fragment`: `` + /// * `children`: Elements inside the fragment. #[inline] - pub fn ts_type_type_reference( + pub fn jsx_child_jsx_fragment( self, span: Span, - type_name: TSTypeName<'a>, - type_parameters: T1, - ) -> TSType<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSType::TSTypeReference(self.alloc_ts_type_reference(span, type_name, type_parameters)) + opening_fragment: JSXOpeningFragment, + closing_fragment: JSXClosingFragment, + children: Vec<'a, JSXChild<'a>>, + ) -> JSXChild<'a> { + JSXChild::Fragment(self.alloc_jsx_fragment( + span, + opening_fragment, + closing_fragment, + children, + )) } - /// Build a [`TSType::TSUnionType`]. + /// Build a [`JSXChild::ExpressionContainer`]. /// - /// This node contains a [`TSUnionType`] that will be stored in the memory arena. + /// This node contains a [`JSXExpressionContainer`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `types`: The types in the union. + /// * `span`: Node location in source code + /// * `expression`: The expression inside the container. #[inline] - pub fn ts_type_union_type(self, span: Span, types: Vec<'a, TSType<'a>>) -> TSType<'a> { - TSType::TSUnionType(self.alloc_ts_union_type(span, types)) + pub fn jsx_child_jsx_expression_container( + self, + span: Span, + expression: JSXExpression<'a>, + ) -> JSXChild<'a> { + JSXChild::ExpressionContainer(self.alloc_jsx_expression_container(span, expression)) } - /// Build a [`TSType::TSParenthesizedType`]. + /// Build a [`JSXChild::Spread`]. /// - /// This node contains a [`TSParenthesizedType`] that will be stored in the memory arena. + /// This node contains a [`JSXSpreadChild`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_annotation` + /// * `span`: Node location in source code + /// * `expression`: The expression being spread. #[inline] - pub fn ts_type_parenthesized_type(self, span: Span, type_annotation: TSType<'a>) -> TSType<'a> { - TSType::TSParenthesizedType(self.alloc_ts_parenthesized_type(span, type_annotation)) + pub fn jsx_child_jsx_spread_child( + self, + span: Span, + expression: Expression<'a>, + ) -> JSXChild<'a> { + JSXChild::Spread(self.alloc_jsx_spread_child(span, expression)) } - /// Build a [`TSType::JSDocNullableType`]. + /// Build a [`JSXSpreadChild`]. /// - /// This node contains a [`JSDocNullableType`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_spread_child`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_annotation` - /// * `postfix`: Was `?` after the type annotation? + /// * `span`: Node location in source code + /// * `expression`: The expression being spread. #[inline] - pub fn ts_type_js_doc_nullable_type( - self, - span: Span, - type_annotation: TSType<'a>, - postfix: bool, - ) -> TSType<'a> { - TSType::JSDocNullableType(self.alloc_js_doc_nullable_type(span, type_annotation, postfix)) + pub fn jsx_spread_child(self, span: Span, expression: Expression<'a>) -> JSXSpreadChild<'a> { + JSXSpreadChild { span, expression } } - /// Build a [`TSType::JSDocNonNullableType`]. + /// Build a [`JSXSpreadChild`], and store it in the memory arena. /// - /// This node contains a [`JSDocNonNullableType`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_spread_child`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_annotation` - /// * `postfix` + /// * `span`: Node location in source code + /// * `expression`: The expression being spread. #[inline] - pub fn ts_type_js_doc_non_nullable_type( + pub fn alloc_jsx_spread_child( self, span: Span, - type_annotation: TSType<'a>, - postfix: bool, - ) -> TSType<'a> { - TSType::JSDocNonNullableType(self.alloc_js_doc_non_nullable_type( - span, - type_annotation, - postfix, - )) + expression: Expression<'a>, + ) -> Box<'a, JSXSpreadChild<'a>> { + Box::new_in(self.jsx_spread_child(span, expression), self.allocator) } - /// Build a [`TSType::JSDocUnknownType`]. + /// Build a [`JSXText`]. /// - /// This node contains a [`JSDocUnknownType`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_text`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node + /// * `span`: Node location in source code + /// * `value`: The text content. #[inline] - pub fn ts_type_js_doc_unknown_type(self, span: Span) -> TSType<'a> { - TSType::JSDocUnknownType(self.alloc_js_doc_unknown_type(span)) + pub fn jsx_text(self, span: Span, value: A) -> JSXText<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + JSXText { span, value: value.into_in(self.allocator) } } - /// Build a [`TSConditionalType`]. + /// Build a [`JSXText`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_conditional_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_text`] instead. + /// + /// ## Parameters + /// * `span`: Node location in source code + /// * `value`: The text content. + #[inline] + pub fn alloc_jsx_text(self, span: Span, value: A) -> Box<'a, JSXText<'a>> + where + A: IntoIn<'a, Atom<'a>>, + { + Box::new_in(self.jsx_text(span, value), self.allocator) + } + + /// Build a [`TSThisParameter`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_this_parameter`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `check_type`: The type before `extends` in the test expression. - /// * `extends_type`: The type `check_type` is being tested against. - /// * `true_type`: The type evaluated to if the test is true. - /// * `false_type`: The type evaluated to if the test is false. + /// * `this_span` + /// * `type_annotation`: Type type the `this` keyword will have in the function #[inline] - pub fn ts_conditional_type( + pub fn ts_this_parameter( self, span: Span, - check_type: TSType<'a>, - extends_type: TSType<'a>, - true_type: TSType<'a>, - false_type: TSType<'a>, - ) -> TSConditionalType<'a> { - TSConditionalType { + this_span: Span, + type_annotation: T1, + ) -> TSThisParameter<'a> + where + T1: IntoIn<'a, Option>>>, + { + TSThisParameter { span, - check_type, - extends_type, - true_type, - false_type, - scope_id: Default::default(), + this_span, + type_annotation: type_annotation.into_in(self.allocator), } } - /// Build a [`TSConditionalType`], and store it in the memory arena. + /// Build a [`TSThisParameter`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_conditional_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_this_parameter`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `check_type`: The type before `extends` in the test expression. - /// * `extends_type`: The type `check_type` is being tested against. - /// * `true_type`: The type evaluated to if the test is true. - /// * `false_type`: The type evaluated to if the test is false. + /// * `this_span` + /// * `type_annotation`: Type type the `this` keyword will have in the function #[inline] - pub fn alloc_ts_conditional_type( + pub fn alloc_ts_this_parameter( self, span: Span, - check_type: TSType<'a>, - extends_type: TSType<'a>, - true_type: TSType<'a>, - false_type: TSType<'a>, - ) -> Box<'a, TSConditionalType<'a>> { - Box::new_in( - self.ts_conditional_type(span, check_type, extends_type, true_type, false_type), - self.allocator, - ) + this_span: Span, + type_annotation: T1, + ) -> Box<'a, TSThisParameter<'a>> + where + T1: IntoIn<'a, Option>>>, + { + Box::new_in(self.ts_this_parameter(span, this_span, type_annotation), self.allocator) } - /// Build a [`TSConditionalType`] with `ScopeId`. + /// Build a [`TSEnumDeclaration`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_conditional_type_with_scope_id`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_enum_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `check_type`: The type before `extends` in the test expression. - /// * `extends_type`: The type `check_type` is being tested against. - /// * `true_type`: The type evaluated to if the test is true. - /// * `false_type`: The type evaluated to if the test is false. - /// * `scope_id` + /// * `id` + /// * `members` + /// * `const`: `true` for const enums + /// * `declare` #[inline] - pub fn ts_conditional_type_with_scope_id( + pub fn ts_enum_declaration( self, span: Span, - check_type: TSType<'a>, - extends_type: TSType<'a>, - true_type: TSType<'a>, - false_type: TSType<'a>, - scope_id: ScopeId, - ) -> TSConditionalType<'a> { - TSConditionalType { - span, - check_type, - extends_type, - true_type, - false_type, - scope_id: Cell::new(Some(scope_id)), - } + id: BindingIdentifier<'a>, + members: Vec<'a, TSEnumMember<'a>>, + r#const: bool, + declare: bool, + ) -> TSEnumDeclaration<'a> { + TSEnumDeclaration { span, id, members, r#const, declare, scope_id: Default::default() } } - /// Build a [`TSConditionalType`] with `ScopeId`, and store it in the memory arena. + /// Build a [`TSEnumDeclaration`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_conditional_type_with_scope_id`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_enum_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `check_type`: The type before `extends` in the test expression. - /// * `extends_type`: The type `check_type` is being tested against. - /// * `true_type`: The type evaluated to if the test is true. - /// * `false_type`: The type evaluated to if the test is false. - /// * `scope_id` + /// * `id` + /// * `members` + /// * `const`: `true` for const enums + /// * `declare` #[inline] - pub fn alloc_ts_conditional_type_with_scope_id( + pub fn alloc_ts_enum_declaration( self, span: Span, - check_type: TSType<'a>, - extends_type: TSType<'a>, - true_type: TSType<'a>, - false_type: TSType<'a>, - scope_id: ScopeId, - ) -> Box<'a, TSConditionalType<'a>> { - Box::new_in( - self.ts_conditional_type_with_scope_id( - span, - check_type, - extends_type, - true_type, - false_type, - scope_id, - ), - self.allocator, - ) + id: BindingIdentifier<'a>, + members: Vec<'a, TSEnumMember<'a>>, + r#const: bool, + declare: bool, + ) -> Box<'a, TSEnumDeclaration<'a>> { + Box::new_in(self.ts_enum_declaration(span, id, members, r#const, declare), self.allocator) } - /// Build a [`TSUnionType`]. + /// Build a [`TSEnumDeclaration`] with `ScopeId`. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_union_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_enum_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `types`: The types in the union. + /// * `id` + /// * `members` + /// * `const`: `true` for const enums + /// * `declare` + /// * `scope_id` #[inline] - pub fn ts_union_type(self, span: Span, types: Vec<'a, TSType<'a>>) -> TSUnionType<'a> { - TSUnionType { span, types } + pub fn ts_enum_declaration_with_scope_id( + self, + span: Span, + id: BindingIdentifier<'a>, + members: Vec<'a, TSEnumMember<'a>>, + r#const: bool, + declare: bool, + scope_id: ScopeId, + ) -> TSEnumDeclaration<'a> { + TSEnumDeclaration { + span, + id, + members, + r#const, + declare, + scope_id: Cell::new(Some(scope_id)), + } } - /// Build a [`TSUnionType`], and store it in the memory arena. + /// Build a [`TSEnumDeclaration`] with `ScopeId`, and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_union_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_enum_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `types`: The types in the union. + /// * `id` + /// * `members` + /// * `const`: `true` for const enums + /// * `declare` + /// * `scope_id` #[inline] - pub fn alloc_ts_union_type( + pub fn alloc_ts_enum_declaration_with_scope_id( self, span: Span, - types: Vec<'a, TSType<'a>>, - ) -> Box<'a, TSUnionType<'a>> { - Box::new_in(self.ts_union_type(span, types), self.allocator) + id: BindingIdentifier<'a>, + members: Vec<'a, TSEnumMember<'a>>, + r#const: bool, + declare: bool, + scope_id: ScopeId, + ) -> Box<'a, TSEnumDeclaration<'a>> { + Box::new_in( + self.ts_enum_declaration_with_scope_id(span, id, members, r#const, declare, scope_id), + self.allocator, + ) } - /// Build a [`TSIntersectionType`]. + /// Build a [`TSEnumMember`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_intersection_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_enum_member`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `types` + /// * `id` + /// * `initializer` #[inline] - pub fn ts_intersection_type( + pub fn ts_enum_member( self, span: Span, - types: Vec<'a, TSType<'a>>, - ) -> TSIntersectionType<'a> { - TSIntersectionType { span, types } + id: TSEnumMemberName<'a>, + initializer: Option>, + ) -> TSEnumMember<'a> { + TSEnumMember { span, id, initializer } } - /// Build a [`TSIntersectionType`], and store it in the memory arena. + /// Build a [`TSEnumMember`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_intersection_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_enum_member`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `types` + /// * `id` + /// * `initializer` #[inline] - pub fn alloc_ts_intersection_type( + pub fn alloc_ts_enum_member( self, span: Span, - types: Vec<'a, TSType<'a>>, - ) -> Box<'a, TSIntersectionType<'a>> { - Box::new_in(self.ts_intersection_type(span, types), self.allocator) + id: TSEnumMemberName<'a>, + initializer: Option>, + ) -> Box<'a, TSEnumMember<'a>> { + Box::new_in(self.ts_enum_member(span, id, initializer), self.allocator) } - /// Build a [`TSParenthesizedType`]. + /// Build a [`TSEnumMemberName::Identifier`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_parenthesized_type`] instead. + /// This node contains an [`IdentifierName`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` + /// * `name` #[inline] - pub fn ts_parenthesized_type( - self, - span: Span, - type_annotation: TSType<'a>, - ) -> TSParenthesizedType<'a> { - TSParenthesizedType { span, type_annotation } + pub fn ts_enum_member_name_identifier_name(self, span: Span, name: A) -> TSEnumMemberName<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + TSEnumMemberName::Identifier(self.alloc_identifier_name(span, name)) } - /// Build a [`TSParenthesizedType`], and store it in the memory arena. + /// Build a [`TSEnumMemberName::String`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_parenthesized_type`] instead. + /// This node contains a [`StringLiteral`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_annotation` + /// * `span`: Node location in source code + /// * `value`: The value of the string. + /// * `raw`: The raw string as it appears in source code. #[inline] - pub fn alloc_ts_parenthesized_type( + pub fn ts_enum_member_name_string_literal( self, span: Span, - type_annotation: TSType<'a>, - ) -> Box<'a, TSParenthesizedType<'a>> { - Box::new_in(self.ts_parenthesized_type(span, type_annotation), self.allocator) + value: A, + raw: Option>, + ) -> TSEnumMemberName<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + TSEnumMemberName::String(self.alloc_string_literal(span, value, raw)) } - /// Build a [`TSTypeOperator`]. + /// Build a [`TSTypeAnnotation`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_operator`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_annotation`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `operator` - /// * `type_annotation`: The type being operated on + /// * `span`: starts at the `:` token and ends at the end of the type annotation + /// * `type_annotation`: The actual type in the annotation #[inline] - pub fn ts_type_operator( + pub fn ts_type_annotation( self, span: Span, - operator: TSTypeOperatorOperator, type_annotation: TSType<'a>, - ) -> TSTypeOperator<'a> { - TSTypeOperator { span, operator, type_annotation } + ) -> TSTypeAnnotation<'a> { + TSTypeAnnotation { span, type_annotation } } - /// Build a [`TSTypeOperator`], and store it in the memory arena. + /// Build a [`TSTypeAnnotation`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_operator`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_annotation`] instead. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `operator` - /// * `type_annotation`: The type being operated on + /// * `span`: starts at the `:` token and ends at the end of the type annotation + /// * `type_annotation`: The actual type in the annotation #[inline] - pub fn alloc_ts_type_operator( + pub fn alloc_ts_type_annotation( self, span: Span, - operator: TSTypeOperatorOperator, type_annotation: TSType<'a>, - ) -> Box<'a, TSTypeOperator<'a>> { - Box::new_in(self.ts_type_operator(span, operator, type_annotation), self.allocator) + ) -> Box<'a, TSTypeAnnotation<'a>> { + Box::new_in(self.ts_type_annotation(span, type_annotation), self.allocator) } - /// Build a [`TSArrayType`]. + /// Build a [`TSLiteralType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_array_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_literal_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `element_type` + /// * `literal` #[inline] - pub fn ts_array_type(self, span: Span, element_type: TSType<'a>) -> TSArrayType<'a> { - TSArrayType { span, element_type } + pub fn ts_literal_type(self, span: Span, literal: TSLiteral<'a>) -> TSLiteralType<'a> { + TSLiteralType { span, literal } } - /// Build a [`TSArrayType`], and store it in the memory arena. + /// Build a [`TSLiteralType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_array_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_literal_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `element_type` + /// * `literal` #[inline] - pub fn alloc_ts_array_type( + pub fn alloc_ts_literal_type( self, span: Span, - element_type: TSType<'a>, - ) -> Box<'a, TSArrayType<'a>> { - Box::new_in(self.ts_array_type(span, element_type), self.allocator) + literal: TSLiteral<'a>, + ) -> Box<'a, TSLiteralType<'a>> { + Box::new_in(self.ts_literal_type(span, literal), self.allocator) } - /// Build a [`TSIndexedAccessType`]. + /// Build a [`TSLiteral::BooleanLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_indexed_access_type`] instead. + /// This node contains a [`BooleanLiteral`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `object_type` - /// * `index_type` + /// * `span`: Node location in source code + /// * `value`: The boolean value itself #[inline] - pub fn ts_indexed_access_type( - self, - span: Span, - object_type: TSType<'a>, - index_type: TSType<'a>, - ) -> TSIndexedAccessType<'a> { - TSIndexedAccessType { span, object_type, index_type } + pub fn ts_literal_boolean_literal(self, span: Span, value: bool) -> TSLiteral<'a> { + TSLiteral::BooleanLiteral(self.alloc_boolean_literal(span, value)) } - /// Build a [`TSIndexedAccessType`], and store it in the memory arena. + /// Build a [`TSLiteral::NullLiteral`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_indexed_access_type`] instead. + /// This node contains a [`NullLiteral`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `object_type` - /// * `index_type` + /// * `span`: Node location in source code #[inline] - pub fn alloc_ts_indexed_access_type( - self, - span: Span, - object_type: TSType<'a>, - index_type: TSType<'a>, - ) -> Box<'a, TSIndexedAccessType<'a>> { - Box::new_in(self.ts_indexed_access_type(span, object_type, index_type), self.allocator) + pub fn ts_literal_null_literal(self, span: Span) -> TSLiteral<'a> { + TSLiteral::NullLiteral(self.alloc_null_literal(span)) } - /// Build a [`TSTupleType`]. + /// Build a [`TSLiteral::NumericLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_tuple_type`] instead. + /// This node contains a [`NumericLiteral`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `element_types` + /// * `span`: Node location in source code + /// * `value`: The value of the number, converted into base 10 + /// * `raw`: The number as it appears in source code + /// * `base`: The base representation used by the literal in source code #[inline] - pub fn ts_tuple_type( + pub fn ts_literal_numeric_literal( self, span: Span, - element_types: Vec<'a, TSTupleElement<'a>>, - ) -> TSTupleType<'a> { - TSTupleType { span, element_types } + value: f64, + raw: Option>, + base: NumberBase, + ) -> TSLiteral<'a> { + TSLiteral::NumericLiteral(self.alloc_numeric_literal(span, value, raw, base)) } - /// Build a [`TSTupleType`], and store it in the memory arena. + /// Build a [`TSLiteral::BigIntLiteral`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_tuple_type`] instead. + /// This node contains a [`BigIntLiteral`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `element_types` + /// * `span`: Node location in source code + /// * `raw`: The bigint as it appears in source code + /// * `base`: The base representation used by the literal in source code #[inline] - pub fn alloc_ts_tuple_type( + pub fn ts_literal_big_int_literal( self, span: Span, - element_types: Vec<'a, TSTupleElement<'a>>, - ) -> Box<'a, TSTupleType<'a>> { - Box::new_in(self.ts_tuple_type(span, element_types), self.allocator) + raw: A, + base: BigintBase, + ) -> TSLiteral<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + TSLiteral::BigIntLiteral(self.alloc_big_int_literal(span, raw, base)) } - /// Build a [`TSNamedTupleMember`]. + /// Build a [`TSLiteral::RegExpLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_named_tuple_member`] instead. + /// This node contains a [`RegExpLiteral`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `element_type` - /// * `label` - /// * `optional` + /// * `span`: Node location in source code + /// * `regex`: The parsed regular expression. See [`oxc_regular_expression`] for more + /// * `raw`: The regular expression as it appears in source code #[inline] - pub fn ts_named_tuple_member( + pub fn ts_literal_reg_exp_literal( self, span: Span, - element_type: TSTupleElement<'a>, - label: IdentifierName<'a>, - optional: bool, - ) -> TSNamedTupleMember<'a> { - TSNamedTupleMember { span, element_type, label, optional } + regex: RegExp<'a>, + raw: Option>, + ) -> TSLiteral<'a> { + TSLiteral::RegExpLiteral(self.alloc_reg_exp_literal(span, regex, raw)) } - /// Build a [`TSNamedTupleMember`], and store it in the memory arena. + /// Build a [`TSLiteral::StringLiteral`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_named_tuple_member`] instead. + /// This node contains a [`StringLiteral`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `element_type` - /// * `label` - /// * `optional` + /// * `span`: Node location in source code + /// * `value`: The value of the string. + /// * `raw`: The raw string as it appears in source code. #[inline] - pub fn alloc_ts_named_tuple_member( + pub fn ts_literal_string_literal( self, span: Span, - element_type: TSTupleElement<'a>, - label: IdentifierName<'a>, - optional: bool, - ) -> Box<'a, TSNamedTupleMember<'a>> { - Box::new_in(self.ts_named_tuple_member(span, element_type, label, optional), self.allocator) + value: A, + raw: Option>, + ) -> TSLiteral<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + TSLiteral::StringLiteral(self.alloc_string_literal(span, value, raw)) } - /// Build a [`TSOptionalType`]. + /// Build a [`TSLiteral::TemplateLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_optional_type`] instead. + /// This node contains a [`TemplateLiteral`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` + /// * `quasis` + /// * `expressions` #[inline] - pub fn ts_optional_type(self, span: Span, type_annotation: TSType<'a>) -> TSOptionalType<'a> { - TSOptionalType { span, type_annotation } + pub fn ts_literal_template_literal( + self, + span: Span, + quasis: Vec<'a, TemplateElement<'a>>, + expressions: Vec<'a, Expression<'a>>, + ) -> TSLiteral<'a> { + TSLiteral::TemplateLiteral(self.alloc_template_literal(span, quasis, expressions)) } - /// Build a [`TSOptionalType`], and store it in the memory arena. + /// Build a [`TSLiteral::UnaryExpression`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_optional_type`] instead. + /// This node contains an [`UnaryExpression`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` + /// * `operator` + /// * `argument` #[inline] - pub fn alloc_ts_optional_type( + pub fn ts_literal_unary_expression( self, span: Span, - type_annotation: TSType<'a>, - ) -> Box<'a, TSOptionalType<'a>> { - Box::new_in(self.ts_optional_type(span, type_annotation), self.allocator) + operator: UnaryOperator, + argument: Expression<'a>, + ) -> TSLiteral<'a> { + TSLiteral::UnaryExpression(self.alloc_unary_expression(span, operator, argument)) } - /// Build a [`TSRestType`]. + /// Build a [`TSType::TSAnyKeyword`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_rest_type`] instead. + /// This node contains a [`TSAnyKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` #[inline] - pub fn ts_rest_type(self, span: Span, type_annotation: TSType<'a>) -> TSRestType<'a> { - TSRestType { span, type_annotation } + pub fn ts_type_any_keyword(self, span: Span) -> TSType<'a> { + TSType::TSAnyKeyword(self.alloc_ts_any_keyword(span)) } - /// Build a [`TSRestType`], and store it in the memory arena. + /// Build a [`TSType::TSBigIntKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_rest_type`] instead. + /// This node contains a [`TSBigIntKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` #[inline] - pub fn alloc_ts_rest_type( - self, - span: Span, - type_annotation: TSType<'a>, - ) -> Box<'a, TSRestType<'a>> { - Box::new_in(self.ts_rest_type(span, type_annotation), self.allocator) + pub fn ts_type_big_int_keyword(self, span: Span) -> TSType<'a> { + TSType::TSBigIntKeyword(self.alloc_ts_big_int_keyword(span)) } - /// Build a [`TSTupleElement::TSOptionalType`]. + /// Build a [`TSType::TSBooleanKeyword`]. /// - /// This node contains a [`TSOptionalType`] that will be stored in the memory arena. + /// This node contains a [`TSBooleanKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` #[inline] - pub fn ts_tuple_element_optional_type( - self, - span: Span, - type_annotation: TSType<'a>, - ) -> TSTupleElement<'a> { - TSTupleElement::TSOptionalType(self.alloc_ts_optional_type(span, type_annotation)) + pub fn ts_type_boolean_keyword(self, span: Span) -> TSType<'a> { + TSType::TSBooleanKeyword(self.alloc_ts_boolean_keyword(span)) } - /// Build a [`TSTupleElement::TSRestType`]. + /// Build a [`TSType::TSIntrinsicKeyword`]. /// - /// This node contains a [`TSRestType`] that will be stored in the memory arena. + /// This node contains a [`TSIntrinsicKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` #[inline] - pub fn ts_tuple_element_rest_type( - self, - span: Span, - type_annotation: TSType<'a>, - ) -> TSTupleElement<'a> { - TSTupleElement::TSRestType(self.alloc_ts_rest_type(span, type_annotation)) + pub fn ts_type_intrinsic_keyword(self, span: Span) -> TSType<'a> { + TSType::TSIntrinsicKeyword(self.alloc_ts_intrinsic_keyword(span)) } - /// Build a [`TSAnyKeyword`]. + /// Build a [`TSType::TSNeverKeyword`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_any_keyword`] instead. + /// This node contains a [`TSNeverKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn ts_any_keyword(self, span: Span) -> TSAnyKeyword { - TSAnyKeyword { span } + pub fn ts_type_never_keyword(self, span: Span) -> TSType<'a> { + TSType::TSNeverKeyword(self.alloc_ts_never_keyword(span)) } - /// Build a [`TSAnyKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSNullKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_any_keyword`] instead. + /// This node contains a [`TSNullKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn alloc_ts_any_keyword(self, span: Span) -> Box<'a, TSAnyKeyword> { - Box::new_in(self.ts_any_keyword(span), self.allocator) + pub fn ts_type_null_keyword(self, span: Span) -> TSType<'a> { + TSType::TSNullKeyword(self.alloc_ts_null_keyword(span)) } - /// Build a [`TSStringKeyword`]. + /// Build a [`TSType::TSNumberKeyword`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_string_keyword`] instead. + /// This node contains a [`TSNumberKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn ts_string_keyword(self, span: Span) -> TSStringKeyword { - TSStringKeyword { span } + pub fn ts_type_number_keyword(self, span: Span) -> TSType<'a> { + TSType::TSNumberKeyword(self.alloc_ts_number_keyword(span)) } - /// Build a [`TSStringKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSObjectKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_string_keyword`] instead. + /// This node contains a [`TSObjectKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn alloc_ts_string_keyword(self, span: Span) -> Box<'a, TSStringKeyword> { - Box::new_in(self.ts_string_keyword(span), self.allocator) + pub fn ts_type_object_keyword(self, span: Span) -> TSType<'a> { + TSType::TSObjectKeyword(self.alloc_ts_object_keyword(span)) } - /// Build a [`TSBooleanKeyword`]. + /// Build a [`TSType::TSStringKeyword`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_boolean_keyword`] instead. + /// This node contains a [`TSStringKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn ts_boolean_keyword(self, span: Span) -> TSBooleanKeyword { - TSBooleanKeyword { span } + pub fn ts_type_string_keyword(self, span: Span) -> TSType<'a> { + TSType::TSStringKeyword(self.alloc_ts_string_keyword(span)) } - /// Build a [`TSBooleanKeyword`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_boolean_keyword`] instead. - /// - /// ## Parameters - /// * `span`: The [`Span`] covering this node - #[inline] - pub fn alloc_ts_boolean_keyword(self, span: Span) -> Box<'a, TSBooleanKeyword> { - Box::new_in(self.ts_boolean_keyword(span), self.allocator) - } - - /// Build a [`TSNumberKeyword`]. + /// Build a [`TSType::TSSymbolKeyword`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_number_keyword`] instead. + /// This node contains a [`TSSymbolKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn ts_number_keyword(self, span: Span) -> TSNumberKeyword { - TSNumberKeyword { span } + pub fn ts_type_symbol_keyword(self, span: Span) -> TSType<'a> { + TSType::TSSymbolKeyword(self.alloc_ts_symbol_keyword(span)) } - /// Build a [`TSNumberKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSUndefinedKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_number_keyword`] instead. + /// This node contains a [`TSUndefinedKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn alloc_ts_number_keyword(self, span: Span) -> Box<'a, TSNumberKeyword> { - Box::new_in(self.ts_number_keyword(span), self.allocator) + pub fn ts_type_undefined_keyword(self, span: Span) -> TSType<'a> { + TSType::TSUndefinedKeyword(self.alloc_ts_undefined_keyword(span)) } - /// Build a [`TSNeverKeyword`]. + /// Build a [`TSType::TSUnknownKeyword`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_never_keyword`] instead. + /// This node contains a [`TSUnknownKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn ts_never_keyword(self, span: Span) -> TSNeverKeyword { - TSNeverKeyword { span } + pub fn ts_type_unknown_keyword(self, span: Span) -> TSType<'a> { + TSType::TSUnknownKeyword(self.alloc_ts_unknown_keyword(span)) } - /// Build a [`TSNeverKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSVoidKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_never_keyword`] instead. + /// This node contains a [`TSVoidKeyword`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn alloc_ts_never_keyword(self, span: Span) -> Box<'a, TSNeverKeyword> { - Box::new_in(self.ts_never_keyword(span), self.allocator) + pub fn ts_type_void_keyword(self, span: Span) -> TSType<'a> { + TSType::TSVoidKeyword(self.alloc_ts_void_keyword(span)) } - /// Build a [`TSIntrinsicKeyword`]. + /// Build a [`TSType::TSArrayType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_intrinsic_keyword`] instead. + /// This node contains a [`TSArrayType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `element_type` #[inline] - pub fn ts_intrinsic_keyword(self, span: Span) -> TSIntrinsicKeyword { - TSIntrinsicKeyword { span } + pub fn ts_type_array_type(self, span: Span, element_type: TSType<'a>) -> TSType<'a> { + TSType::TSArrayType(self.alloc_ts_array_type(span, element_type)) } - /// Build a [`TSIntrinsicKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSConditionalType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_intrinsic_keyword`] instead. + /// This node contains a [`TSConditionalType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `check_type`: The type before `extends` in the test expression. + /// * `extends_type`: The type `check_type` is being tested against. + /// * `true_type`: The type evaluated to if the test is true. + /// * `false_type`: The type evaluated to if the test is false. #[inline] - pub fn alloc_ts_intrinsic_keyword(self, span: Span) -> Box<'a, TSIntrinsicKeyword> { - Box::new_in(self.ts_intrinsic_keyword(span), self.allocator) + pub fn ts_type_conditional_type( + self, + span: Span, + check_type: TSType<'a>, + extends_type: TSType<'a>, + true_type: TSType<'a>, + false_type: TSType<'a>, + ) -> TSType<'a> { + TSType::TSConditionalType(self.alloc_ts_conditional_type( + span, + check_type, + extends_type, + true_type, + false_type, + )) } - /// Build a [`TSUnknownKeyword`]. + /// Build a [`TSType::TSConstructorType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_unknown_keyword`] instead. + /// This node contains a [`TSConstructorType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `abstract` + /// * `type_parameters` + /// * `params` + /// * `return_type` #[inline] - pub fn ts_unknown_keyword(self, span: Span) -> TSUnknownKeyword { - TSUnknownKeyword { span } + pub fn ts_type_constructor_type( + self, + span: Span, + r#abstract: bool, + type_parameters: T1, + params: T2, + return_type: T3, + ) -> TSType<'a> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + TSType::TSConstructorType(self.alloc_ts_constructor_type( + span, + r#abstract, + type_parameters, + params, + return_type, + )) } - /// Build a [`TSUnknownKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSFunctionType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_unknown_keyword`] instead. + /// This node contains a [`TSFunctionType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `type_parameters`: Generic type parameters + /// * `this_param`: `this` parameter + /// * `params`: Function parameters. Akin to [`Function::params`]. + /// * `return_type`: Return type of the function. #[inline] - pub fn alloc_ts_unknown_keyword(self, span: Span) -> Box<'a, TSUnknownKeyword> { - Box::new_in(self.ts_unknown_keyword(span), self.allocator) + pub fn ts_type_function_type( + self, + span: Span, + type_parameters: T1, + this_param: T2, + params: T3, + return_type: T4, + ) -> TSType<'a> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T4: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + TSType::TSFunctionType(self.alloc_ts_function_type( + span, + type_parameters, + this_param, + params, + return_type, + )) } - /// Build a [`TSNullKeyword`]. + /// Build a [`TSType::TSImportType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_null_keyword`] instead. + /// This node contains a [`TSImportType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `is_type_of`: `true` for `typeof import("foo")` + /// * `parameter` + /// * `qualifier` + /// * `attributes` + /// * `type_parameters` #[inline] - pub fn ts_null_keyword(self, span: Span) -> TSNullKeyword { - TSNullKeyword { span } + pub fn ts_type_import_type( + self, + span: Span, + is_type_of: bool, + parameter: TSType<'a>, + qualifier: Option>, + attributes: T1, + type_parameters: T2, + ) -> TSType<'a> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + { + TSType::TSImportType(self.alloc_ts_import_type( + span, + is_type_of, + parameter, + qualifier, + attributes, + type_parameters, + )) } - /// Build a [`TSNullKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSIndexedAccessType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_null_keyword`] instead. + /// This node contains a [`TSIndexedAccessType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `object_type` + /// * `index_type` #[inline] - pub fn alloc_ts_null_keyword(self, span: Span) -> Box<'a, TSNullKeyword> { - Box::new_in(self.ts_null_keyword(span), self.allocator) + pub fn ts_type_indexed_access_type( + self, + span: Span, + object_type: TSType<'a>, + index_type: TSType<'a>, + ) -> TSType<'a> { + TSType::TSIndexedAccessType(self.alloc_ts_indexed_access_type( + span, + object_type, + index_type, + )) } - /// Build a [`TSUndefinedKeyword`]. + /// Build a [`TSType::TSInferType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_undefined_keyword`] instead. + /// This node contains a [`TSInferType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `type_parameter`: The type bound when the #[inline] - pub fn ts_undefined_keyword(self, span: Span) -> TSUndefinedKeyword { - TSUndefinedKeyword { span } + pub fn ts_type_infer_type(self, span: Span, type_parameter: T1) -> TSType<'a> + where + T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + { + TSType::TSInferType(self.alloc_ts_infer_type(span, type_parameter)) } - /// Build a [`TSUndefinedKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSIntersectionType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_undefined_keyword`] instead. + /// This node contains a [`TSIntersectionType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `types` #[inline] - pub fn alloc_ts_undefined_keyword(self, span: Span) -> Box<'a, TSUndefinedKeyword> { - Box::new_in(self.ts_undefined_keyword(span), self.allocator) + pub fn ts_type_intersection_type(self, span: Span, types: Vec<'a, TSType<'a>>) -> TSType<'a> { + TSType::TSIntersectionType(self.alloc_ts_intersection_type(span, types)) } - /// Build a [`TSVoidKeyword`]. + /// Build a [`TSType::TSLiteralType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_void_keyword`] instead. + /// This node contains a [`TSLiteralType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `literal` #[inline] - pub fn ts_void_keyword(self, span: Span) -> TSVoidKeyword { - TSVoidKeyword { span } + pub fn ts_type_literal_type(self, span: Span, literal: TSLiteral<'a>) -> TSType<'a> { + TSType::TSLiteralType(self.alloc_ts_literal_type(span, literal)) } - /// Build a [`TSVoidKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSMappedType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_void_keyword`] instead. + /// This node contains a [`TSMappedType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. + /// * `name_type` + /// * `type_annotation` + /// * `optional`: Optional modifier on type annotation + /// * `readonly`: Readonly modifier before keyed index signature #[inline] - pub fn alloc_ts_void_keyword(self, span: Span) -> Box<'a, TSVoidKeyword> { - Box::new_in(self.ts_void_keyword(span), self.allocator) + pub fn ts_type_mapped_type( + self, + span: Span, + type_parameter: T1, + name_type: Option>, + type_annotation: Option>, + optional: TSMappedTypeModifierOperator, + readonly: TSMappedTypeModifierOperator, + ) -> TSType<'a> + where + T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + { + TSType::TSMappedType(self.alloc_ts_mapped_type( + span, + type_parameter, + name_type, + type_annotation, + optional, + readonly, + )) } - /// Build a [`TSSymbolKeyword`]. + /// Build a [`TSType::TSNamedTupleMember`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_symbol_keyword`] instead. + /// This node contains a [`TSNamedTupleMember`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `element_type` + /// * `label` + /// * `optional` #[inline] - pub fn ts_symbol_keyword(self, span: Span) -> TSSymbolKeyword { - TSSymbolKeyword { span } + pub fn ts_type_named_tuple_member( + self, + span: Span, + element_type: TSTupleElement<'a>, + label: IdentifierName<'a>, + optional: bool, + ) -> TSType<'a> { + TSType::TSNamedTupleMember(self.alloc_ts_named_tuple_member( + span, + element_type, + label, + optional, + )) } - /// Build a [`TSSymbolKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSQualifiedName`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_symbol_keyword`] instead. + /// This node contains a [`TSQualifiedName`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `left` + /// * `right` #[inline] - pub fn alloc_ts_symbol_keyword(self, span: Span) -> Box<'a, TSSymbolKeyword> { - Box::new_in(self.ts_symbol_keyword(span), self.allocator) + pub fn ts_type_qualified_name( + self, + span: Span, + left: TSTypeName<'a>, + right: IdentifierName<'a>, + ) -> TSType<'a> { + TSType::TSQualifiedName(self.alloc_ts_qualified_name(span, left, right)) } - /// Build a [`TSThisType`]. + /// Build a [`TSType::TSTemplateLiteralType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_this_type`] instead. + /// This node contains a [`TSTemplateLiteralType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `quasis`: The string parts of the template literal. + /// * `types`: The interpolated expressions in the template literal. #[inline] - pub fn ts_this_type(self, span: Span) -> TSThisType { - TSThisType { span } + pub fn ts_type_template_literal_type( + self, + span: Span, + quasis: Vec<'a, TemplateElement<'a>>, + types: Vec<'a, TSType<'a>>, + ) -> TSType<'a> { + TSType::TSTemplateLiteralType(self.alloc_ts_template_literal_type(span, quasis, types)) } - /// Build a [`TSThisType`], and store it in the memory arena. + /// Build a [`TSType::TSThisType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_this_type`] instead. + /// This node contains a [`TSThisType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node #[inline] - pub fn alloc_ts_this_type(self, span: Span) -> Box<'a, TSThisType> { - Box::new_in(self.ts_this_type(span), self.allocator) + pub fn ts_type_this_type(self, span: Span) -> TSType<'a> { + TSType::TSThisType(self.alloc_ts_this_type(span)) } - /// Build a [`TSObjectKeyword`]. + /// Build a [`TSType::TSTupleType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_object_keyword`] instead. + /// This node contains a [`TSTupleType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `element_types` #[inline] - pub fn ts_object_keyword(self, span: Span) -> TSObjectKeyword { - TSObjectKeyword { span } + pub fn ts_type_tuple_type( + self, + span: Span, + element_types: Vec<'a, TSTupleElement<'a>>, + ) -> TSType<'a> { + TSType::TSTupleType(self.alloc_ts_tuple_type(span, element_types)) } - /// Build a [`TSObjectKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSTypeLiteral`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_object_keyword`] instead. + /// This node contains a [`TSTypeLiteral`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `members` #[inline] - pub fn alloc_ts_object_keyword(self, span: Span) -> Box<'a, TSObjectKeyword> { - Box::new_in(self.ts_object_keyword(span), self.allocator) + pub fn ts_type_type_literal(self, span: Span, members: Vec<'a, TSSignature<'a>>) -> TSType<'a> { + TSType::TSTypeLiteral(self.alloc_ts_type_literal(span, members)) } - /// Build a [`TSBigIntKeyword`]. + /// Build a [`TSType::TSTypeOperatorType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_big_int_keyword`] instead. + /// This node contains a [`TSTypeOperator`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `operator` + /// * `type_annotation`: The type being operated on #[inline] - pub fn ts_big_int_keyword(self, span: Span) -> TSBigIntKeyword { - TSBigIntKeyword { span } + pub fn ts_type_type_operator( + self, + span: Span, + operator: TSTypeOperatorOperator, + type_annotation: TSType<'a>, + ) -> TSType<'a> { + TSType::TSTypeOperatorType(self.alloc_ts_type_operator(span, operator, type_annotation)) } - /// Build a [`TSBigIntKeyword`], and store it in the memory arena. + /// Build a [`TSType::TSTypePredicate`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_big_int_keyword`] instead. + /// This node contains a [`TSTypePredicate`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `parameter_name`: The identifier the predicate operates on + /// * `asserts`: Does this predicate include an `asserts` modifier? + /// * `type_annotation` #[inline] - pub fn alloc_ts_big_int_keyword(self, span: Span) -> Box<'a, TSBigIntKeyword> { - Box::new_in(self.ts_big_int_keyword(span), self.allocator) + pub fn ts_type_type_predicate( + self, + span: Span, + parameter_name: TSTypePredicateName<'a>, + asserts: bool, + type_annotation: T1, + ) -> TSType<'a> + where + T1: IntoIn<'a, Option>>>, + { + TSType::TSTypePredicate(self.alloc_ts_type_predicate( + span, + parameter_name, + asserts, + type_annotation, + )) } - /// Build a [`TSTypeReference`]. + /// Build a [`TSType::TSTypeQuery`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_reference`] instead. + /// This node contains a [`TSTypeQuery`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_name` + /// * `expr_name` /// * `type_parameters` #[inline] - pub fn ts_type_reference( + pub fn ts_type_type_query( self, span: Span, - type_name: TSTypeName<'a>, + expr_name: TSTypeQueryExprName<'a>, type_parameters: T1, - ) -> TSTypeReference<'a> + ) -> TSType<'a> where T1: IntoIn<'a, Option>>>, { - TSTypeReference { - span, - type_name, - type_parameters: type_parameters.into_in(self.allocator), - } + TSType::TSTypeQuery(self.alloc_ts_type_query(span, expr_name, type_parameters)) } - /// Build a [`TSTypeReference`], and store it in the memory arena. + /// Build a [`TSType::TSTypeReference`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_reference`] instead. + /// This node contains a [`TSTypeReference`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node /// * `type_name` /// * `type_parameters` #[inline] - pub fn alloc_ts_type_reference( + pub fn ts_type_type_reference( self, span: Span, type_name: TSTypeName<'a>, type_parameters: T1, - ) -> Box<'a, TSTypeReference<'a>> + ) -> TSType<'a> where T1: IntoIn<'a, Option>>>, { - Box::new_in(self.ts_type_reference(span, type_name, type_parameters), self.allocator) + TSType::TSTypeReference(self.alloc_ts_type_reference(span, type_name, type_parameters)) } - /// Build a [`TSTypeName::IdentifierReference`]. + /// Build a [`TSType::TSUnionType`]. /// - /// This node contains an [`IdentifierReference`] that will be stored in the memory arena. + /// This node contains a [`TSUnionType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name`: The name of the identifier being referenced. + /// * `types`: The types in the union. #[inline] - pub fn ts_type_name_identifier_reference(self, span: Span, name: A) -> TSTypeName<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - TSTypeName::IdentifierReference(self.alloc_identifier_reference(span, name)) + pub fn ts_type_union_type(self, span: Span, types: Vec<'a, TSType<'a>>) -> TSType<'a> { + TSType::TSUnionType(self.alloc_ts_union_type(span, types)) } - /// Build a [`TSTypeName::QualifiedName`]. + /// Build a [`TSType::TSParenthesizedType`]. /// - /// This node contains a [`TSQualifiedName`] that will be stored in the memory arena. + /// This node contains a [`TSParenthesizedType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `left` - /// * `right` + /// * `type_annotation` #[inline] - pub fn ts_type_name_qualified_name( - self, - span: Span, - left: TSTypeName<'a>, - right: IdentifierName<'a>, - ) -> TSTypeName<'a> { - TSTypeName::QualifiedName(self.alloc_ts_qualified_name(span, left, right)) + pub fn ts_type_parenthesized_type(self, span: Span, type_annotation: TSType<'a>) -> TSType<'a> { + TSType::TSParenthesizedType(self.alloc_ts_parenthesized_type(span, type_annotation)) } - /// Build a [`TSQualifiedName`]. + /// Build a [`TSType::JSDocNullableType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_qualified_name`] instead. + /// This node contains a [`JSDocNullableType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `left` - /// * `right` + /// * `type_annotation` + /// * `postfix`: Was `?` after the type annotation? #[inline] - pub fn ts_qualified_name( + pub fn ts_type_js_doc_nullable_type( self, span: Span, - left: TSTypeName<'a>, - right: IdentifierName<'a>, - ) -> TSQualifiedName<'a> { - TSQualifiedName { span, left, right } + type_annotation: TSType<'a>, + postfix: bool, + ) -> TSType<'a> { + TSType::JSDocNullableType(self.alloc_js_doc_nullable_type(span, type_annotation, postfix)) } - /// Build a [`TSQualifiedName`], and store it in the memory arena. + /// Build a [`TSType::JSDocNonNullableType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_qualified_name`] instead. + /// This node contains a [`JSDocNonNullableType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `left` - /// * `right` + /// * `type_annotation` + /// * `postfix` #[inline] - pub fn alloc_ts_qualified_name( + pub fn ts_type_js_doc_non_nullable_type( self, span: Span, - left: TSTypeName<'a>, - right: IdentifierName<'a>, - ) -> Box<'a, TSQualifiedName<'a>> { - Box::new_in(self.ts_qualified_name(span, left, right), self.allocator) + type_annotation: TSType<'a>, + postfix: bool, + ) -> TSType<'a> { + TSType::JSDocNonNullableType(self.alloc_js_doc_non_nullable_type( + span, + type_annotation, + postfix, + )) } - /// Build a [`TSTypeParameterInstantiation`]. + /// Build a [`TSType::JSDocUnknownType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_parameter_instantiation`] instead. + /// This node contains a [`JSDocUnknownType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `params` #[inline] - pub fn ts_type_parameter_instantiation( - self, - span: Span, - params: Vec<'a, TSType<'a>>, - ) -> TSTypeParameterInstantiation<'a> { - TSTypeParameterInstantiation { span, params } + pub fn ts_type_js_doc_unknown_type(self, span: Span) -> TSType<'a> { + TSType::JSDocUnknownType(self.alloc_js_doc_unknown_type(span)) } - /// Build a [`TSTypeParameterInstantiation`], and store it in the memory arena. + /// Build a [`TSConditionalType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_parameter_instantiation`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_conditional_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `params` + /// * `check_type`: The type before `extends` in the test expression. + /// * `extends_type`: The type `check_type` is being tested against. + /// * `true_type`: The type evaluated to if the test is true. + /// * `false_type`: The type evaluated to if the test is false. #[inline] - pub fn alloc_ts_type_parameter_instantiation( + pub fn ts_conditional_type( self, span: Span, - params: Vec<'a, TSType<'a>>, - ) -> Box<'a, TSTypeParameterInstantiation<'a>> { - Box::new_in(self.ts_type_parameter_instantiation(span, params), self.allocator) + check_type: TSType<'a>, + extends_type: TSType<'a>, + true_type: TSType<'a>, + false_type: TSType<'a>, + ) -> TSConditionalType<'a> { + TSConditionalType { + span, + check_type, + extends_type, + true_type, + false_type, + scope_id: Default::default(), + } } - /// Build a [`TSTypeParameter`]. + /// Build a [`TSConditionalType`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_parameter`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_conditional_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name`: The name of the parameter, e.g. `T` in `type Foo = ...`. - /// * `constraint`: Constrains what types can be passed to the type parameter. - /// * `default`: Default value of the type parameter if no type is provided when using the type. - /// * `in`: Was an `in` modifier keyword present? - /// * `out`: Was an `out` modifier keyword present? - /// * `const`: Was a `const` modifier keyword present? + /// * `check_type`: The type before `extends` in the test expression. + /// * `extends_type`: The type `check_type` is being tested against. + /// * `true_type`: The type evaluated to if the test is true. + /// * `false_type`: The type evaluated to if the test is false. #[inline] - pub fn ts_type_parameter( + pub fn alloc_ts_conditional_type( self, span: Span, - name: BindingIdentifier<'a>, - constraint: Option>, - default: Option>, - r#in: bool, - out: bool, - r#const: bool, - ) -> TSTypeParameter<'a> { - TSTypeParameter { span, name, constraint, default, r#in, out, r#const } + check_type: TSType<'a>, + extends_type: TSType<'a>, + true_type: TSType<'a>, + false_type: TSType<'a>, + ) -> Box<'a, TSConditionalType<'a>> { + Box::new_in( + self.ts_conditional_type(span, check_type, extends_type, true_type, false_type), + self.allocator, + ) } - /// Build a [`TSTypeParameter`], and store it in the memory arena. + /// Build a [`TSConditionalType`] with `ScopeId`. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_parameter`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_conditional_type_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name`: The name of the parameter, e.g. `T` in `type Foo = ...`. - /// * `constraint`: Constrains what types can be passed to the type parameter. - /// * `default`: Default value of the type parameter if no type is provided when using the type. - /// * `in`: Was an `in` modifier keyword present? - /// * `out`: Was an `out` modifier keyword present? - /// * `const`: Was a `const` modifier keyword present? + /// * `check_type`: The type before `extends` in the test expression. + /// * `extends_type`: The type `check_type` is being tested against. + /// * `true_type`: The type evaluated to if the test is true. + /// * `false_type`: The type evaluated to if the test is false. + /// * `scope_id` #[inline] - pub fn alloc_ts_type_parameter( + pub fn ts_conditional_type_with_scope_id( self, span: Span, - name: BindingIdentifier<'a>, - constraint: Option>, - default: Option>, - r#in: bool, - out: bool, - r#const: bool, - ) -> Box<'a, TSTypeParameter<'a>> { + check_type: TSType<'a>, + extends_type: TSType<'a>, + true_type: TSType<'a>, + false_type: TSType<'a>, + scope_id: ScopeId, + ) -> TSConditionalType<'a> { + TSConditionalType { + span, + check_type, + extends_type, + true_type, + false_type, + scope_id: Cell::new(Some(scope_id)), + } + } + + /// Build a [`TSConditionalType`] with `ScopeId`, and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_conditional_type_with_scope_id`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + /// * `check_type`: The type before `extends` in the test expression. + /// * `extends_type`: The type `check_type` is being tested against. + /// * `true_type`: The type evaluated to if the test is true. + /// * `false_type`: The type evaluated to if the test is false. + /// * `scope_id` + #[inline] + pub fn alloc_ts_conditional_type_with_scope_id( + self, + span: Span, + check_type: TSType<'a>, + extends_type: TSType<'a>, + true_type: TSType<'a>, + false_type: TSType<'a>, + scope_id: ScopeId, + ) -> Box<'a, TSConditionalType<'a>> { Box::new_in( - self.ts_type_parameter(span, name, constraint, default, r#in, out, r#const), + self.ts_conditional_type_with_scope_id( + span, + check_type, + extends_type, + true_type, + false_type, + scope_id, + ), self.allocator, ) } - /// Build a [`TSTypeParameterDeclaration`]. + /// Build a [`TSUnionType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_parameter_declaration`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_union_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `params` + /// * `types`: The types in the union. #[inline] - pub fn ts_type_parameter_declaration( - self, - span: Span, - params: Vec<'a, TSTypeParameter<'a>>, - ) -> TSTypeParameterDeclaration<'a> { - TSTypeParameterDeclaration { span, params } + pub fn ts_union_type(self, span: Span, types: Vec<'a, TSType<'a>>) -> TSUnionType<'a> { + TSUnionType { span, types } } - /// Build a [`TSTypeParameterDeclaration`], and store it in the memory arena. + /// Build a [`TSUnionType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_parameter_declaration`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_union_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `params` + /// * `types`: The types in the union. #[inline] - pub fn alloc_ts_type_parameter_declaration( + pub fn alloc_ts_union_type( self, span: Span, - params: Vec<'a, TSTypeParameter<'a>>, - ) -> Box<'a, TSTypeParameterDeclaration<'a>> { - Box::new_in(self.ts_type_parameter_declaration(span, params), self.allocator) + types: Vec<'a, TSType<'a>>, + ) -> Box<'a, TSUnionType<'a>> { + Box::new_in(self.ts_union_type(span, types), self.allocator) } - /// Build a [`TSTypeAliasDeclaration`]. + /// Build a [`TSIntersectionType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_alias_declaration`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_intersection_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: Type alias's identifier, e.g. `Foo` in `type Foo = number`. - /// * `type_parameters` - /// * `type_annotation` - /// * `declare` + /// * `types` #[inline] - pub fn ts_type_alias_declaration( + pub fn ts_intersection_type( self, span: Span, - id: BindingIdentifier<'a>, - type_parameters: T1, - type_annotation: TSType<'a>, - declare: bool, - ) -> TSTypeAliasDeclaration<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSTypeAliasDeclaration { - span, - id, - type_parameters: type_parameters.into_in(self.allocator), - type_annotation, - declare, - scope_id: Default::default(), - } + types: Vec<'a, TSType<'a>>, + ) -> TSIntersectionType<'a> { + TSIntersectionType { span, types } } - /// Build a [`TSTypeAliasDeclaration`], and store it in the memory arena. + /// Build a [`TSIntersectionType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_alias_declaration`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_intersection_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: Type alias's identifier, e.g. `Foo` in `type Foo = number`. - /// * `type_parameters` - /// * `type_annotation` - /// * `declare` + /// * `types` #[inline] - pub fn alloc_ts_type_alias_declaration( + pub fn alloc_ts_intersection_type( self, span: Span, - id: BindingIdentifier<'a>, - type_parameters: T1, - type_annotation: TSType<'a>, - declare: bool, - ) -> Box<'a, TSTypeAliasDeclaration<'a>> - where - T1: IntoIn<'a, Option>>>, - { - Box::new_in( - self.ts_type_alias_declaration(span, id, type_parameters, type_annotation, declare), - self.allocator, - ) + types: Vec<'a, TSType<'a>>, + ) -> Box<'a, TSIntersectionType<'a>> { + Box::new_in(self.ts_intersection_type(span, types), self.allocator) } - /// Build a [`TSTypeAliasDeclaration`] with `ScopeId`. + /// Build a [`TSParenthesizedType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_alias_declaration_with_scope_id`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_parenthesized_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: Type alias's identifier, e.g. `Foo` in `type Foo = number`. - /// * `type_parameters` /// * `type_annotation` - /// * `declare` - /// * `scope_id` #[inline] - pub fn ts_type_alias_declaration_with_scope_id( + pub fn ts_parenthesized_type( self, span: Span, - id: BindingIdentifier<'a>, - type_parameters: T1, type_annotation: TSType<'a>, - declare: bool, - scope_id: ScopeId, - ) -> TSTypeAliasDeclaration<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSTypeAliasDeclaration { - span, - id, - type_parameters: type_parameters.into_in(self.allocator), - type_annotation, - declare, - scope_id: Cell::new(Some(scope_id)), - } + ) -> TSParenthesizedType<'a> { + TSParenthesizedType { span, type_annotation } } - /// Build a [`TSTypeAliasDeclaration`] with `ScopeId`, and store it in the memory arena. + /// Build a [`TSParenthesizedType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_alias_declaration_with_scope_id`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_parenthesized_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: Type alias's identifier, e.g. `Foo` in `type Foo = number`. - /// * `type_parameters` /// * `type_annotation` - /// * `declare` - /// * `scope_id` #[inline] - pub fn alloc_ts_type_alias_declaration_with_scope_id( + pub fn alloc_ts_parenthesized_type( self, span: Span, - id: BindingIdentifier<'a>, - type_parameters: T1, type_annotation: TSType<'a>, - declare: bool, - scope_id: ScopeId, - ) -> Box<'a, TSTypeAliasDeclaration<'a>> - where - T1: IntoIn<'a, Option>>>, - { - Box::new_in( - self.ts_type_alias_declaration_with_scope_id( - span, - id, - type_parameters, - type_annotation, - declare, - scope_id, - ), - self.allocator, - ) + ) -> Box<'a, TSParenthesizedType<'a>> { + Box::new_in(self.ts_parenthesized_type(span, type_annotation), self.allocator) } - /// Build a [`TSClassImplements`]. + /// Build a [`TSTypeOperator`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_class_implements`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_operator`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_parameters` + /// * `operator` + /// * `type_annotation`: The type being operated on #[inline] - pub fn ts_class_implements( + pub fn ts_type_operator( self, span: Span, - expression: TSTypeName<'a>, - type_parameters: T1, - ) -> TSClassImplements<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSClassImplements { - span, - expression, - type_parameters: type_parameters.into_in(self.allocator), - } + operator: TSTypeOperatorOperator, + type_annotation: TSType<'a>, + ) -> TSTypeOperator<'a> { + TSTypeOperator { span, operator, type_annotation } } - /// Build a [`TSClassImplements`], and store it in the memory arena. + /// Build a [`TSTypeOperator`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_class_implements`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_operator`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_parameters` + /// * `operator` + /// * `type_annotation`: The type being operated on #[inline] - pub fn alloc_ts_class_implements( + pub fn alloc_ts_type_operator( self, span: Span, - expression: TSTypeName<'a>, - type_parameters: T1, - ) -> Box<'a, TSClassImplements<'a>> - where - T1: IntoIn<'a, Option>>>, - { - Box::new_in(self.ts_class_implements(span, expression, type_parameters), self.allocator) + operator: TSTypeOperatorOperator, + type_annotation: TSType<'a>, + ) -> Box<'a, TSTypeOperator<'a>> { + Box::new_in(self.ts_type_operator(span, operator, type_annotation), self.allocator) } - /// Build a [`TSInterfaceDeclaration`]. + /// Build a [`TSArrayType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_interface_declaration`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_array_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The identifier (name) of the interface. - /// * `extends`: Other interfaces/types this interface extends. - /// * `type_parameters`: Type parameters that get bound to the interface. - /// * `body` - /// * `declare`: `true` for `declare interface Foo {}` + /// * `element_type` #[inline] - pub fn ts_interface_declaration( - self, - span: Span, - id: BindingIdentifier<'a>, - extends: Option>>, - type_parameters: T1, - body: T2, - declare: bool, - ) -> TSInterfaceDeclaration<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, TSInterfaceBody<'a>>>, - { - TSInterfaceDeclaration { - span, - id, - extends, - type_parameters: type_parameters.into_in(self.allocator), - body: body.into_in(self.allocator), - declare, - scope_id: Default::default(), - } + pub fn ts_array_type(self, span: Span, element_type: TSType<'a>) -> TSArrayType<'a> { + TSArrayType { span, element_type } } - /// Build a [`TSInterfaceDeclaration`], and store it in the memory arena. + /// Build a [`TSArrayType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_interface_declaration`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_array_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The identifier (name) of the interface. - /// * `extends`: Other interfaces/types this interface extends. - /// * `type_parameters`: Type parameters that get bound to the interface. - /// * `body` - /// * `declare`: `true` for `declare interface Foo {}` + /// * `element_type` #[inline] - pub fn alloc_ts_interface_declaration( + pub fn alloc_ts_array_type( self, span: Span, - id: BindingIdentifier<'a>, - extends: Option>>, - type_parameters: T1, - body: T2, - declare: bool, - ) -> Box<'a, TSInterfaceDeclaration<'a>> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, TSInterfaceBody<'a>>>, - { - Box::new_in( - self.ts_interface_declaration(span, id, extends, type_parameters, body, declare), - self.allocator, - ) + element_type: TSType<'a>, + ) -> Box<'a, TSArrayType<'a>> { + Box::new_in(self.ts_array_type(span, element_type), self.allocator) } - /// Build a [`TSInterfaceDeclaration`] with `ScopeId`. + /// Build a [`TSIndexedAccessType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_interface_declaration_with_scope_id`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_indexed_access_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The identifier (name) of the interface. - /// * `extends`: Other interfaces/types this interface extends. - /// * `type_parameters`: Type parameters that get bound to the interface. - /// * `body` - /// * `declare`: `true` for `declare interface Foo {}` - /// * `scope_id` + /// * `object_type` + /// * `index_type` #[inline] - pub fn ts_interface_declaration_with_scope_id( + pub fn ts_indexed_access_type( self, span: Span, - id: BindingIdentifier<'a>, - extends: Option>>, - type_parameters: T1, - body: T2, - declare: bool, - scope_id: ScopeId, - ) -> TSInterfaceDeclaration<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, TSInterfaceBody<'a>>>, - { - TSInterfaceDeclaration { - span, - id, - extends, - type_parameters: type_parameters.into_in(self.allocator), - body: body.into_in(self.allocator), - declare, - scope_id: Cell::new(Some(scope_id)), - } + object_type: TSType<'a>, + index_type: TSType<'a>, + ) -> TSIndexedAccessType<'a> { + TSIndexedAccessType { span, object_type, index_type } } - /// Build a [`TSInterfaceDeclaration`] with `ScopeId`, and store it in the memory arena. + /// Build a [`TSIndexedAccessType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_interface_declaration_with_scope_id`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_indexed_access_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The identifier (name) of the interface. - /// * `extends`: Other interfaces/types this interface extends. - /// * `type_parameters`: Type parameters that get bound to the interface. - /// * `body` - /// * `declare`: `true` for `declare interface Foo {}` - /// * `scope_id` + /// * `object_type` + /// * `index_type` #[inline] - pub fn alloc_ts_interface_declaration_with_scope_id( + pub fn alloc_ts_indexed_access_type( self, span: Span, - id: BindingIdentifier<'a>, - extends: Option>>, - type_parameters: T1, - body: T2, - declare: bool, - scope_id: ScopeId, - ) -> Box<'a, TSInterfaceDeclaration<'a>> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, TSInterfaceBody<'a>>>, - { - Box::new_in( - self.ts_interface_declaration_with_scope_id( - span, - id, - extends, - type_parameters, - body, - declare, - scope_id, - ), - self.allocator, - ) + object_type: TSType<'a>, + index_type: TSType<'a>, + ) -> Box<'a, TSIndexedAccessType<'a>> { + Box::new_in(self.ts_indexed_access_type(span, object_type, index_type), self.allocator) } - /// Build a [`TSInterfaceBody`]. + /// Build a [`TSTupleType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_interface_body`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_tuple_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `body` + /// * `element_types` #[inline] - pub fn ts_interface_body( + pub fn ts_tuple_type( self, span: Span, - body: Vec<'a, TSSignature<'a>>, - ) -> TSInterfaceBody<'a> { - TSInterfaceBody { span, body } + element_types: Vec<'a, TSTupleElement<'a>>, + ) -> TSTupleType<'a> { + TSTupleType { span, element_types } } - /// Build a [`TSInterfaceBody`], and store it in the memory arena. + /// Build a [`TSTupleType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_interface_body`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_tuple_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `body` + /// * `element_types` #[inline] - pub fn alloc_ts_interface_body( + pub fn alloc_ts_tuple_type( self, span: Span, - body: Vec<'a, TSSignature<'a>>, - ) -> Box<'a, TSInterfaceBody<'a>> { - Box::new_in(self.ts_interface_body(span, body), self.allocator) + element_types: Vec<'a, TSTupleElement<'a>>, + ) -> Box<'a, TSTupleType<'a>> { + Box::new_in(self.ts_tuple_type(span, element_types), self.allocator) } - /// Build a [`TSPropertySignature`]. + /// Build a [`TSNamedTupleMember`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_property_signature`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_named_tuple_member`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `computed` + /// * `element_type` + /// * `label` /// * `optional` - /// * `readonly` - /// * `key` - /// * `type_annotation` #[inline] - pub fn ts_property_signature( + pub fn ts_named_tuple_member( self, span: Span, - computed: bool, + element_type: TSTupleElement<'a>, + label: IdentifierName<'a>, optional: bool, - readonly: bool, - key: PropertyKey<'a>, - type_annotation: T1, - ) -> TSPropertySignature<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSPropertySignature { - span, - computed, - optional, - readonly, - key, - type_annotation: type_annotation.into_in(self.allocator), - } + ) -> TSNamedTupleMember<'a> { + TSNamedTupleMember { span, element_type, label, optional } } - /// Build a [`TSPropertySignature`], and store it in the memory arena. + /// Build a [`TSNamedTupleMember`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_property_signature`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_named_tuple_member`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `computed` + /// * `element_type` + /// * `label` /// * `optional` - /// * `readonly` - /// * `key` - /// * `type_annotation` #[inline] - pub fn alloc_ts_property_signature( + pub fn alloc_ts_named_tuple_member( self, span: Span, - computed: bool, + element_type: TSTupleElement<'a>, + label: IdentifierName<'a>, optional: bool, - readonly: bool, - key: PropertyKey<'a>, - type_annotation: T1, - ) -> Box<'a, TSPropertySignature<'a>> - where - T1: IntoIn<'a, Option>>>, - { - Box::new_in( - self.ts_property_signature(span, computed, optional, readonly, key, type_annotation), - self.allocator, - ) + ) -> Box<'a, TSNamedTupleMember<'a>> { + Box::new_in(self.ts_named_tuple_member(span, element_type, label, optional), self.allocator) } - /// Build a [`TSSignature::TSIndexSignature`]. + /// Build a [`TSOptionalType`]. /// - /// This node contains a [`TSIndexSignature`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_optional_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `parameters` /// * `type_annotation` - /// * `readonly` - /// * `static` #[inline] - pub fn ts_signature_index_signature( - self, - span: Span, - parameters: Vec<'a, TSIndexSignatureName<'a>>, - type_annotation: T1, - readonly: bool, - r#static: bool, - ) -> TSSignature<'a> - where - T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, - { - TSSignature::TSIndexSignature(self.alloc_ts_index_signature( - span, - parameters, - type_annotation, - readonly, - r#static, - )) + pub fn ts_optional_type(self, span: Span, type_annotation: TSType<'a>) -> TSOptionalType<'a> { + TSOptionalType { span, type_annotation } } - /// Build a [`TSSignature::TSPropertySignature`]. + /// Build a [`TSOptionalType`], and store it in the memory arena. /// - /// This node contains a [`TSPropertySignature`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_optional_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `computed` - /// * `optional` - /// * `readonly` - /// * `key` /// * `type_annotation` #[inline] - pub fn ts_signature_property_signature( + pub fn alloc_ts_optional_type( self, span: Span, - computed: bool, - optional: bool, - readonly: bool, - key: PropertyKey<'a>, - type_annotation: T1, - ) -> TSSignature<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSSignature::TSPropertySignature(self.alloc_ts_property_signature( - span, - computed, - optional, - readonly, - key, - type_annotation, - )) + type_annotation: TSType<'a>, + ) -> Box<'a, TSOptionalType<'a>> { + Box::new_in(self.ts_optional_type(span, type_annotation), self.allocator) } - /// Build a [`TSSignature::TSCallSignatureDeclaration`]. + /// Build a [`TSRestType`]. /// - /// This node contains a [`TSCallSignatureDeclaration`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_rest_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters` - /// * `this_param` - /// * `params` - /// * `return_type` + /// * `type_annotation` #[inline] - pub fn ts_signature_call_signature_declaration( - self, - span: Span, - type_parameters: T1, - this_param: Option>, - params: T2, - return_type: T3, - ) -> TSSignature<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Option>>>, - { - TSSignature::TSCallSignatureDeclaration(self.alloc_ts_call_signature_declaration( - span, - type_parameters, - this_param, - params, - return_type, - )) + pub fn ts_rest_type(self, span: Span, type_annotation: TSType<'a>) -> TSRestType<'a> { + TSRestType { span, type_annotation } } - /// Build a [`TSSignature::TSConstructSignatureDeclaration`]. + /// Build a [`TSRestType`], and store it in the memory arena. /// - /// This node contains a [`TSConstructSignatureDeclaration`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_rest_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters` - /// * `params` - /// * `return_type` + /// * `type_annotation` #[inline] - pub fn ts_signature_construct_signature_declaration( + pub fn alloc_ts_rest_type( self, span: Span, - type_parameters: T1, - params: T2, - return_type: T3, - ) -> TSSignature<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Option>>>, - { - TSSignature::TSConstructSignatureDeclaration(self.alloc_ts_construct_signature_declaration( - span, - type_parameters, - params, - return_type, - )) + type_annotation: TSType<'a>, + ) -> Box<'a, TSRestType<'a>> { + Box::new_in(self.ts_rest_type(span, type_annotation), self.allocator) } - /// Build a [`TSSignature::TSMethodSignature`]. + /// Build a [`TSTupleElement::TSOptionalType`]. /// - /// This node contains a [`TSMethodSignature`] that will be stored in the memory arena. + /// This node contains a [`TSOptionalType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `key` - /// * `computed` - /// * `optional` - /// * `kind` - /// * `type_parameters` - /// * `this_param` - /// * `params` - /// * `return_type` + /// * `type_annotation` #[inline] - pub fn ts_signature_method_signature( + pub fn ts_tuple_element_optional_type( self, span: Span, - key: PropertyKey<'a>, - computed: bool, - optional: bool, - kind: TSMethodSignatureKind, - type_parameters: T1, - this_param: T2, - params: T3, - return_type: T4, - ) -> TSSignature<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T4: IntoIn<'a, Option>>>, - { - TSSignature::TSMethodSignature(self.alloc_ts_method_signature( - span, - key, - computed, - optional, - kind, - type_parameters, - this_param, - params, - return_type, - )) + type_annotation: TSType<'a>, + ) -> TSTupleElement<'a> { + TSTupleElement::TSOptionalType(self.alloc_ts_optional_type(span, type_annotation)) } - /// Build a [`TSIndexSignature`]. + /// Build a [`TSTupleElement::TSRestType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_index_signature`] instead. + /// This node contains a [`TSRestType`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `parameters` /// * `type_annotation` - /// * `readonly` - /// * `static` #[inline] - pub fn ts_index_signature( + pub fn ts_tuple_element_rest_type( self, span: Span, - parameters: Vec<'a, TSIndexSignatureName<'a>>, - type_annotation: T1, - readonly: bool, - r#static: bool, - ) -> TSIndexSignature<'a> - where - T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, - { - TSIndexSignature { - span, - parameters, - type_annotation: type_annotation.into_in(self.allocator), - readonly, - r#static, - } + type_annotation: TSType<'a>, + ) -> TSTupleElement<'a> { + TSTupleElement::TSRestType(self.alloc_ts_rest_type(span, type_annotation)) } - /// Build a [`TSIndexSignature`], and store it in the memory arena. + /// Build a [`TSAnyKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_index_signature`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_any_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `parameters` - /// * `type_annotation` - /// * `readonly` - /// * `static` #[inline] - pub fn alloc_ts_index_signature( - self, - span: Span, - parameters: Vec<'a, TSIndexSignatureName<'a>>, - type_annotation: T1, - readonly: bool, - r#static: bool, - ) -> Box<'a, TSIndexSignature<'a>> - where - T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, - { - Box::new_in( - self.ts_index_signature(span, parameters, type_annotation, readonly, r#static), - self.allocator, - ) + pub fn ts_any_keyword(self, span: Span) -> TSAnyKeyword { + TSAnyKeyword { span } } - /// Build a [`TSCallSignatureDeclaration`]. + /// Build a [`TSAnyKeyword`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_call_signature_declaration`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_any_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters` - /// * `this_param` - /// * `params` - /// * `return_type` #[inline] - pub fn ts_call_signature_declaration( - self, - span: Span, - type_parameters: T1, - this_param: Option>, - params: T2, - return_type: T3, - ) -> TSCallSignatureDeclaration<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Option>>>, - { - TSCallSignatureDeclaration { - span, - type_parameters: type_parameters.into_in(self.allocator), - this_param, - params: params.into_in(self.allocator), - return_type: return_type.into_in(self.allocator), - } + pub fn alloc_ts_any_keyword(self, span: Span) -> Box<'a, TSAnyKeyword> { + Box::new_in(self.ts_any_keyword(span), self.allocator) } - /// Build a [`TSCallSignatureDeclaration`], and store it in the memory arena. + /// Build a [`TSStringKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_call_signature_declaration`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_string_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters` - /// * `this_param` - /// * `params` - /// * `return_type` #[inline] - pub fn alloc_ts_call_signature_declaration( - self, - span: Span, - type_parameters: T1, - this_param: Option>, - params: T2, - return_type: T3, - ) -> Box<'a, TSCallSignatureDeclaration<'a>> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Option>>>, - { - Box::new_in( - self.ts_call_signature_declaration( - span, - type_parameters, - this_param, - params, - return_type, - ), - self.allocator, - ) + pub fn ts_string_keyword(self, span: Span) -> TSStringKeyword { + TSStringKeyword { span } } - /// Build a [`TSMethodSignature`]. + /// Build a [`TSStringKeyword`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_method_signature`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_string_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `key` - /// * `computed` - /// * `optional` - /// * `kind` - /// * `type_parameters` - /// * `this_param` - /// * `params` - /// * `return_type` #[inline] - pub fn ts_method_signature( - self, - span: Span, - key: PropertyKey<'a>, - computed: bool, - optional: bool, - kind: TSMethodSignatureKind, - type_parameters: T1, - this_param: T2, - params: T3, - return_type: T4, - ) -> TSMethodSignature<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T4: IntoIn<'a, Option>>>, - { - TSMethodSignature { - span, - key, - computed, - optional, - kind, - type_parameters: type_parameters.into_in(self.allocator), - this_param: this_param.into_in(self.allocator), - params: params.into_in(self.allocator), - return_type: return_type.into_in(self.allocator), - scope_id: Default::default(), - } + pub fn alloc_ts_string_keyword(self, span: Span) -> Box<'a, TSStringKeyword> { + Box::new_in(self.ts_string_keyword(span), self.allocator) } - /// Build a [`TSMethodSignature`], and store it in the memory arena. + /// Build a [`TSBooleanKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_method_signature`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_boolean_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `key` - /// * `computed` - /// * `optional` - /// * `kind` - /// * `type_parameters` - /// * `this_param` - /// * `params` - /// * `return_type` #[inline] - pub fn alloc_ts_method_signature( - self, - span: Span, - key: PropertyKey<'a>, - computed: bool, - optional: bool, - kind: TSMethodSignatureKind, - type_parameters: T1, - this_param: T2, - params: T3, - return_type: T4, - ) -> Box<'a, TSMethodSignature<'a>> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T4: IntoIn<'a, Option>>>, - { - Box::new_in( - self.ts_method_signature( - span, - key, - computed, - optional, - kind, - type_parameters, - this_param, - params, - return_type, - ), - self.allocator, - ) + pub fn ts_boolean_keyword(self, span: Span) -> TSBooleanKeyword { + TSBooleanKeyword { span } } - /// Build a [`TSMethodSignature`] with `ScopeId`. + /// Build a [`TSBooleanKeyword`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_method_signature_with_scope_id`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_boolean_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `key` - /// * `computed` - /// * `optional` - /// * `kind` - /// * `type_parameters` - /// * `this_param` - /// * `params` - /// * `return_type` - /// * `scope_id` #[inline] - pub fn ts_method_signature_with_scope_id( - self, - span: Span, - key: PropertyKey<'a>, - computed: bool, - optional: bool, - kind: TSMethodSignatureKind, - type_parameters: T1, - this_param: T2, - params: T3, - return_type: T4, - scope_id: ScopeId, - ) -> TSMethodSignature<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T4: IntoIn<'a, Option>>>, - { - TSMethodSignature { - span, - key, - computed, - optional, - kind, - type_parameters: type_parameters.into_in(self.allocator), - this_param: this_param.into_in(self.allocator), - params: params.into_in(self.allocator), - return_type: return_type.into_in(self.allocator), - scope_id: Cell::new(Some(scope_id)), - } + pub fn alloc_ts_boolean_keyword(self, span: Span) -> Box<'a, TSBooleanKeyword> { + Box::new_in(self.ts_boolean_keyword(span), self.allocator) } - /// Build a [`TSMethodSignature`] with `ScopeId`, and store it in the memory arena. + /// Build a [`TSNumberKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_method_signature_with_scope_id`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_number_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `key` - /// * `computed` - /// * `optional` - /// * `kind` - /// * `type_parameters` - /// * `this_param` - /// * `params` - /// * `return_type` - /// * `scope_id` #[inline] - pub fn alloc_ts_method_signature_with_scope_id( - self, - span: Span, - key: PropertyKey<'a>, - computed: bool, - optional: bool, - kind: TSMethodSignatureKind, - type_parameters: T1, - this_param: T2, - params: T3, - return_type: T4, - scope_id: ScopeId, - ) -> Box<'a, TSMethodSignature<'a>> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T4: IntoIn<'a, Option>>>, - { - Box::new_in( - self.ts_method_signature_with_scope_id( - span, - key, - computed, - optional, - kind, - type_parameters, - this_param, - params, - return_type, - scope_id, - ), - self.allocator, - ) + pub fn ts_number_keyword(self, span: Span) -> TSNumberKeyword { + TSNumberKeyword { span } } - /// Build a [`TSConstructSignatureDeclaration`]. + /// Build a [`TSNumberKeyword`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_construct_signature_declaration`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_number_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters` - /// * `params` - /// * `return_type` #[inline] - pub fn ts_construct_signature_declaration( - self, - span: Span, - type_parameters: T1, - params: T2, - return_type: T3, - ) -> TSConstructSignatureDeclaration<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Option>>>, - { - TSConstructSignatureDeclaration { - span, - type_parameters: type_parameters.into_in(self.allocator), - params: params.into_in(self.allocator), - return_type: return_type.into_in(self.allocator), - scope_id: Default::default(), - } + pub fn alloc_ts_number_keyword(self, span: Span) -> Box<'a, TSNumberKeyword> { + Box::new_in(self.ts_number_keyword(span), self.allocator) } - /// Build a [`TSConstructSignatureDeclaration`], and store it in the memory arena. + /// Build a [`TSNeverKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_construct_signature_declaration`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_never_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters` - /// * `params` - /// * `return_type` #[inline] - pub fn alloc_ts_construct_signature_declaration( - self, - span: Span, - type_parameters: T1, - params: T2, - return_type: T3, - ) -> Box<'a, TSConstructSignatureDeclaration<'a>> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Option>>>, - { - Box::new_in( - self.ts_construct_signature_declaration(span, type_parameters, params, return_type), - self.allocator, - ) + pub fn ts_never_keyword(self, span: Span) -> TSNeverKeyword { + TSNeverKeyword { span } } - /// Build a [`TSConstructSignatureDeclaration`] with `ScopeId`. + /// Build a [`TSNeverKeyword`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_construct_signature_declaration_with_scope_id`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_never_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters` - /// * `params` - /// * `return_type` - /// * `scope_id` #[inline] - pub fn ts_construct_signature_declaration_with_scope_id( - self, - span: Span, - type_parameters: T1, - params: T2, - return_type: T3, - scope_id: ScopeId, - ) -> TSConstructSignatureDeclaration<'a> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Option>>>, - { - TSConstructSignatureDeclaration { - span, - type_parameters: type_parameters.into_in(self.allocator), - params: params.into_in(self.allocator), - return_type: return_type.into_in(self.allocator), - scope_id: Cell::new(Some(scope_id)), - } + pub fn alloc_ts_never_keyword(self, span: Span) -> Box<'a, TSNeverKeyword> { + Box::new_in(self.ts_never_keyword(span), self.allocator) } - /// Build a [`TSConstructSignatureDeclaration`] with `ScopeId`, and store it in the memory arena. + /// Build a [`TSIntrinsicKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_construct_signature_declaration_with_scope_id`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_intrinsic_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters` - /// * `params` - /// * `return_type` - /// * `scope_id` #[inline] - pub fn alloc_ts_construct_signature_declaration_with_scope_id( - self, - span: Span, - type_parameters: T1, - params: T2, - return_type: T3, - scope_id: ScopeId, - ) -> Box<'a, TSConstructSignatureDeclaration<'a>> - where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Option>>>, - { - Box::new_in( - self.ts_construct_signature_declaration_with_scope_id( - span, - type_parameters, - params, - return_type, - scope_id, - ), - self.allocator, - ) + pub fn ts_intrinsic_keyword(self, span: Span) -> TSIntrinsicKeyword { + TSIntrinsicKeyword { span } } - /// Build a [`TSIndexSignatureName`]. + /// Build a [`TSIntrinsicKeyword`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_index_signature_name`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_intrinsic_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name` - /// * `type_annotation` #[inline] - pub fn ts_index_signature_name( - self, - span: Span, - name: A, - type_annotation: T1, - ) -> TSIndexSignatureName<'a> - where - A: IntoIn<'a, Atom<'a>>, - T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, - { - TSIndexSignatureName { - span, - name: name.into_in(self.allocator), - type_annotation: type_annotation.into_in(self.allocator), - } + pub fn alloc_ts_intrinsic_keyword(self, span: Span) -> Box<'a, TSIntrinsicKeyword> { + Box::new_in(self.ts_intrinsic_keyword(span), self.allocator) + } + + /// Build a [`TSUnknownKeyword`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_unknown_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn ts_unknown_keyword(self, span: Span) -> TSUnknownKeyword { + TSUnknownKeyword { span } + } + + /// Build a [`TSUnknownKeyword`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_unknown_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn alloc_ts_unknown_keyword(self, span: Span) -> Box<'a, TSUnknownKeyword> { + Box::new_in(self.ts_unknown_keyword(span), self.allocator) + } + + /// Build a [`TSNullKeyword`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_null_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn ts_null_keyword(self, span: Span) -> TSNullKeyword { + TSNullKeyword { span } + } + + /// Build a [`TSNullKeyword`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_null_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn alloc_ts_null_keyword(self, span: Span) -> Box<'a, TSNullKeyword> { + Box::new_in(self.ts_null_keyword(span), self.allocator) + } + + /// Build a [`TSUndefinedKeyword`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_undefined_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn ts_undefined_keyword(self, span: Span) -> TSUndefinedKeyword { + TSUndefinedKeyword { span } + } + + /// Build a [`TSUndefinedKeyword`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_undefined_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn alloc_ts_undefined_keyword(self, span: Span) -> Box<'a, TSUndefinedKeyword> { + Box::new_in(self.ts_undefined_keyword(span), self.allocator) + } + + /// Build a [`TSVoidKeyword`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_void_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn ts_void_keyword(self, span: Span) -> TSVoidKeyword { + TSVoidKeyword { span } + } + + /// Build a [`TSVoidKeyword`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_void_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn alloc_ts_void_keyword(self, span: Span) -> Box<'a, TSVoidKeyword> { + Box::new_in(self.ts_void_keyword(span), self.allocator) + } + + /// Build a [`TSSymbolKeyword`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_symbol_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn ts_symbol_keyword(self, span: Span) -> TSSymbolKeyword { + TSSymbolKeyword { span } + } + + /// Build a [`TSSymbolKeyword`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_symbol_keyword`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn alloc_ts_symbol_keyword(self, span: Span) -> Box<'a, TSSymbolKeyword> { + Box::new_in(self.ts_symbol_keyword(span), self.allocator) + } + + /// Build a [`TSThisType`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_this_type`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn ts_this_type(self, span: Span) -> TSThisType { + TSThisType { span } + } + + /// Build a [`TSThisType`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_this_type`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + #[inline] + pub fn alloc_ts_this_type(self, span: Span) -> Box<'a, TSThisType> { + Box::new_in(self.ts_this_type(span), self.allocator) } - /// Build a [`TSIndexSignatureName`], and store it in the memory arena. + /// Build a [`TSObjectKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_index_signature_name`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_object_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name` - /// * `type_annotation` #[inline] - pub fn alloc_ts_index_signature_name( - self, - span: Span, - name: A, - type_annotation: T1, - ) -> Box<'a, TSIndexSignatureName<'a>> - where - A: IntoIn<'a, Atom<'a>>, - T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, - { - Box::new_in(self.ts_index_signature_name(span, name, type_annotation), self.allocator) + pub fn ts_object_keyword(self, span: Span) -> TSObjectKeyword { + TSObjectKeyword { span } } - /// Build a [`TSInterfaceHeritage`]. + /// Build a [`TSObjectKeyword`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_interface_heritage`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_object_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_parameters` #[inline] - pub fn ts_interface_heritage( - self, - span: Span, - expression: Expression<'a>, - type_parameters: T1, - ) -> TSInterfaceHeritage<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSInterfaceHeritage { - span, - expression, - type_parameters: type_parameters.into_in(self.allocator), - } + pub fn alloc_ts_object_keyword(self, span: Span) -> Box<'a, TSObjectKeyword> { + Box::new_in(self.ts_object_keyword(span), self.allocator) } - /// Build a [`TSInterfaceHeritage`], and store it in the memory arena. + /// Build a [`TSBigIntKeyword`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_interface_heritage`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_big_int_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_parameters` #[inline] - pub fn alloc_ts_interface_heritage( - self, - span: Span, - expression: Expression<'a>, - type_parameters: T1, - ) -> Box<'a, TSInterfaceHeritage<'a>> - where - T1: IntoIn<'a, Option>>>, - { - Box::new_in(self.ts_interface_heritage(span, expression, type_parameters), self.allocator) + pub fn ts_big_int_keyword(self, span: Span) -> TSBigIntKeyword { + TSBigIntKeyword { span } } - /// Build a [`TSTypePredicate`]. + /// Build a [`TSBigIntKeyword`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_predicate`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_big_int_keyword`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `parameter_name`: The identifier the predicate operates on - /// * `asserts`: Does this predicate include an `asserts` modifier? - /// * `type_annotation` #[inline] - pub fn ts_type_predicate( - self, - span: Span, - parameter_name: TSTypePredicateName<'a>, - asserts: bool, - type_annotation: T1, - ) -> TSTypePredicate<'a> - where - T1: IntoIn<'a, Option>>>, - { - TSTypePredicate { - span, - parameter_name, - asserts, - type_annotation: type_annotation.into_in(self.allocator), - } + pub fn alloc_ts_big_int_keyword(self, span: Span) -> Box<'a, TSBigIntKeyword> { + Box::new_in(self.ts_big_int_keyword(span), self.allocator) } - /// Build a [`TSTypePredicate`], and store it in the memory arena. + /// Build a [`TSTypeReference`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_predicate`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_reference`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `parameter_name`: The identifier the predicate operates on - /// * `asserts`: Does this predicate include an `asserts` modifier? - /// * `type_annotation` + /// * `type_name` + /// * `type_parameters` #[inline] - pub fn alloc_ts_type_predicate( + pub fn ts_type_reference( self, span: Span, - parameter_name: TSTypePredicateName<'a>, - asserts: bool, - type_annotation: T1, - ) -> Box<'a, TSTypePredicate<'a>> + type_name: TSTypeName<'a>, + type_parameters: T1, + ) -> TSTypeReference<'a> where - T1: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, { - Box::new_in( - self.ts_type_predicate(span, parameter_name, asserts, type_annotation), - self.allocator, - ) + TSTypeReference { + span, + type_name, + type_parameters: type_parameters.into_in(self.allocator), + } } - /// Build a [`TSTypePredicateName::Identifier`]. + /// Build a [`TSTypeReference`], and store it in the memory arena. /// - /// This node contains an [`IdentifierName`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_reference`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name` + /// * `type_name` + /// * `type_parameters` #[inline] - pub fn ts_type_predicate_name_identifier_name( + pub fn alloc_ts_type_reference( self, span: Span, - name: A, - ) -> TSTypePredicateName<'a> + type_name: TSTypeName<'a>, + type_parameters: T1, + ) -> Box<'a, TSTypeReference<'a>> where - A: IntoIn<'a, Atom<'a>>, + T1: IntoIn<'a, Option>>>, { - TSTypePredicateName::Identifier(self.alloc_identifier_name(span, name)) + Box::new_in(self.ts_type_reference(span, type_name, type_parameters), self.allocator) } - /// Build a [`TSTypePredicateName::This`]. + /// Build a [`TSTypeName::IdentifierReference`]. + /// + /// This node contains an [`IdentifierReference`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `name`: The name of the identifier being referenced. #[inline] - pub fn ts_type_predicate_name_this_type(self, span: Span) -> TSTypePredicateName<'a> { - TSTypePredicateName::This(self.ts_this_type(span)) + pub fn ts_type_name_identifier_reference(self, span: Span, name: A) -> TSTypeName<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + TSTypeName::IdentifierReference(self.alloc_identifier_reference(span, name)) } - /// Build a [`TSModuleDeclaration`]. + /// Build a [`TSTypeName::QualifiedName`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_module_declaration`] instead. + /// This node contains a [`TSQualifiedName`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The name of the module/namespace being declared. - /// * `body` - /// * `kind`: The keyword used to define this module declaration. - /// * `declare` + /// * `left` + /// * `right` #[inline] - pub fn ts_module_declaration( + pub fn ts_type_name_qualified_name( self, span: Span, - id: TSModuleDeclarationName<'a>, - body: Option>, - kind: TSModuleDeclarationKind, - declare: bool, - ) -> TSModuleDeclaration<'a> { - TSModuleDeclaration { span, id, body, kind, declare, scope_id: Default::default() } + left: TSTypeName<'a>, + right: IdentifierName<'a>, + ) -> TSTypeName<'a> { + TSTypeName::QualifiedName(self.alloc_ts_qualified_name(span, left, right)) } - /// Build a [`TSModuleDeclaration`], and store it in the memory arena. + /// Build a [`TSQualifiedName`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_module_declaration`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_qualified_name`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The name of the module/namespace being declared. - /// * `body` - /// * `kind`: The keyword used to define this module declaration. - /// * `declare` + /// * `left` + /// * `right` #[inline] - pub fn alloc_ts_module_declaration( + pub fn ts_qualified_name( self, span: Span, - id: TSModuleDeclarationName<'a>, - body: Option>, - kind: TSModuleDeclarationKind, - declare: bool, - ) -> Box<'a, TSModuleDeclaration<'a>> { - Box::new_in(self.ts_module_declaration(span, id, body, kind, declare), self.allocator) + left: TSTypeName<'a>, + right: IdentifierName<'a>, + ) -> TSQualifiedName<'a> { + TSQualifiedName { span, left, right } } - /// Build a [`TSModuleDeclaration`] with `ScopeId`. + /// Build a [`TSQualifiedName`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_module_declaration_with_scope_id`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_qualified_name`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The name of the module/namespace being declared. - /// * `body` - /// * `kind`: The keyword used to define this module declaration. - /// * `declare` - /// * `scope_id` + /// * `left` + /// * `right` #[inline] - pub fn ts_module_declaration_with_scope_id( + pub fn alloc_ts_qualified_name( self, span: Span, - id: TSModuleDeclarationName<'a>, - body: Option>, - kind: TSModuleDeclarationKind, - declare: bool, - scope_id: ScopeId, - ) -> TSModuleDeclaration<'a> { - TSModuleDeclaration { span, id, body, kind, declare, scope_id: Cell::new(Some(scope_id)) } + left: TSTypeName<'a>, + right: IdentifierName<'a>, + ) -> Box<'a, TSQualifiedName<'a>> { + Box::new_in(self.ts_qualified_name(span, left, right), self.allocator) } - /// Build a [`TSModuleDeclaration`] with `ScopeId`, and store it in the memory arena. + /// Build a [`TSTypeParameterInstantiation`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_module_declaration_with_scope_id`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_parameter_instantiation`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The name of the module/namespace being declared. - /// * `body` - /// * `kind`: The keyword used to define this module declaration. - /// * `declare` - /// * `scope_id` + /// * `params` #[inline] - pub fn alloc_ts_module_declaration_with_scope_id( + pub fn ts_type_parameter_instantiation( self, span: Span, - id: TSModuleDeclarationName<'a>, - body: Option>, - kind: TSModuleDeclarationKind, - declare: bool, - scope_id: ScopeId, - ) -> Box<'a, TSModuleDeclaration<'a>> { - Box::new_in( - self.ts_module_declaration_with_scope_id(span, id, body, kind, declare, scope_id), - self.allocator, - ) + params: Vec<'a, TSType<'a>>, + ) -> TSTypeParameterInstantiation<'a> { + TSTypeParameterInstantiation { span, params } } - /// Build a [`TSModuleDeclarationName::Identifier`]. + /// Build a [`TSTypeParameterInstantiation`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_parameter_instantiation`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name`: The identifier name being bound. + /// * `params` #[inline] - pub fn ts_module_declaration_name_binding_identifier( + pub fn alloc_ts_type_parameter_instantiation( self, - span: Span, - name: A, - ) -> TSModuleDeclarationName<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - TSModuleDeclarationName::Identifier(self.binding_identifier(span, name)) + span: Span, + params: Vec<'a, TSType<'a>>, + ) -> Box<'a, TSTypeParameterInstantiation<'a>> { + Box::new_in(self.ts_type_parameter_instantiation(span, params), self.allocator) } - /// Build a [`TSModuleDeclarationName::StringLiteral`]. + /// Build a [`TSTypeParameter`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_parameter`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The value of the string. - /// * `raw`: The raw string as it appears in source code. + /// * `span`: The [`Span`] covering this node + /// * `name`: The name of the parameter, e.g. `T` in `type Foo = ...`. + /// * `constraint`: Constrains what types can be passed to the type parameter. + /// * `default`: Default value of the type parameter if no type is provided when using the type. + /// * `in`: Was an `in` modifier keyword present? + /// * `out`: Was an `out` modifier keyword present? + /// * `const`: Was a `const` modifier keyword present? #[inline] - pub fn ts_module_declaration_name_string_literal( + pub fn ts_type_parameter( self, span: Span, - value: A, - raw: Option>, - ) -> TSModuleDeclarationName<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - TSModuleDeclarationName::StringLiteral(self.string_literal(span, value, raw)) + name: BindingIdentifier<'a>, + constraint: Option>, + default: Option>, + r#in: bool, + out: bool, + r#const: bool, + ) -> TSTypeParameter<'a> { + TSTypeParameter { span, name, constraint, default, r#in, out, r#const } } - /// Build a [`TSModuleDeclarationBody::TSModuleDeclaration`]. + /// Build a [`TSTypeParameter`], and store it in the memory arena. /// - /// This node contains a [`TSModuleDeclaration`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_parameter`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id`: The name of the module/namespace being declared. - /// * `body` - /// * `kind`: The keyword used to define this module declaration. - /// * `declare` + /// * `name`: The name of the parameter, e.g. `T` in `type Foo = ...`. + /// * `constraint`: Constrains what types can be passed to the type parameter. + /// * `default`: Default value of the type parameter if no type is provided when using the type. + /// * `in`: Was an `in` modifier keyword present? + /// * `out`: Was an `out` modifier keyword present? + /// * `const`: Was a `const` modifier keyword present? #[inline] - pub fn ts_module_declaration_body_module_declaration( + pub fn alloc_ts_type_parameter( self, span: Span, - id: TSModuleDeclarationName<'a>, - body: Option>, - kind: TSModuleDeclarationKind, - declare: bool, - ) -> TSModuleDeclarationBody<'a> { - TSModuleDeclarationBody::TSModuleDeclaration( - self.alloc_ts_module_declaration(span, id, body, kind, declare), + name: BindingIdentifier<'a>, + constraint: Option>, + default: Option>, + r#in: bool, + out: bool, + r#const: bool, + ) -> Box<'a, TSTypeParameter<'a>> { + Box::new_in( + self.ts_type_parameter(span, name, constraint, default, r#in, out, r#const), + self.allocator, ) } - /// Build a [`TSModuleDeclarationBody::TSModuleBlock`]. + /// Build a [`TSTypeParameterDeclaration`]. /// - /// This node contains a [`TSModuleBlock`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_parameter_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `directives` - /// * `body` + /// * `params` #[inline] - pub fn ts_module_declaration_body_module_block( + pub fn ts_type_parameter_declaration( self, span: Span, - directives: Vec<'a, Directive<'a>>, - body: Vec<'a, Statement<'a>>, - ) -> TSModuleDeclarationBody<'a> { - TSModuleDeclarationBody::TSModuleBlock(self.alloc_ts_module_block(span, directives, body)) + params: Vec<'a, TSTypeParameter<'a>>, + ) -> TSTypeParameterDeclaration<'a> { + TSTypeParameterDeclaration { span, params } } - /// Build a [`TSModuleBlock`]. + /// Build a [`TSTypeParameterDeclaration`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_module_block`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_parameter_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `directives` - /// * `body` + /// * `params` #[inline] - pub fn ts_module_block( + pub fn alloc_ts_type_parameter_declaration( self, span: Span, - directives: Vec<'a, Directive<'a>>, - body: Vec<'a, Statement<'a>>, - ) -> TSModuleBlock<'a> { - TSModuleBlock { span, directives, body } + params: Vec<'a, TSTypeParameter<'a>>, + ) -> Box<'a, TSTypeParameterDeclaration<'a>> { + Box::new_in(self.ts_type_parameter_declaration(span, params), self.allocator) } - /// Build a [`TSModuleBlock`], and store it in the memory arena. + /// Build a [`TSTypeAliasDeclaration`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_module_block`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_alias_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `directives` - /// * `body` + /// * `id`: Type alias's identifier, e.g. `Foo` in `type Foo = number`. + /// * `type_parameters` + /// * `type_annotation` + /// * `declare` #[inline] - pub fn alloc_ts_module_block( + pub fn ts_type_alias_declaration( self, span: Span, - directives: Vec<'a, Directive<'a>>, - body: Vec<'a, Statement<'a>>, - ) -> Box<'a, TSModuleBlock<'a>> { - Box::new_in(self.ts_module_block(span, directives, body), self.allocator) + id: BindingIdentifier<'a>, + type_parameters: T1, + type_annotation: TSType<'a>, + declare: bool, + ) -> TSTypeAliasDeclaration<'a> + where + T1: IntoIn<'a, Option>>>, + { + TSTypeAliasDeclaration { + span, + id, + type_parameters: type_parameters.into_in(self.allocator), + type_annotation, + declare, + scope_id: Default::default(), + } } - /// Build a [`TSTypeLiteral`]. + /// Build a [`TSTypeAliasDeclaration`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_literal`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_alias_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `members` + /// * `id`: Type alias's identifier, e.g. `Foo` in `type Foo = number`. + /// * `type_parameters` + /// * `type_annotation` + /// * `declare` #[inline] - pub fn ts_type_literal( + pub fn alloc_ts_type_alias_declaration( self, span: Span, - members: Vec<'a, TSSignature<'a>>, - ) -> TSTypeLiteral<'a> { - TSTypeLiteral { span, members } + id: BindingIdentifier<'a>, + type_parameters: T1, + type_annotation: TSType<'a>, + declare: bool, + ) -> Box<'a, TSTypeAliasDeclaration<'a>> + where + T1: IntoIn<'a, Option>>>, + { + Box::new_in( + self.ts_type_alias_declaration(span, id, type_parameters, type_annotation, declare), + self.allocator, + ) } - /// Build a [`TSTypeLiteral`], and store it in the memory arena. + /// Build a [`TSTypeAliasDeclaration`] with `ScopeId`. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_literal`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_alias_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `members` + /// * `id`: Type alias's identifier, e.g. `Foo` in `type Foo = number`. + /// * `type_parameters` + /// * `type_annotation` + /// * `declare` + /// * `scope_id` #[inline] - pub fn alloc_ts_type_literal( + pub fn ts_type_alias_declaration_with_scope_id( self, span: Span, - members: Vec<'a, TSSignature<'a>>, - ) -> Box<'a, TSTypeLiteral<'a>> { - Box::new_in(self.ts_type_literal(span, members), self.allocator) + id: BindingIdentifier<'a>, + type_parameters: T1, + type_annotation: TSType<'a>, + declare: bool, + scope_id: ScopeId, + ) -> TSTypeAliasDeclaration<'a> + where + T1: IntoIn<'a, Option>>>, + { + TSTypeAliasDeclaration { + span, + id, + type_parameters: type_parameters.into_in(self.allocator), + type_annotation, + declare, + scope_id: Cell::new(Some(scope_id)), + } } - /// Build a [`TSInferType`]. + /// Build a [`TSTypeAliasDeclaration`] with `ScopeId`, and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_infer_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_alias_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameter`: The type bound when the + /// * `id`: Type alias's identifier, e.g. `Foo` in `type Foo = number`. + /// * `type_parameters` + /// * `type_annotation` + /// * `declare` + /// * `scope_id` #[inline] - pub fn ts_infer_type(self, span: Span, type_parameter: T1) -> TSInferType<'a> + pub fn alloc_ts_type_alias_declaration_with_scope_id( + self, + span: Span, + id: BindingIdentifier<'a>, + type_parameters: T1, + type_annotation: TSType<'a>, + declare: bool, + scope_id: ScopeId, + ) -> Box<'a, TSTypeAliasDeclaration<'a>> where - T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + T1: IntoIn<'a, Option>>>, { - TSInferType { span, type_parameter: type_parameter.into_in(self.allocator) } + Box::new_in( + self.ts_type_alias_declaration_with_scope_id( + span, + id, + type_parameters, + type_annotation, + declare, + scope_id, + ), + self.allocator, + ) } - /// Build a [`TSInferType`], and store it in the memory arena. + /// Build a [`TSClassImplements`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_infer_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_class_implements`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameter`: The type bound when the + /// * `expression` + /// * `type_parameters` #[inline] - pub fn alloc_ts_infer_type(self, span: Span, type_parameter: T1) -> Box<'a, TSInferType<'a>> + pub fn ts_class_implements( + self, + span: Span, + expression: TSTypeName<'a>, + type_parameters: T1, + ) -> TSClassImplements<'a> where - T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + T1: IntoIn<'a, Option>>>, { - Box::new_in(self.ts_infer_type(span, type_parameter), self.allocator) + TSClassImplements { + span, + expression, + type_parameters: type_parameters.into_in(self.allocator), + } } - /// Build a [`TSTypeQuery`]. + /// Build a [`TSClassImplements`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_query`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_class_implements`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expr_name` + /// * `expression` /// * `type_parameters` #[inline] - pub fn ts_type_query( + pub fn alloc_ts_class_implements( self, span: Span, - expr_name: TSTypeQueryExprName<'a>, + expression: TSTypeName<'a>, type_parameters: T1, - ) -> TSTypeQuery<'a> + ) -> Box<'a, TSClassImplements<'a>> where T1: IntoIn<'a, Option>>>, { - TSTypeQuery { span, expr_name, type_parameters: type_parameters.into_in(self.allocator) } + Box::new_in(self.ts_class_implements(span, expression, type_parameters), self.allocator) } - /// Build a [`TSTypeQuery`], and store it in the memory arena. + /// Build a [`TSInterfaceDeclaration`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_query`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_interface_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expr_name` - /// * `type_parameters` + /// * `id`: The identifier (name) of the interface. + /// * `extends`: Other interfaces/types this interface extends. + /// * `type_parameters`: Type parameters that get bound to the interface. + /// * `body` + /// * `declare`: `true` for `declare interface Foo {}` #[inline] - pub fn alloc_ts_type_query( + pub fn ts_interface_declaration( self, span: Span, - expr_name: TSTypeQueryExprName<'a>, + id: BindingIdentifier<'a>, + extends: Option>>, type_parameters: T1, - ) -> Box<'a, TSTypeQuery<'a>> + body: T2, + declare: bool, + ) -> TSInterfaceDeclaration<'a> where - T1: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, TSInterfaceBody<'a>>>, { - Box::new_in(self.ts_type_query(span, expr_name, type_parameters), self.allocator) + TSInterfaceDeclaration { + span, + id, + extends, + type_parameters: type_parameters.into_in(self.allocator), + body: body.into_in(self.allocator), + declare, + scope_id: Default::default(), + } } - /// Build a [`TSTypeQueryExprName::TSImportType`]. + /// Build a [`TSInterfaceDeclaration`], and store it in the memory arena. /// - /// This node contains a [`TSImportType`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_interface_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `is_type_of`: `true` for `typeof import("foo")` - /// * `parameter` - /// * `qualifier` - /// * `attributes` - /// * `type_parameters` + /// * `id`: The identifier (name) of the interface. + /// * `extends`: Other interfaces/types this interface extends. + /// * `type_parameters`: Type parameters that get bound to the interface. + /// * `body` + /// * `declare`: `true` for `declare interface Foo {}` #[inline] - pub fn ts_type_query_expr_name_import_type( + pub fn alloc_ts_interface_declaration( self, span: Span, - is_type_of: bool, - parameter: TSType<'a>, - qualifier: Option>, - attributes: T1, - type_parameters: T2, - ) -> TSTypeQueryExprName<'a> + id: BindingIdentifier<'a>, + extends: Option>>, + type_parameters: T1, + body: T2, + declare: bool, + ) -> Box<'a, TSInterfaceDeclaration<'a>> where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, TSInterfaceBody<'a>>>, { - TSTypeQueryExprName::TSImportType(self.alloc_ts_import_type( - span, - is_type_of, - parameter, - qualifier, - attributes, - type_parameters, - )) + Box::new_in( + self.ts_interface_declaration(span, id, extends, type_parameters, body, declare), + self.allocator, + ) } - /// Build a [`TSImportType`]. + /// Build a [`TSInterfaceDeclaration`] with `ScopeId`. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_interface_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `is_type_of`: `true` for `typeof import("foo")` - /// * `parameter` - /// * `qualifier` - /// * `attributes` - /// * `type_parameters` + /// * `id`: The identifier (name) of the interface. + /// * `extends`: Other interfaces/types this interface extends. + /// * `type_parameters`: Type parameters that get bound to the interface. + /// * `body` + /// * `declare`: `true` for `declare interface Foo {}` + /// * `scope_id` #[inline] - pub fn ts_import_type( + pub fn ts_interface_declaration_with_scope_id( self, span: Span, - is_type_of: bool, - parameter: TSType<'a>, - qualifier: Option>, - attributes: T1, - type_parameters: T2, - ) -> TSImportType<'a> + id: BindingIdentifier<'a>, + extends: Option>>, + type_parameters: T1, + body: T2, + declare: bool, + scope_id: ScopeId, + ) -> TSInterfaceDeclaration<'a> where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, TSInterfaceBody<'a>>>, { - TSImportType { + TSInterfaceDeclaration { span, - is_type_of, - parameter, - qualifier, - attributes: attributes.into_in(self.allocator), + id, + extends, type_parameters: type_parameters.into_in(self.allocator), + body: body.into_in(self.allocator), + declare, + scope_id: Cell::new(Some(scope_id)), } } - /// Build a [`TSImportType`], and store it in the memory arena. + /// Build a [`TSInterfaceDeclaration`] with `ScopeId`, and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_interface_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `is_type_of`: `true` for `typeof import("foo")` - /// * `parameter` - /// * `qualifier` - /// * `attributes` - /// * `type_parameters` + /// * `id`: The identifier (name) of the interface. + /// * `extends`: Other interfaces/types this interface extends. + /// * `type_parameters`: Type parameters that get bound to the interface. + /// * `body` + /// * `declare`: `true` for `declare interface Foo {}` + /// * `scope_id` #[inline] - pub fn alloc_ts_import_type( + pub fn alloc_ts_interface_declaration_with_scope_id( self, span: Span, - is_type_of: bool, - parameter: TSType<'a>, - qualifier: Option>, - attributes: T1, - type_parameters: T2, - ) -> Box<'a, TSImportType<'a>> + id: BindingIdentifier<'a>, + extends: Option>>, + type_parameters: T1, + body: T2, + declare: bool, + scope_id: ScopeId, + ) -> Box<'a, TSInterfaceDeclaration<'a>> where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, TSInterfaceBody<'a>>>, { Box::new_in( - self.ts_import_type( + self.ts_interface_declaration_with_scope_id( span, - is_type_of, - parameter, - qualifier, - attributes, + id, + extends, type_parameters, + body, + declare, + scope_id, ), self.allocator, ) } - /// Build a [`TSImportAttributes`]. + /// Build a [`TSInterfaceBody`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_attributes`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_interface_body`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `attributes_keyword` - /// * `elements` + /// * `body` #[inline] - pub fn ts_import_attributes( + pub fn ts_interface_body( self, span: Span, - attributes_keyword: IdentifierName<'a>, - elements: Vec<'a, TSImportAttribute<'a>>, - ) -> TSImportAttributes<'a> { - TSImportAttributes { span, attributes_keyword, elements } + body: Vec<'a, TSSignature<'a>>, + ) -> TSInterfaceBody<'a> { + TSInterfaceBody { span, body } } - /// Build a [`TSImportAttributes`], and store it in the memory arena. + /// Build a [`TSInterfaceBody`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_attributes`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_interface_body`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `attributes_keyword` - /// * `elements` + /// * `body` #[inline] - pub fn alloc_ts_import_attributes( + pub fn alloc_ts_interface_body( self, span: Span, - attributes_keyword: IdentifierName<'a>, - elements: Vec<'a, TSImportAttribute<'a>>, - ) -> Box<'a, TSImportAttributes<'a>> { - Box::new_in(self.ts_import_attributes(span, attributes_keyword, elements), self.allocator) + body: Vec<'a, TSSignature<'a>>, + ) -> Box<'a, TSInterfaceBody<'a>> { + Box::new_in(self.ts_interface_body(span, body), self.allocator) + } + + /// Build a [`TSPropertySignature`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_property_signature`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + /// * `computed` + /// * `optional` + /// * `readonly` + /// * `key` + /// * `type_annotation` + #[inline] + pub fn ts_property_signature( + self, + span: Span, + computed: bool, + optional: bool, + readonly: bool, + key: PropertyKey<'a>, + type_annotation: T1, + ) -> TSPropertySignature<'a> + where + T1: IntoIn<'a, Option>>>, + { + TSPropertySignature { + span, + computed, + optional, + readonly, + key, + type_annotation: type_annotation.into_in(self.allocator), + } + } + + /// Build a [`TSPropertySignature`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_property_signature`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + /// * `computed` + /// * `optional` + /// * `readonly` + /// * `key` + /// * `type_annotation` + #[inline] + pub fn alloc_ts_property_signature( + self, + span: Span, + computed: bool, + optional: bool, + readonly: bool, + key: PropertyKey<'a>, + type_annotation: T1, + ) -> Box<'a, TSPropertySignature<'a>> + where + T1: IntoIn<'a, Option>>>, + { + Box::new_in( + self.ts_property_signature(span, computed, optional, readonly, key, type_annotation), + self.allocator, + ) } - /// Build a [`TSImportAttribute`]. + /// Build a [`TSSignature::TSIndexSignature`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_attribute`] instead. + /// This node contains a [`TSIndexSignature`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name` - /// * `value` + /// * `parameters` + /// * `type_annotation` + /// * `readonly` + /// * `static` #[inline] - pub fn ts_import_attribute( + pub fn ts_signature_index_signature( self, span: Span, - name: TSImportAttributeName<'a>, - value: Expression<'a>, - ) -> TSImportAttribute<'a> { - TSImportAttribute { span, name, value } + parameters: Vec<'a, TSIndexSignatureName<'a>>, + type_annotation: T1, + readonly: bool, + r#static: bool, + ) -> TSSignature<'a> + where + T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + TSSignature::TSIndexSignature(self.alloc_ts_index_signature( + span, + parameters, + type_annotation, + readonly, + r#static, + )) } - /// Build a [`TSImportAttribute`], and store it in the memory arena. + /// Build a [`TSSignature::TSPropertySignature`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_attribute`] instead. + /// This node contains a [`TSPropertySignature`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name` - /// * `value` + /// * `computed` + /// * `optional` + /// * `readonly` + /// * `key` + /// * `type_annotation` #[inline] - pub fn alloc_ts_import_attribute( + pub fn ts_signature_property_signature( self, span: Span, - name: TSImportAttributeName<'a>, - value: Expression<'a>, - ) -> Box<'a, TSImportAttribute<'a>> { - Box::new_in(self.ts_import_attribute(span, name, value), self.allocator) + computed: bool, + optional: bool, + readonly: bool, + key: PropertyKey<'a>, + type_annotation: T1, + ) -> TSSignature<'a> + where + T1: IntoIn<'a, Option>>>, + { + TSSignature::TSPropertySignature(self.alloc_ts_property_signature( + span, + computed, + optional, + readonly, + key, + type_annotation, + )) } - /// Build a [`TSImportAttributeName::Identifier`]. + /// Build a [`TSSignature::TSCallSignatureDeclaration`]. + /// + /// This node contains a [`TSCallSignatureDeclaration`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name` + /// * `type_parameters` + /// * `this_param` + /// * `params` + /// * `return_type` #[inline] - pub fn ts_import_attribute_name_identifier_name( + pub fn ts_signature_call_signature_declaration( self, span: Span, - name: A, - ) -> TSImportAttributeName<'a> + type_parameters: T1, + this_param: Option>, + params: T2, + return_type: T3, + ) -> TSSignature<'a> where - A: IntoIn<'a, Atom<'a>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Option>>>, { - TSImportAttributeName::Identifier(self.identifier_name(span, name)) + TSSignature::TSCallSignatureDeclaration(self.alloc_ts_call_signature_declaration( + span, + type_parameters, + this_param, + params, + return_type, + )) } - /// Build a [`TSImportAttributeName::StringLiteral`]. + /// Build a [`TSSignature::TSConstructSignatureDeclaration`]. + /// + /// This node contains a [`TSConstructSignatureDeclaration`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The value of the string. - /// * `raw`: The raw string as it appears in source code. + /// * `span`: The [`Span`] covering this node + /// * `type_parameters` + /// * `params` + /// * `return_type` #[inline] - pub fn ts_import_attribute_name_string_literal( + pub fn ts_signature_construct_signature_declaration( self, span: Span, - value: A, - raw: Option>, - ) -> TSImportAttributeName<'a> + type_parameters: T1, + params: T2, + return_type: T3, + ) -> TSSignature<'a> where - A: IntoIn<'a, Atom<'a>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Option>>>, { - TSImportAttributeName::StringLiteral(self.string_literal(span, value, raw)) + TSSignature::TSConstructSignatureDeclaration(self.alloc_ts_construct_signature_declaration( + span, + type_parameters, + params, + return_type, + )) } - /// Build a [`TSFunctionType`]. + /// Build a [`TSSignature::TSMethodSignature`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_function_type`] instead. + /// This node contains a [`TSMethodSignature`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters`: Generic type parameters - /// * `this_param`: `this` parameter - /// * `params`: Function parameters. Akin to [`Function::params`]. - /// * `return_type`: Return type of the function. + /// * `key` + /// * `computed` + /// * `optional` + /// * `kind` + /// * `type_parameters` + /// * `this_param` + /// * `params` + /// * `return_type` #[inline] - pub fn ts_function_type( + pub fn ts_signature_method_signature( self, span: Span, + key: PropertyKey<'a>, + computed: bool, + optional: bool, + kind: TSMethodSignatureKind, type_parameters: T1, this_param: T2, params: T3, return_type: T4, - ) -> TSFunctionType<'a> + ) -> TSSignature<'a> where T1: IntoIn<'a, Option>>>, T2: IntoIn<'a, Option>>>, T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T4: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + T4: IntoIn<'a, Option>>>, { - TSFunctionType { + TSSignature::TSMethodSignature(self.alloc_ts_method_signature( span, - type_parameters: type_parameters.into_in(self.allocator), - this_param: this_param.into_in(self.allocator), - params: params.into_in(self.allocator), - return_type: return_type.into_in(self.allocator), + key, + computed, + optional, + kind, + type_parameters, + this_param, + params, + return_type, + )) + } + + /// Build a [`TSIndexSignature`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_index_signature`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + /// * `parameters` + /// * `type_annotation` + /// * `readonly` + /// * `static` + #[inline] + pub fn ts_index_signature( + self, + span: Span, + parameters: Vec<'a, TSIndexSignatureName<'a>>, + type_annotation: T1, + readonly: bool, + r#static: bool, + ) -> TSIndexSignature<'a> + where + T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + TSIndexSignature { + span, + parameters, + type_annotation: type_annotation.into_in(self.allocator), + readonly, + r#static, } } - /// Build a [`TSFunctionType`], and store it in the memory arena. + /// Build a [`TSIndexSignature`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_function_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_index_signature`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameters`: Generic type parameters - /// * `this_param`: `this` parameter - /// * `params`: Function parameters. Akin to [`Function::params`]. - /// * `return_type`: Return type of the function. + /// * `parameters` + /// * `type_annotation` + /// * `readonly` + /// * `static` #[inline] - pub fn alloc_ts_function_type( + pub fn alloc_ts_index_signature( self, span: Span, - type_parameters: T1, - this_param: T2, - params: T3, - return_type: T4, - ) -> Box<'a, TSFunctionType<'a>> + parameters: Vec<'a, TSIndexSignatureName<'a>>, + type_annotation: T1, + readonly: bool, + r#static: bool, + ) -> Box<'a, TSIndexSignature<'a>> where - T1: IntoIn<'a, Option>>>, - T2: IntoIn<'a, Option>>>, - T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T4: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, { Box::new_in( - self.ts_function_type(span, type_parameters, this_param, params, return_type), + self.ts_index_signature(span, parameters, type_annotation, readonly, r#static), self.allocator, ) } - /// Build a [`TSConstructorType`]. + /// Build a [`TSCallSignatureDeclaration`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_constructor_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_call_signature_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `abstract` /// * `type_parameters` + /// * `this_param` /// * `params` /// * `return_type` #[inline] - pub fn ts_constructor_type( + pub fn ts_call_signature_declaration( self, span: Span, - r#abstract: bool, type_parameters: T1, + this_param: Option>, params: T2, return_type: T3, - ) -> TSConstructorType<'a> + ) -> TSCallSignatureDeclaration<'a> where T1: IntoIn<'a, Option>>>, T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + T3: IntoIn<'a, Option>>>, { - TSConstructorType { + TSCallSignatureDeclaration { span, - r#abstract, type_parameters: type_parameters.into_in(self.allocator), + this_param, params: params.into_in(self.allocator), return_type: return_type.into_in(self.allocator), } } - /// Build a [`TSConstructorType`], and store it in the memory arena. + /// Build a [`TSCallSignatureDeclaration`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_constructor_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_call_signature_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `abstract` /// * `type_parameters` + /// * `this_param` /// * `params` /// * `return_type` #[inline] - pub fn alloc_ts_constructor_type( + pub fn alloc_ts_call_signature_declaration( self, span: Span, - r#abstract: bool, type_parameters: T1, + this_param: Option>, params: T2, return_type: T3, - ) -> Box<'a, TSConstructorType<'a>> + ) -> Box<'a, TSCallSignatureDeclaration<'a>> where T1: IntoIn<'a, Option>>>, T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, - T3: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + T3: IntoIn<'a, Option>>>, { Box::new_in( - self.ts_constructor_type(span, r#abstract, type_parameters, params, return_type), + self.ts_call_signature_declaration( + span, + type_parameters, + this_param, + params, + return_type, + ), self.allocator, ) } - /// Build a [`TSMappedType`]. + /// Build a [`TSMethodSignature`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_mapped_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_method_signature`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. - /// * `name_type` - /// * `type_annotation` - /// * `optional`: Optional modifier on type annotation - /// * `readonly`: Readonly modifier before keyed index signature + /// * `key` + /// * `computed` + /// * `optional` + /// * `kind` + /// * `type_parameters` + /// * `this_param` + /// * `params` + /// * `return_type` #[inline] - pub fn ts_mapped_type( + pub fn ts_method_signature( self, span: Span, - type_parameter: T1, - name_type: Option>, - type_annotation: Option>, - optional: TSMappedTypeModifierOperator, - readonly: TSMappedTypeModifierOperator, - ) -> TSMappedType<'a> + key: PropertyKey<'a>, + computed: bool, + optional: bool, + kind: TSMethodSignatureKind, + type_parameters: T1, + this_param: T2, + params: T3, + return_type: T4, + ) -> TSMethodSignature<'a> where - T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T4: IntoIn<'a, Option>>>, { - TSMappedType { + TSMethodSignature { span, - type_parameter: type_parameter.into_in(self.allocator), - name_type, - type_annotation, + key, + computed, optional, - readonly, + kind, + type_parameters: type_parameters.into_in(self.allocator), + this_param: this_param.into_in(self.allocator), + params: params.into_in(self.allocator), + return_type: return_type.into_in(self.allocator), scope_id: Default::default(), } } - /// Build a [`TSMappedType`], and store it in the memory arena. + /// Build a [`TSMethodSignature`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_mapped_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_method_signature`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. - /// * `name_type` - /// * `type_annotation` - /// * `optional`: Optional modifier on type annotation - /// * `readonly`: Readonly modifier before keyed index signature + /// * `key` + /// * `computed` + /// * `optional` + /// * `kind` + /// * `type_parameters` + /// * `this_param` + /// * `params` + /// * `return_type` #[inline] - pub fn alloc_ts_mapped_type( + pub fn alloc_ts_method_signature( self, span: Span, - type_parameter: T1, - name_type: Option>, - type_annotation: Option>, - optional: TSMappedTypeModifierOperator, - readonly: TSMappedTypeModifierOperator, - ) -> Box<'a, TSMappedType<'a>> + key: PropertyKey<'a>, + computed: bool, + optional: bool, + kind: TSMethodSignatureKind, + type_parameters: T1, + this_param: T2, + params: T3, + return_type: T4, + ) -> Box<'a, TSMethodSignature<'a>> where - T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T4: IntoIn<'a, Option>>>, { Box::new_in( - self.ts_mapped_type( + self.ts_method_signature( span, - type_parameter, - name_type, - type_annotation, + key, + computed, optional, - readonly, + kind, + type_parameters, + this_param, + params, + return_type, ), self.allocator, ) } - /// Build a [`TSMappedType`] with `ScopeId`. + /// Build a [`TSMethodSignature`] with `ScopeId`. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_mapped_type_with_scope_id`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_method_signature_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. - /// * `name_type` - /// * `type_annotation` - /// * `optional`: Optional modifier on type annotation - /// * `readonly`: Readonly modifier before keyed index signature + /// * `key` + /// * `computed` + /// * `optional` + /// * `kind` + /// * `type_parameters` + /// * `this_param` + /// * `params` + /// * `return_type` /// * `scope_id` #[inline] - pub fn ts_mapped_type_with_scope_id( + pub fn ts_method_signature_with_scope_id( self, span: Span, - type_parameter: T1, - name_type: Option>, - type_annotation: Option>, - optional: TSMappedTypeModifierOperator, - readonly: TSMappedTypeModifierOperator, + key: PropertyKey<'a>, + computed: bool, + optional: bool, + kind: TSMethodSignatureKind, + type_parameters: T1, + this_param: T2, + params: T3, + return_type: T4, scope_id: ScopeId, - ) -> TSMappedType<'a> + ) -> TSMethodSignature<'a> where - T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T4: IntoIn<'a, Option>>>, { - TSMappedType { + TSMethodSignature { span, - type_parameter: type_parameter.into_in(self.allocator), - name_type, - type_annotation, + key, + computed, optional, - readonly, + kind, + type_parameters: type_parameters.into_in(self.allocator), + this_param: this_param.into_in(self.allocator), + params: params.into_in(self.allocator), + return_type: return_type.into_in(self.allocator), scope_id: Cell::new(Some(scope_id)), } } - /// Build a [`TSMappedType`] with `ScopeId`, and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_mapped_type_with_scope_id`] instead. - /// - /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. - /// * `name_type` - /// * `type_annotation` - /// * `optional`: Optional modifier on type annotation - /// * `readonly`: Readonly modifier before keyed index signature - /// * `scope_id` - #[inline] - pub fn alloc_ts_mapped_type_with_scope_id( - self, - span: Span, - type_parameter: T1, - name_type: Option>, - type_annotation: Option>, - optional: TSMappedTypeModifierOperator, - readonly: TSMappedTypeModifierOperator, - scope_id: ScopeId, - ) -> Box<'a, TSMappedType<'a>> - where - T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, - { - Box::new_in( - self.ts_mapped_type_with_scope_id( - span, - type_parameter, - name_type, - type_annotation, - optional, - readonly, - scope_id, - ), - self.allocator, - ) - } - - /// Build a [`TSTemplateLiteralType`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_template_literal_type`] instead. - /// - /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `quasis`: The string parts of the template literal. - /// * `types`: The interpolated expressions in the template literal. - #[inline] - pub fn ts_template_literal_type( - self, - span: Span, - quasis: Vec<'a, TemplateElement<'a>>, - types: Vec<'a, TSType<'a>>, - ) -> TSTemplateLiteralType<'a> { - TSTemplateLiteralType { span, quasis, types } - } - - /// Build a [`TSTemplateLiteralType`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_template_literal_type`] instead. - /// - /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `quasis`: The string parts of the template literal. - /// * `types`: The interpolated expressions in the template literal. - #[inline] - pub fn alloc_ts_template_literal_type( - self, - span: Span, - quasis: Vec<'a, TemplateElement<'a>>, - types: Vec<'a, TSType<'a>>, - ) -> Box<'a, TSTemplateLiteralType<'a>> { - Box::new_in(self.ts_template_literal_type(span, quasis, types), self.allocator) - } - - /// Build a [`TSAsExpression`]. + /// Build a [`TSMethodSignature`] with `ScopeId`, and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_as_expression`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_method_signature_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_annotation` + /// * `key` + /// * `computed` + /// * `optional` + /// * `kind` + /// * `type_parameters` + /// * `this_param` + /// * `params` + /// * `return_type` + /// * `scope_id` #[inline] - pub fn ts_as_expression( + pub fn alloc_ts_method_signature_with_scope_id( self, span: Span, - expression: Expression<'a>, - type_annotation: TSType<'a>, - ) -> TSAsExpression<'a> { - TSAsExpression { span, expression, type_annotation } + key: PropertyKey<'a>, + computed: bool, + optional: bool, + kind: TSMethodSignatureKind, + type_parameters: T1, + this_param: T2, + params: T3, + return_type: T4, + scope_id: ScopeId, + ) -> Box<'a, TSMethodSignature<'a>> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T4: IntoIn<'a, Option>>>, + { + Box::new_in( + self.ts_method_signature_with_scope_id( + span, + key, + computed, + optional, + kind, + type_parameters, + this_param, + params, + return_type, + scope_id, + ), + self.allocator, + ) } - /// Build a [`TSAsExpression`], and store it in the memory arena. + /// Build a [`TSConstructSignatureDeclaration`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_as_expression`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_construct_signature_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_annotation` + /// * `type_parameters` + /// * `params` + /// * `return_type` #[inline] - pub fn alloc_ts_as_expression( + pub fn ts_construct_signature_declaration( self, span: Span, - expression: Expression<'a>, - type_annotation: TSType<'a>, - ) -> Box<'a, TSAsExpression<'a>> { - Box::new_in(self.ts_as_expression(span, expression, type_annotation), self.allocator) + type_parameters: T1, + params: T2, + return_type: T3, + ) -> TSConstructSignatureDeclaration<'a> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Option>>>, + { + TSConstructSignatureDeclaration { + span, + type_parameters: type_parameters.into_in(self.allocator), + params: params.into_in(self.allocator), + return_type: return_type.into_in(self.allocator), + scope_id: Default::default(), + } } - /// Build a [`TSSatisfiesExpression`]. + /// Build a [`TSConstructSignatureDeclaration`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_satisfies_expression`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_construct_signature_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression`: The value expression being constrained. - /// * `type_annotation`: The type `expression` must satisfy. + /// * `type_parameters` + /// * `params` + /// * `return_type` #[inline] - pub fn ts_satisfies_expression( + pub fn alloc_ts_construct_signature_declaration( self, span: Span, - expression: Expression<'a>, - type_annotation: TSType<'a>, - ) -> TSSatisfiesExpression<'a> { - TSSatisfiesExpression { span, expression, type_annotation } + type_parameters: T1, + params: T2, + return_type: T3, + ) -> Box<'a, TSConstructSignatureDeclaration<'a>> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Option>>>, + { + Box::new_in( + self.ts_construct_signature_declaration(span, type_parameters, params, return_type), + self.allocator, + ) } - /// Build a [`TSSatisfiesExpression`], and store it in the memory arena. + /// Build a [`TSConstructSignatureDeclaration`] with `ScopeId`. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_satisfies_expression`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_construct_signature_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression`: The value expression being constrained. - /// * `type_annotation`: The type `expression` must satisfy. + /// * `type_parameters` + /// * `params` + /// * `return_type` + /// * `scope_id` #[inline] - pub fn alloc_ts_satisfies_expression( + pub fn ts_construct_signature_declaration_with_scope_id( self, span: Span, - expression: Expression<'a>, - type_annotation: TSType<'a>, - ) -> Box<'a, TSSatisfiesExpression<'a>> { - Box::new_in(self.ts_satisfies_expression(span, expression, type_annotation), self.allocator) + type_parameters: T1, + params: T2, + return_type: T3, + scope_id: ScopeId, + ) -> TSConstructSignatureDeclaration<'a> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Option>>>, + { + TSConstructSignatureDeclaration { + span, + type_parameters: type_parameters.into_in(self.allocator), + params: params.into_in(self.allocator), + return_type: return_type.into_in(self.allocator), + scope_id: Cell::new(Some(scope_id)), + } } - /// Build a [`TSTypeAssertion`]. + /// Build a [`TSConstructSignatureDeclaration`] with `ScopeId`, and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_assertion`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_construct_signature_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_annotation` + /// * `type_parameters` + /// * `params` + /// * `return_type` + /// * `scope_id` #[inline] - pub fn ts_type_assertion( + pub fn alloc_ts_construct_signature_declaration_with_scope_id( self, span: Span, - expression: Expression<'a>, - type_annotation: TSType<'a>, - ) -> TSTypeAssertion<'a> { - TSTypeAssertion { span, expression, type_annotation } + type_parameters: T1, + params: T2, + return_type: T3, + scope_id: ScopeId, + ) -> Box<'a, TSConstructSignatureDeclaration<'a>> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Option>>>, + { + Box::new_in( + self.ts_construct_signature_declaration_with_scope_id( + span, + type_parameters, + params, + return_type, + scope_id, + ), + self.allocator, + ) } - /// Build a [`TSTypeAssertion`], and store it in the memory arena. + /// Build a [`TSIndexSignatureName`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_assertion`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_index_signature_name`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` + /// * `name` /// * `type_annotation` #[inline] - pub fn alloc_ts_type_assertion( + pub fn ts_index_signature_name( self, span: Span, - expression: Expression<'a>, - type_annotation: TSType<'a>, - ) -> Box<'a, TSTypeAssertion<'a>> { - Box::new_in(self.ts_type_assertion(span, expression, type_annotation), self.allocator) + name: A, + type_annotation: T1, + ) -> TSIndexSignatureName<'a> + where + A: IntoIn<'a, Atom<'a>>, + T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + TSIndexSignatureName { + span, + name: name.into_in(self.allocator), + type_annotation: type_annotation.into_in(self.allocator), + } } - /// Build a [`TSImportEqualsDeclaration`]. + /// Build a [`TSIndexSignatureName`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_equals_declaration`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_index_signature_name`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id` - /// * `module_reference` - /// * `import_kind` + /// * `name` + /// * `type_annotation` #[inline] - pub fn ts_import_equals_declaration( + pub fn alloc_ts_index_signature_name( self, span: Span, - id: BindingIdentifier<'a>, - module_reference: TSModuleReference<'a>, - import_kind: ImportOrExportKind, - ) -> TSImportEqualsDeclaration<'a> { - TSImportEqualsDeclaration { span, id, module_reference, import_kind } + name: A, + type_annotation: T1, + ) -> Box<'a, TSIndexSignatureName<'a>> + where + A: IntoIn<'a, Atom<'a>>, + T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + Box::new_in(self.ts_index_signature_name(span, name, type_annotation), self.allocator) } - /// Build a [`TSImportEqualsDeclaration`], and store it in the memory arena. + /// Build a [`TSInterfaceHeritage`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_equals_declaration`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_interface_heritage`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id` - /// * `module_reference` - /// * `import_kind` + /// * `expression` + /// * `type_parameters` #[inline] - pub fn alloc_ts_import_equals_declaration( + pub fn ts_interface_heritage( self, span: Span, - id: BindingIdentifier<'a>, - module_reference: TSModuleReference<'a>, - import_kind: ImportOrExportKind, - ) -> Box<'a, TSImportEqualsDeclaration<'a>> { - Box::new_in( - self.ts_import_equals_declaration(span, id, module_reference, import_kind), - self.allocator, - ) + expression: Expression<'a>, + type_parameters: T1, + ) -> TSInterfaceHeritage<'a> + where + T1: IntoIn<'a, Option>>>, + { + TSInterfaceHeritage { + span, + expression, + type_parameters: type_parameters.into_in(self.allocator), + } } - /// Build a [`TSModuleReference::ExternalModuleReference`]. + /// Build a [`TSInterfaceHeritage`], and store it in the memory arena. /// - /// This node contains a [`TSExternalModuleReference`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_interface_heritage`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node /// * `expression` + /// * `type_parameters` #[inline] - pub fn ts_module_reference_external_module_reference( + pub fn alloc_ts_interface_heritage( self, span: Span, - expression: StringLiteral<'a>, - ) -> TSModuleReference<'a> { - TSModuleReference::ExternalModuleReference( - self.alloc_ts_external_module_reference(span, expression), - ) + expression: Expression<'a>, + type_parameters: T1, + ) -> Box<'a, TSInterfaceHeritage<'a>> + where + T1: IntoIn<'a, Option>>>, + { + Box::new_in(self.ts_interface_heritage(span, expression, type_parameters), self.allocator) } - /// Build a [`TSExternalModuleReference`]. + /// Build a [`TSTypePredicate`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_external_module_reference`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_predicate`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` + /// * `parameter_name`: The identifier the predicate operates on + /// * `asserts`: Does this predicate include an `asserts` modifier? + /// * `type_annotation` #[inline] - pub fn ts_external_module_reference( + pub fn ts_type_predicate( self, span: Span, - expression: StringLiteral<'a>, - ) -> TSExternalModuleReference<'a> { - TSExternalModuleReference { span, expression } + parameter_name: TSTypePredicateName<'a>, + asserts: bool, + type_annotation: T1, + ) -> TSTypePredicate<'a> + where + T1: IntoIn<'a, Option>>>, + { + TSTypePredicate { + span, + parameter_name, + asserts, + type_annotation: type_annotation.into_in(self.allocator), + } } - /// Build a [`TSExternalModuleReference`], and store it in the memory arena. + /// Build a [`TSTypePredicate`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_external_module_reference`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_predicate`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` + /// * `parameter_name`: The identifier the predicate operates on + /// * `asserts`: Does this predicate include an `asserts` modifier? + /// * `type_annotation` #[inline] - pub fn alloc_ts_external_module_reference( + pub fn alloc_ts_type_predicate( self, span: Span, - expression: StringLiteral<'a>, - ) -> Box<'a, TSExternalModuleReference<'a>> { - Box::new_in(self.ts_external_module_reference(span, expression), self.allocator) + parameter_name: TSTypePredicateName<'a>, + asserts: bool, + type_annotation: T1, + ) -> Box<'a, TSTypePredicate<'a>> + where + T1: IntoIn<'a, Option>>>, + { + Box::new_in( + self.ts_type_predicate(span, parameter_name, asserts, type_annotation), + self.allocator, + ) } - /// Build a [`TSNonNullExpression`]. + /// Build a [`TSTypePredicateName::Identifier`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_non_null_expression`] instead. + /// This node contains an [`IdentifierName`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` + /// * `name` #[inline] - pub fn ts_non_null_expression( + pub fn ts_type_predicate_name_identifier_name( self, span: Span, - expression: Expression<'a>, - ) -> TSNonNullExpression<'a> { - TSNonNullExpression { span, expression } + name: A, + ) -> TSTypePredicateName<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + TSTypePredicateName::Identifier(self.alloc_identifier_name(span, name)) } - /// Build a [`TSNonNullExpression`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_non_null_expression`] instead. + /// Build a [`TSTypePredicateName::This`]. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` #[inline] - pub fn alloc_ts_non_null_expression( - self, - span: Span, - expression: Expression<'a>, - ) -> Box<'a, TSNonNullExpression<'a>> { - Box::new_in(self.ts_non_null_expression(span, expression), self.allocator) + pub fn ts_type_predicate_name_this_type(self, span: Span) -> TSTypePredicateName<'a> { + TSTypePredicateName::This(self.ts_this_type(span)) } - /// Build a [`Decorator`]. + /// Build a [`TSModuleDeclaration`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_decorator`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_module_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` + /// * `id`: The name of the module/namespace being declared. + /// * `body` + /// * `kind`: The keyword used to define this module declaration. + /// * `declare` #[inline] - pub fn decorator(self, span: Span, expression: Expression<'a>) -> Decorator<'a> { - Decorator { span, expression } + pub fn ts_module_declaration( + self, + span: Span, + id: TSModuleDeclarationName<'a>, + body: Option>, + kind: TSModuleDeclarationKind, + declare: bool, + ) -> TSModuleDeclaration<'a> { + TSModuleDeclaration { span, id, body, kind, declare, scope_id: Default::default() } } - /// Build a [`Decorator`], and store it in the memory arena. + /// Build a [`TSModuleDeclaration`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::decorator`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_module_declaration`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` + /// * `id`: The name of the module/namespace being declared. + /// * `body` + /// * `kind`: The keyword used to define this module declaration. + /// * `declare` #[inline] - pub fn alloc_decorator(self, span: Span, expression: Expression<'a>) -> Box<'a, Decorator<'a>> { - Box::new_in(self.decorator(span, expression), self.allocator) + pub fn alloc_ts_module_declaration( + self, + span: Span, + id: TSModuleDeclarationName<'a>, + body: Option>, + kind: TSModuleDeclarationKind, + declare: bool, + ) -> Box<'a, TSModuleDeclaration<'a>> { + Box::new_in(self.ts_module_declaration(span, id, body, kind, declare), self.allocator) } - /// Build a [`TSExportAssignment`]. + /// Build a [`TSModuleDeclaration`] with `ScopeId`. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_export_assignment`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_module_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` + /// * `id`: The name of the module/namespace being declared. + /// * `body` + /// * `kind`: The keyword used to define this module declaration. + /// * `declare` + /// * `scope_id` #[inline] - pub fn ts_export_assignment( + pub fn ts_module_declaration_with_scope_id( self, span: Span, - expression: Expression<'a>, - ) -> TSExportAssignment<'a> { - TSExportAssignment { span, expression } + id: TSModuleDeclarationName<'a>, + body: Option>, + kind: TSModuleDeclarationKind, + declare: bool, + scope_id: ScopeId, + ) -> TSModuleDeclaration<'a> { + TSModuleDeclaration { span, id, body, kind, declare, scope_id: Cell::new(Some(scope_id)) } } - /// Build a [`TSExportAssignment`], and store it in the memory arena. + /// Build a [`TSModuleDeclaration`] with `ScopeId`, and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_export_assignment`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_module_declaration_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` + /// * `id`: The name of the module/namespace being declared. + /// * `body` + /// * `kind`: The keyword used to define this module declaration. + /// * `declare` + /// * `scope_id` #[inline] - pub fn alloc_ts_export_assignment( + pub fn alloc_ts_module_declaration_with_scope_id( self, span: Span, - expression: Expression<'a>, - ) -> Box<'a, TSExportAssignment<'a>> { - Box::new_in(self.ts_export_assignment(span, expression), self.allocator) + id: TSModuleDeclarationName<'a>, + body: Option>, + kind: TSModuleDeclarationKind, + declare: bool, + scope_id: ScopeId, + ) -> Box<'a, TSModuleDeclaration<'a>> { + Box::new_in( + self.ts_module_declaration_with_scope_id(span, id, body, kind, declare, scope_id), + self.allocator, + ) } - /// Build a [`TSNamespaceExportDeclaration`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_namespace_export_declaration`] instead. + /// Build a [`TSModuleDeclarationName::Identifier`]. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `id` + /// * `name`: The identifier name being bound. #[inline] - pub fn ts_namespace_export_declaration( + pub fn ts_module_declaration_name_binding_identifier( self, span: Span, - id: IdentifierName<'a>, - ) -> TSNamespaceExportDeclaration<'a> { - TSNamespaceExportDeclaration { span, id } + name: A, + ) -> TSModuleDeclarationName<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + TSModuleDeclarationName::Identifier(self.binding_identifier(span, name)) } - /// Build a [`TSNamespaceExportDeclaration`], and store it in the memory arena. - /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_namespace_export_declaration`] instead. + /// Build a [`TSModuleDeclarationName::StringLiteral`]. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `id` + /// * `span`: Node location in source code + /// * `value`: The value of the string. + /// * `raw`: The raw string as it appears in source code. #[inline] - pub fn alloc_ts_namespace_export_declaration( + pub fn ts_module_declaration_name_string_literal( self, span: Span, - id: IdentifierName<'a>, - ) -> Box<'a, TSNamespaceExportDeclaration<'a>> { - Box::new_in(self.ts_namespace_export_declaration(span, id), self.allocator) + value: A, + raw: Option>, + ) -> TSModuleDeclarationName<'a> + where + A: IntoIn<'a, Atom<'a>>, + { + TSModuleDeclarationName::StringLiteral(self.string_literal(span, value, raw)) } - /// Build a [`TSInstantiationExpression`]. + /// Build a [`TSModuleDeclarationBody::TSModuleDeclaration`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_instantiation_expression`] instead. + /// This node contains a [`TSModuleDeclaration`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_parameters` + /// * `id`: The name of the module/namespace being declared. + /// * `body` + /// * `kind`: The keyword used to define this module declaration. + /// * `declare` #[inline] - pub fn ts_instantiation_expression( + pub fn ts_module_declaration_body_module_declaration( self, span: Span, - expression: Expression<'a>, - type_parameters: T1, - ) -> TSInstantiationExpression<'a> - where - T1: IntoIn<'a, Box<'a, TSTypeParameterInstantiation<'a>>>, - { - TSInstantiationExpression { - span, - expression, - type_parameters: type_parameters.into_in(self.allocator), - } + id: TSModuleDeclarationName<'a>, + body: Option>, + kind: TSModuleDeclarationKind, + declare: bool, + ) -> TSModuleDeclarationBody<'a> { + TSModuleDeclarationBody::TSModuleDeclaration( + self.alloc_ts_module_declaration(span, id, body, kind, declare), + ) } - /// Build a [`TSInstantiationExpression`], and store it in the memory arena. + /// Build a [`TSModuleDeclarationBody::TSModuleBlock`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_instantiation_expression`] instead. + /// This node contains a [`TSModuleBlock`] that will be stored in the memory arena. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `expression` - /// * `type_parameters` + /// * `directives` + /// * `body` #[inline] - pub fn alloc_ts_instantiation_expression( + pub fn ts_module_declaration_body_module_block( self, span: Span, - expression: Expression<'a>, - type_parameters: T1, - ) -> Box<'a, TSInstantiationExpression<'a>> - where - T1: IntoIn<'a, Box<'a, TSTypeParameterInstantiation<'a>>>, - { - Box::new_in( - self.ts_instantiation_expression(span, expression, type_parameters), - self.allocator, - ) + directives: Vec<'a, Directive<'a>>, + body: Vec<'a, Statement<'a>>, + ) -> TSModuleDeclarationBody<'a> { + TSModuleDeclarationBody::TSModuleBlock(self.alloc_ts_module_block(span, directives, body)) } - /// Build a [`JSDocNullableType`]. + /// Build a [`TSModuleBlock`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_js_doc_nullable_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_module_block`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` - /// * `postfix`: Was `?` after the type annotation? + /// * `directives` + /// * `body` #[inline] - pub fn js_doc_nullable_type( + pub fn ts_module_block( self, span: Span, - type_annotation: TSType<'a>, - postfix: bool, - ) -> JSDocNullableType<'a> { - JSDocNullableType { span, type_annotation, postfix } + directives: Vec<'a, Directive<'a>>, + body: Vec<'a, Statement<'a>>, + ) -> TSModuleBlock<'a> { + TSModuleBlock { span, directives, body } } - /// Build a [`JSDocNullableType`], and store it in the memory arena. + /// Build a [`TSModuleBlock`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::js_doc_nullable_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_module_block`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` - /// * `postfix`: Was `?` after the type annotation? + /// * `directives` + /// * `body` #[inline] - pub fn alloc_js_doc_nullable_type( + pub fn alloc_ts_module_block( self, span: Span, - type_annotation: TSType<'a>, - postfix: bool, - ) -> Box<'a, JSDocNullableType<'a>> { - Box::new_in(self.js_doc_nullable_type(span, type_annotation, postfix), self.allocator) + directives: Vec<'a, Directive<'a>>, + body: Vec<'a, Statement<'a>>, + ) -> Box<'a, TSModuleBlock<'a>> { + Box::new_in(self.ts_module_block(span, directives, body), self.allocator) } - /// Build a [`JSDocNonNullableType`]. + /// Build a [`TSTypeLiteral`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_js_doc_non_nullable_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_literal`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` - /// * `postfix` + /// * `members` #[inline] - pub fn js_doc_non_nullable_type( + pub fn ts_type_literal( self, span: Span, - type_annotation: TSType<'a>, - postfix: bool, - ) -> JSDocNonNullableType<'a> { - JSDocNonNullableType { span, type_annotation, postfix } + members: Vec<'a, TSSignature<'a>>, + ) -> TSTypeLiteral<'a> { + TSTypeLiteral { span, members } } - /// Build a [`JSDocNonNullableType`], and store it in the memory arena. + /// Build a [`TSTypeLiteral`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::js_doc_non_nullable_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_literal`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `type_annotation` - /// * `postfix` + /// * `members` #[inline] - pub fn alloc_js_doc_non_nullable_type( + pub fn alloc_ts_type_literal( self, span: Span, - type_annotation: TSType<'a>, - postfix: bool, - ) -> Box<'a, JSDocNonNullableType<'a>> { - Box::new_in(self.js_doc_non_nullable_type(span, type_annotation, postfix), self.allocator) + members: Vec<'a, TSSignature<'a>>, + ) -> Box<'a, TSTypeLiteral<'a>> { + Box::new_in(self.ts_type_literal(span, members), self.allocator) } - /// Build a [`JSDocUnknownType`]. + /// Build a [`TSInferType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_js_doc_unknown_type`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_infer_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `type_parameter`: The type bound when the #[inline] - pub fn js_doc_unknown_type(self, span: Span) -> JSDocUnknownType { - JSDocUnknownType { span } + pub fn ts_infer_type(self, span: Span, type_parameter: T1) -> TSInferType<'a> + where + T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + { + TSInferType { span, type_parameter: type_parameter.into_in(self.allocator) } } - /// Build a [`JSDocUnknownType`], and store it in the memory arena. + /// Build a [`TSInferType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::js_doc_unknown_type`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_infer_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `type_parameter`: The type bound when the #[inline] - pub fn alloc_js_doc_unknown_type(self, span: Span) -> Box<'a, JSDocUnknownType> { - Box::new_in(self.js_doc_unknown_type(span), self.allocator) + pub fn alloc_ts_infer_type(self, span: Span, type_parameter: T1) -> Box<'a, TSInferType<'a>> + where + T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + { + Box::new_in(self.ts_infer_type(span, type_parameter), self.allocator) } - /// Build a [`JSXElement`]. + /// Build a [`TSTypeQuery`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_element`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_query`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `opening_element`: Opening tag of the element. - /// * `closing_element`: Closing tag of the element. Will be [`None`] for self-closing tags. - /// * `children`: Children of the element. This can be text, other elements, or expressions. + /// * `span`: The [`Span`] covering this node + /// * `expr_name` + /// * `type_parameters` #[inline] - pub fn jsx_element( + pub fn ts_type_query( self, span: Span, - opening_element: T1, - closing_element: T2, - children: Vec<'a, JSXChild<'a>>, - ) -> JSXElement<'a> + expr_name: TSTypeQueryExprName<'a>, + type_parameters: T1, + ) -> TSTypeQuery<'a> where - T1: IntoIn<'a, Box<'a, JSXOpeningElement<'a>>>, - T2: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, { - JSXElement { - span, - opening_element: opening_element.into_in(self.allocator), - closing_element: closing_element.into_in(self.allocator), - children, - } + TSTypeQuery { span, expr_name, type_parameters: type_parameters.into_in(self.allocator) } } - /// Build a [`JSXElement`], and store it in the memory arena. + /// Build a [`TSTypeQuery`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_element`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_query`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `opening_element`: Opening tag of the element. - /// * `closing_element`: Closing tag of the element. Will be [`None`] for self-closing tags. - /// * `children`: Children of the element. This can be text, other elements, or expressions. + /// * `span`: The [`Span`] covering this node + /// * `expr_name` + /// * `type_parameters` #[inline] - pub fn alloc_jsx_element( + pub fn alloc_ts_type_query( self, span: Span, - opening_element: T1, - closing_element: T2, - children: Vec<'a, JSXChild<'a>>, - ) -> Box<'a, JSXElement<'a>> + expr_name: TSTypeQueryExprName<'a>, + type_parameters: T1, + ) -> Box<'a, TSTypeQuery<'a>> where - T1: IntoIn<'a, Box<'a, JSXOpeningElement<'a>>>, - T2: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, { - Box::new_in( - self.jsx_element(span, opening_element, closing_element, children), - self.allocator, - ) + Box::new_in(self.ts_type_query(span, expr_name, type_parameters), self.allocator) } - /// Build a [`JSXOpeningElement`]. + /// Build a [`TSTypeQueryExprName::TSImportType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_opening_element`] instead. + /// This node contains a [`TSImportType`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `self_closing`: Is this tag self-closing? - /// * `name`: The possibly-namespaced tag name, e.g. `Foo` in ``. - /// * `attributes`: List of JSX attributes. In React-like applications, these become props. - /// * `type_parameters`: Type parameters for generic JSX elements. + /// * `span`: The [`Span`] covering this node + /// * `is_type_of`: `true` for `typeof import("foo")` + /// * `parameter` + /// * `qualifier` + /// * `attributes` + /// * `type_parameters` #[inline] - pub fn jsx_opening_element( + pub fn ts_type_query_expr_name_import_type( self, span: Span, - self_closing: bool, - name: JSXElementName<'a>, - attributes: Vec<'a, JSXAttributeItem<'a>>, - type_parameters: T1, - ) -> JSXOpeningElement<'a> + is_type_of: bool, + parameter: TSType<'a>, + qualifier: Option>, + attributes: T1, + type_parameters: T2, + ) -> TSTypeQueryExprName<'a> where - T1: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, { - JSXOpeningElement { + TSTypeQueryExprName::TSImportType(self.alloc_ts_import_type( span, - self_closing, - name, + is_type_of, + parameter, + qualifier, attributes, - type_parameters: type_parameters.into_in(self.allocator), - } + type_parameters, + )) } - /// Build a [`JSXOpeningElement`], and store it in the memory arena. + /// Build a [`TSImportType`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_opening_element`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `self_closing`: Is this tag self-closing? - /// * `name`: The possibly-namespaced tag name, e.g. `Foo` in ``. - /// * `attributes`: List of JSX attributes. In React-like applications, these become props. - /// * `type_parameters`: Type parameters for generic JSX elements. + /// * `span`: The [`Span`] covering this node + /// * `is_type_of`: `true` for `typeof import("foo")` + /// * `parameter` + /// * `qualifier` + /// * `attributes` + /// * `type_parameters` + #[inline] + pub fn ts_import_type( + self, + span: Span, + is_type_of: bool, + parameter: TSType<'a>, + qualifier: Option>, + attributes: T1, + type_parameters: T2, + ) -> TSImportType<'a> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + { + TSImportType { + span, + is_type_of, + parameter, + qualifier, + attributes: attributes.into_in(self.allocator), + type_parameters: type_parameters.into_in(self.allocator), + } + } + + /// Build a [`TSImportType`], and store it in the memory arena. + /// + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_type`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + /// * `is_type_of`: `true` for `typeof import("foo")` + /// * `parameter` + /// * `qualifier` + /// * `attributes` + /// * `type_parameters` #[inline] - pub fn alloc_jsx_opening_element( + pub fn alloc_ts_import_type( self, span: Span, - self_closing: bool, - name: JSXElementName<'a>, - attributes: Vec<'a, JSXAttributeItem<'a>>, - type_parameters: T1, - ) -> Box<'a, JSXOpeningElement<'a>> + is_type_of: bool, + parameter: TSType<'a>, + qualifier: Option>, + attributes: T1, + type_parameters: T2, + ) -> Box<'a, TSImportType<'a>> where - T1: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, { Box::new_in( - self.jsx_opening_element(span, self_closing, name, attributes, type_parameters), + self.ts_import_type( + span, + is_type_of, + parameter, + qualifier, + attributes, + type_parameters, + ), self.allocator, ) } - /// Build a [`JSXClosingElement`]. + /// Build a [`TSImportAttributes`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_closing_element`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_attributes`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The tag name, e.g. `Foo` in ``. + /// * `span`: The [`Span`] covering this node + /// * `attributes_keyword` + /// * `elements` #[inline] - pub fn jsx_closing_element( + pub fn ts_import_attributes( self, span: Span, - name: JSXElementName<'a>, - ) -> JSXClosingElement<'a> { - JSXClosingElement { span, name } + attributes_keyword: IdentifierName<'a>, + elements: Vec<'a, TSImportAttribute<'a>>, + ) -> TSImportAttributes<'a> { + TSImportAttributes { span, attributes_keyword, elements } } - /// Build a [`JSXClosingElement`], and store it in the memory arena. + /// Build a [`TSImportAttributes`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_closing_element`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_attributes`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The tag name, e.g. `Foo` in ``. + /// * `span`: The [`Span`] covering this node + /// * `attributes_keyword` + /// * `elements` #[inline] - pub fn alloc_jsx_closing_element( + pub fn alloc_ts_import_attributes( self, span: Span, - name: JSXElementName<'a>, - ) -> Box<'a, JSXClosingElement<'a>> { - Box::new_in(self.jsx_closing_element(span, name), self.allocator) + attributes_keyword: IdentifierName<'a>, + elements: Vec<'a, TSImportAttribute<'a>>, + ) -> Box<'a, TSImportAttributes<'a>> { + Box::new_in(self.ts_import_attributes(span, attributes_keyword, elements), self.allocator) } - /// Build a [`JSXFragment`]. + /// Build a [`TSImportAttribute`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_fragment`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_attribute`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `opening_fragment`: `<>` - /// * `closing_fragment`: `` - /// * `children`: Elements inside the fragment. + /// * `span`: The [`Span`] covering this node + /// * `name` + /// * `value` #[inline] - pub fn jsx_fragment( + pub fn ts_import_attribute( self, span: Span, - opening_fragment: JSXOpeningFragment, - closing_fragment: JSXClosingFragment, - children: Vec<'a, JSXChild<'a>>, - ) -> JSXFragment<'a> { - JSXFragment { span, opening_fragment, closing_fragment, children } + name: TSImportAttributeName<'a>, + value: Expression<'a>, + ) -> TSImportAttribute<'a> { + TSImportAttribute { span, name, value } } - /// Build a [`JSXFragment`], and store it in the memory arena. + /// Build a [`TSImportAttribute`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_fragment`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_attribute`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `opening_fragment`: `<>` - /// * `closing_fragment`: `` - /// * `children`: Elements inside the fragment. + /// * `span`: The [`Span`] covering this node + /// * `name` + /// * `value` #[inline] - pub fn alloc_jsx_fragment( + pub fn alloc_ts_import_attribute( self, span: Span, - opening_fragment: JSXOpeningFragment, - closing_fragment: JSXClosingFragment, - children: Vec<'a, JSXChild<'a>>, - ) -> Box<'a, JSXFragment<'a>> { - Box::new_in( - self.jsx_fragment(span, opening_fragment, closing_fragment, children), - self.allocator, - ) + name: TSImportAttributeName<'a>, + value: Expression<'a>, + ) -> Box<'a, TSImportAttribute<'a>> { + Box::new_in(self.ts_import_attribute(span, name, value), self.allocator) } - /// Build a [`JSXElementName::Identifier`]. - /// - /// This node contains a [`JSXIdentifier`] that will be stored in the memory arena. + /// Build a [`TSImportAttributeName::Identifier`]. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The name of the identifier. + /// * `span`: The [`Span`] covering this node + /// * `name` #[inline] - pub fn jsx_element_name_jsx_identifier(self, span: Span, name: A) -> JSXElementName<'a> + pub fn ts_import_attribute_name_identifier_name( + self, + span: Span, + name: A, + ) -> TSImportAttributeName<'a> where A: IntoIn<'a, Atom<'a>>, { - JSXElementName::Identifier(self.alloc_jsx_identifier(span, name)) + TSImportAttributeName::Identifier(self.identifier_name(span, name)) } - /// Build a [`JSXElementName::IdentifierReference`]. - /// - /// This node contains an [`IdentifierReference`] that will be stored in the memory arena. + /// Build a [`TSImportAttributeName::StringLiteral`]. /// /// ## Parameters - /// * `span`: The [`Span`] covering this node - /// * `name`: The name of the identifier being referenced. + /// * `span`: Node location in source code + /// * `value`: The value of the string. + /// * `raw`: The raw string as it appears in source code. #[inline] - pub fn jsx_element_name_identifier_reference(self, span: Span, name: A) -> JSXElementName<'a> + pub fn ts_import_attribute_name_string_literal( + self, + span: Span, + value: A, + raw: Option>, + ) -> TSImportAttributeName<'a> where A: IntoIn<'a, Atom<'a>>, { - JSXElementName::IdentifierReference(self.alloc_identifier_reference(span, name)) + TSImportAttributeName::StringLiteral(self.string_literal(span, value, raw)) } - /// Build a [`JSXElementName::NamespacedName`]. + /// Build a [`TSFunctionType`]. /// - /// This node contains a [`JSXNamespacedName`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_function_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `namespace`: Namespace portion of the name, e.g. `Apple` in `` - /// * `property`: Name portion of the name, e.g. `Orange` in `` + /// * `span`: The [`Span`] covering this node + /// * `type_parameters`: Generic type parameters + /// * `this_param`: `this` parameter + /// * `params`: Function parameters. Akin to [`Function::params`]. + /// * `return_type`: Return type of the function. #[inline] - pub fn jsx_element_name_jsx_namespaced_name( + pub fn ts_function_type( self, span: Span, - namespace: JSXIdentifier<'a>, - property: JSXIdentifier<'a>, - ) -> JSXElementName<'a> { - JSXElementName::NamespacedName(self.alloc_jsx_namespaced_name(span, namespace, property)) + type_parameters: T1, + this_param: T2, + params: T3, + return_type: T4, + ) -> TSFunctionType<'a> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T4: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + TSFunctionType { + span, + type_parameters: type_parameters.into_in(self.allocator), + this_param: this_param.into_in(self.allocator), + params: params.into_in(self.allocator), + return_type: return_type.into_in(self.allocator), + } } - /// Build a [`JSXElementName::MemberExpression`]. + /// Build a [`TSFunctionType`], and store it in the memory arena. /// - /// This node contains a [`JSXMemberExpression`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_function_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `object`: The object being accessed. This is everything before the last `.`. - /// * `property`: The property being accessed. This is everything after the last `.`. + /// * `span`: The [`Span`] covering this node + /// * `type_parameters`: Generic type parameters + /// * `this_param`: `this` parameter + /// * `params`: Function parameters. Akin to [`Function::params`]. + /// * `return_type`: Return type of the function. #[inline] - pub fn jsx_element_name_jsx_member_expression( + pub fn alloc_ts_function_type( self, span: Span, - object: JSXMemberExpressionObject<'a>, - property: JSXIdentifier<'a>, - ) -> JSXElementName<'a> { - JSXElementName::MemberExpression(self.alloc_jsx_member_expression(span, object, property)) + type_parameters: T1, + this_param: T2, + params: T3, + return_type: T4, + ) -> Box<'a, TSFunctionType<'a>> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Option>>>, + T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T4: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + Box::new_in( + self.ts_function_type(span, type_parameters, this_param, params, return_type), + self.allocator, + ) } - /// Build a [`JSXElementName::ThisExpression`]. + /// Build a [`TSConstructorType`]. /// - /// This node contains a [`ThisExpression`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_constructor_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `abstract` + /// * `type_parameters` + /// * `params` + /// * `return_type` #[inline] - pub fn jsx_element_name_this_expression(self, span: Span) -> JSXElementName<'a> { - JSXElementName::ThisExpression(self.alloc_this_expression(span)) - } - - /// Build a [`JSXNamespacedName`]. - /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_namespaced_name`] instead. - /// - /// ## Parameters - /// * `span`: Node location in source code - /// * `namespace`: Namespace portion of the name, e.g. `Apple` in `` - /// * `property`: Name portion of the name, e.g. `Orange` in `` - #[inline] - pub fn jsx_namespaced_name( + pub fn ts_constructor_type( self, span: Span, - namespace: JSXIdentifier<'a>, - property: JSXIdentifier<'a>, - ) -> JSXNamespacedName<'a> { - JSXNamespacedName { span, namespace, property } + r#abstract: bool, + type_parameters: T1, + params: T2, + return_type: T3, + ) -> TSConstructorType<'a> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + TSConstructorType { + span, + r#abstract, + type_parameters: type_parameters.into_in(self.allocator), + params: params.into_in(self.allocator), + return_type: return_type.into_in(self.allocator), + } } - /// Build a [`JSXNamespacedName`], and store it in the memory arena. + /// Build a [`TSConstructorType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_namespaced_name`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_constructor_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `namespace`: Namespace portion of the name, e.g. `Apple` in `` - /// * `property`: Name portion of the name, e.g. `Orange` in `` + /// * `span`: The [`Span`] covering this node + /// * `abstract` + /// * `type_parameters` + /// * `params` + /// * `return_type` #[inline] - pub fn alloc_jsx_namespaced_name( + pub fn alloc_ts_constructor_type( self, span: Span, - namespace: JSXIdentifier<'a>, - property: JSXIdentifier<'a>, - ) -> Box<'a, JSXNamespacedName<'a>> { - Box::new_in(self.jsx_namespaced_name(span, namespace, property), self.allocator) + r#abstract: bool, + type_parameters: T1, + params: T2, + return_type: T3, + ) -> Box<'a, TSConstructorType<'a>> + where + T1: IntoIn<'a, Option>>>, + T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>, + T3: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>, + { + Box::new_in( + self.ts_constructor_type(span, r#abstract, type_parameters, params, return_type), + self.allocator, + ) } - /// Build a [`JSXMemberExpression`]. + /// Build a [`TSMappedType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_member_expression`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_mapped_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `object`: The object being accessed. This is everything before the last `.`. - /// * `property`: The property being accessed. This is everything after the last `.`. + /// * `span`: The [`Span`] covering this node + /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. + /// * `name_type` + /// * `type_annotation` + /// * `optional`: Optional modifier on type annotation + /// * `readonly`: Readonly modifier before keyed index signature #[inline] - pub fn jsx_member_expression( + pub fn ts_mapped_type( self, span: Span, - object: JSXMemberExpressionObject<'a>, - property: JSXIdentifier<'a>, - ) -> JSXMemberExpression<'a> { - JSXMemberExpression { span, object, property } + type_parameter: T1, + name_type: Option>, + type_annotation: Option>, + optional: TSMappedTypeModifierOperator, + readonly: TSMappedTypeModifierOperator, + ) -> TSMappedType<'a> + where + T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + { + TSMappedType { + span, + type_parameter: type_parameter.into_in(self.allocator), + name_type, + type_annotation, + optional, + readonly, + scope_id: Default::default(), + } } - /// Build a [`JSXMemberExpression`], and store it in the memory arena. + /// Build a [`TSMappedType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_member_expression`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_mapped_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `object`: The object being accessed. This is everything before the last `.`. - /// * `property`: The property being accessed. This is everything after the last `.`. + /// * `span`: The [`Span`] covering this node + /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. + /// * `name_type` + /// * `type_annotation` + /// * `optional`: Optional modifier on type annotation + /// * `readonly`: Readonly modifier before keyed index signature #[inline] - pub fn alloc_jsx_member_expression( + pub fn alloc_ts_mapped_type( self, span: Span, - object: JSXMemberExpressionObject<'a>, - property: JSXIdentifier<'a>, - ) -> Box<'a, JSXMemberExpression<'a>> { - Box::new_in(self.jsx_member_expression(span, object, property), self.allocator) + type_parameter: T1, + name_type: Option>, + type_annotation: Option>, + optional: TSMappedTypeModifierOperator, + readonly: TSMappedTypeModifierOperator, + ) -> Box<'a, TSMappedType<'a>> + where + T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + { + Box::new_in( + self.ts_mapped_type( + span, + type_parameter, + name_type, + type_annotation, + optional, + readonly, + ), + self.allocator, + ) } - /// Build a [`JSXMemberExpressionObject::IdentifierReference`]. + /// Build a [`TSMappedType`] with `ScopeId`. /// - /// This node contains an [`IdentifierReference`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_mapped_type_with_scope_id`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node - /// * `name`: The name of the identifier being referenced. + /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. + /// * `name_type` + /// * `type_annotation` + /// * `optional`: Optional modifier on type annotation + /// * `readonly`: Readonly modifier before keyed index signature + /// * `scope_id` #[inline] - pub fn jsx_member_expression_object_identifier_reference( + pub fn ts_mapped_type_with_scope_id( self, span: Span, - name: A, - ) -> JSXMemberExpressionObject<'a> + type_parameter: T1, + name_type: Option>, + type_annotation: Option>, + optional: TSMappedTypeModifierOperator, + readonly: TSMappedTypeModifierOperator, + scope_id: ScopeId, + ) -> TSMappedType<'a> where - A: IntoIn<'a, Atom<'a>>, + T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, { - JSXMemberExpressionObject::IdentifierReference(self.alloc_identifier_reference(span, name)) + TSMappedType { + span, + type_parameter: type_parameter.into_in(self.allocator), + name_type, + type_annotation, + optional, + readonly, + scope_id: Cell::new(Some(scope_id)), + } } - /// Build a [`JSXMemberExpressionObject::MemberExpression`]. + /// Build a [`TSMappedType`] with `ScopeId`, and store it in the memory arena. /// - /// This node contains a [`JSXMemberExpression`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_mapped_type_with_scope_id`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `object`: The object being accessed. This is everything before the last `.`. - /// * `property`: The property being accessed. This is everything after the last `.`. + /// * `span`: The [`Span`] covering this node + /// * `type_parameter`: Key type parameter, e.g. `P` in `[P in keyof T]`. + /// * `name_type` + /// * `type_annotation` + /// * `optional`: Optional modifier on type annotation + /// * `readonly`: Readonly modifier before keyed index signature + /// * `scope_id` #[inline] - pub fn jsx_member_expression_object_jsx_member_expression( + pub fn alloc_ts_mapped_type_with_scope_id( self, span: Span, - object: JSXMemberExpressionObject<'a>, - property: JSXIdentifier<'a>, - ) -> JSXMemberExpressionObject<'a> { - JSXMemberExpressionObject::MemberExpression( - self.alloc_jsx_member_expression(span, object, property), + type_parameter: T1, + name_type: Option>, + type_annotation: Option>, + optional: TSMappedTypeModifierOperator, + readonly: TSMappedTypeModifierOperator, + scope_id: ScopeId, + ) -> Box<'a, TSMappedType<'a>> + where + T1: IntoIn<'a, Box<'a, TSTypeParameter<'a>>>, + { + Box::new_in( + self.ts_mapped_type_with_scope_id( + span, + type_parameter, + name_type, + type_annotation, + optional, + readonly, + scope_id, + ), + self.allocator, ) } - /// Build a [`JSXMemberExpressionObject::ThisExpression`]. + /// Build a [`TSTemplateLiteralType`]. /// - /// This node contains a [`ThisExpression`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_template_literal_type`] instead. /// /// ## Parameters /// * `span`: The [`Span`] covering this node + /// * `quasis`: The string parts of the template literal. + /// * `types`: The interpolated expressions in the template literal. #[inline] - pub fn jsx_member_expression_object_this_expression( + pub fn ts_template_literal_type( self, span: Span, - ) -> JSXMemberExpressionObject<'a> { - JSXMemberExpressionObject::ThisExpression(self.alloc_this_expression(span)) + quasis: Vec<'a, TemplateElement<'a>>, + types: Vec<'a, TSType<'a>>, + ) -> TSTemplateLiteralType<'a> { + TSTemplateLiteralType { span, quasis, types } } - /// Build a [`JSXExpressionContainer`]. + /// Build a [`TSTemplateLiteralType`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_expression_container`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_template_literal_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `expression`: The expression inside the container. + /// * `span`: The [`Span`] covering this node + /// * `quasis`: The string parts of the template literal. + /// * `types`: The interpolated expressions in the template literal. #[inline] - pub fn jsx_expression_container( + pub fn alloc_ts_template_literal_type( self, span: Span, - expression: JSXExpression<'a>, - ) -> JSXExpressionContainer<'a> { - JSXExpressionContainer { span, expression } + quasis: Vec<'a, TemplateElement<'a>>, + types: Vec<'a, TSType<'a>>, + ) -> Box<'a, TSTemplateLiteralType<'a>> { + Box::new_in(self.ts_template_literal_type(span, quasis, types), self.allocator) } - /// Build a [`JSXExpressionContainer`], and store it in the memory arena. + /// Build a [`TSAsExpression`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_expression_container`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_as_expression`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `expression`: The expression inside the container. + /// * `span`: The [`Span`] covering this node + /// * `expression` + /// * `type_annotation` #[inline] - pub fn alloc_jsx_expression_container( + pub fn ts_as_expression( self, span: Span, - expression: JSXExpression<'a>, - ) -> Box<'a, JSXExpressionContainer<'a>> { - Box::new_in(self.jsx_expression_container(span, expression), self.allocator) - } - - /// Build a [`JSXExpression::EmptyExpression`]. - /// - /// ## Parameters - /// * `span`: Node location in source code - #[inline] - pub fn jsx_expression_jsx_empty_expression(self, span: Span) -> JSXExpression<'a> { - JSXExpression::EmptyExpression(self.jsx_empty_expression(span)) + expression: Expression<'a>, + type_annotation: TSType<'a>, + ) -> TSAsExpression<'a> { + TSAsExpression { span, expression, type_annotation } } - /// Build a [`JSXEmptyExpression`]. + /// Build a [`TSAsExpression`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_empty_expression`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_as_expression`] instead. /// /// ## Parameters - /// * `span`: Node location in source code + /// * `span`: The [`Span`] covering this node + /// * `expression` + /// * `type_annotation` #[inline] - pub fn jsx_empty_expression(self, span: Span) -> JSXEmptyExpression { - JSXEmptyExpression { span } + pub fn alloc_ts_as_expression( + self, + span: Span, + expression: Expression<'a>, + type_annotation: TSType<'a>, + ) -> Box<'a, TSAsExpression<'a>> { + Box::new_in(self.ts_as_expression(span, expression, type_annotation), self.allocator) } - /// Build a [`JSXEmptyExpression`], and store it in the memory arena. + /// Build a [`TSSatisfiesExpression`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_empty_expression`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_satisfies_expression`] instead. /// /// ## Parameters - /// * `span`: Node location in source code + /// * `span`: The [`Span`] covering this node + /// * `expression`: The value expression being constrained. + /// * `type_annotation`: The type `expression` must satisfy. #[inline] - pub fn alloc_jsx_empty_expression(self, span: Span) -> Box<'a, JSXEmptyExpression> { - Box::new_in(self.jsx_empty_expression(span), self.allocator) + pub fn ts_satisfies_expression( + self, + span: Span, + expression: Expression<'a>, + type_annotation: TSType<'a>, + ) -> TSSatisfiesExpression<'a> { + TSSatisfiesExpression { span, expression, type_annotation } } - /// Build a [`JSXAttributeItem::Attribute`]. + /// Build a [`TSSatisfiesExpression`], and store it in the memory arena. /// - /// This node contains a [`JSXAttribute`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_satisfies_expression`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The name of the attribute. This is a prop in React-like applications. - /// * `value`: The value of the attribute. This can be a string literal, an expression, + /// * `span`: The [`Span`] covering this node + /// * `expression`: The value expression being constrained. + /// * `type_annotation`: The type `expression` must satisfy. #[inline] - pub fn jsx_attribute_item_jsx_attribute( + pub fn alloc_ts_satisfies_expression( self, span: Span, - name: JSXAttributeName<'a>, - value: Option>, - ) -> JSXAttributeItem<'a> { - JSXAttributeItem::Attribute(self.alloc_jsx_attribute(span, name, value)) + expression: Expression<'a>, + type_annotation: TSType<'a>, + ) -> Box<'a, TSSatisfiesExpression<'a>> { + Box::new_in(self.ts_satisfies_expression(span, expression, type_annotation), self.allocator) } - /// Build a [`JSXAttributeItem::SpreadAttribute`]. + /// Build a [`TSTypeAssertion`]. /// - /// This node contains a [`JSXSpreadAttribute`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_type_assertion`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `argument`: The expression being spread. + /// * `span`: The [`Span`] covering this node + /// * `expression` + /// * `type_annotation` #[inline] - pub fn jsx_attribute_item_jsx_spread_attribute( + pub fn ts_type_assertion( self, span: Span, - argument: Expression<'a>, - ) -> JSXAttributeItem<'a> { - JSXAttributeItem::SpreadAttribute(self.alloc_jsx_spread_attribute(span, argument)) + expression: Expression<'a>, + type_annotation: TSType<'a>, + ) -> TSTypeAssertion<'a> { + TSTypeAssertion { span, expression, type_annotation } } - /// Build a [`JSXAttribute`]. + /// Build a [`TSTypeAssertion`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_attribute`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_type_assertion`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The name of the attribute. This is a prop in React-like applications. - /// * `value`: The value of the attribute. This can be a string literal, an expression, + /// * `span`: The [`Span`] covering this node + /// * `expression` + /// * `type_annotation` #[inline] - pub fn jsx_attribute( + pub fn alloc_ts_type_assertion( self, span: Span, - name: JSXAttributeName<'a>, - value: Option>, - ) -> JSXAttribute<'a> { - JSXAttribute { span, name, value } + expression: Expression<'a>, + type_annotation: TSType<'a>, + ) -> Box<'a, TSTypeAssertion<'a>> { + Box::new_in(self.ts_type_assertion(span, expression, type_annotation), self.allocator) } - /// Build a [`JSXAttribute`], and store it in the memory arena. + /// Build a [`TSImportEqualsDeclaration`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_attribute`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_import_equals_declaration`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The name of the attribute. This is a prop in React-like applications. - /// * `value`: The value of the attribute. This can be a string literal, an expression, + /// * `span`: The [`Span`] covering this node + /// * `id` + /// * `module_reference` + /// * `import_kind` #[inline] - pub fn alloc_jsx_attribute( + pub fn ts_import_equals_declaration( self, span: Span, - name: JSXAttributeName<'a>, - value: Option>, - ) -> Box<'a, JSXAttribute<'a>> { - Box::new_in(self.jsx_attribute(span, name, value), self.allocator) + id: BindingIdentifier<'a>, + module_reference: TSModuleReference<'a>, + import_kind: ImportOrExportKind, + ) -> TSImportEqualsDeclaration<'a> { + TSImportEqualsDeclaration { span, id, module_reference, import_kind } } - /// Build a [`JSXSpreadAttribute`]. + /// Build a [`TSImportEqualsDeclaration`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_spread_attribute`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_import_equals_declaration`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `argument`: The expression being spread. + /// * `span`: The [`Span`] covering this node + /// * `id` + /// * `module_reference` + /// * `import_kind` #[inline] - pub fn jsx_spread_attribute( + pub fn alloc_ts_import_equals_declaration( self, span: Span, - argument: Expression<'a>, - ) -> JSXSpreadAttribute<'a> { - JSXSpreadAttribute { span, argument } + id: BindingIdentifier<'a>, + module_reference: TSModuleReference<'a>, + import_kind: ImportOrExportKind, + ) -> Box<'a, TSImportEqualsDeclaration<'a>> { + Box::new_in( + self.ts_import_equals_declaration(span, id, module_reference, import_kind), + self.allocator, + ) } - /// Build a [`JSXSpreadAttribute`], and store it in the memory arena. + /// Build a [`TSModuleReference::ExternalModuleReference`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_spread_attribute`] instead. + /// This node contains a [`TSExternalModuleReference`] that will be stored in the memory arena. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `argument`: The expression being spread. + /// * `span`: The [`Span`] covering this node + /// * `expression` #[inline] - pub fn alloc_jsx_spread_attribute( + pub fn ts_module_reference_external_module_reference( self, span: Span, - argument: Expression<'a>, - ) -> Box<'a, JSXSpreadAttribute<'a>> { - Box::new_in(self.jsx_spread_attribute(span, argument), self.allocator) + expression: StringLiteral<'a>, + ) -> TSModuleReference<'a> { + TSModuleReference::ExternalModuleReference( + self.alloc_ts_external_module_reference(span, expression), + ) } - /// Build a [`JSXAttributeName::Identifier`]. + /// Build a [`TSExternalModuleReference`]. /// - /// This node contains a [`JSXIdentifier`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_external_module_reference`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The name of the identifier. + /// * `span`: The [`Span`] covering this node + /// * `expression` #[inline] - pub fn jsx_attribute_name_jsx_identifier(self, span: Span, name: A) -> JSXAttributeName<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - JSXAttributeName::Identifier(self.alloc_jsx_identifier(span, name)) + pub fn ts_external_module_reference( + self, + span: Span, + expression: StringLiteral<'a>, + ) -> TSExternalModuleReference<'a> { + TSExternalModuleReference { span, expression } } - /// Build a [`JSXAttributeName::NamespacedName`]. + /// Build a [`TSExternalModuleReference`], and store it in the memory arena. /// - /// This node contains a [`JSXNamespacedName`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_external_module_reference`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `namespace`: Namespace portion of the name, e.g. `Apple` in `` - /// * `property`: Name portion of the name, e.g. `Orange` in `` + /// * `span`: The [`Span`] covering this node + /// * `expression` #[inline] - pub fn jsx_attribute_name_jsx_namespaced_name( + pub fn alloc_ts_external_module_reference( self, span: Span, - namespace: JSXIdentifier<'a>, - property: JSXIdentifier<'a>, - ) -> JSXAttributeName<'a> { - JSXAttributeName::NamespacedName(self.alloc_jsx_namespaced_name(span, namespace, property)) + expression: StringLiteral<'a>, + ) -> Box<'a, TSExternalModuleReference<'a>> { + Box::new_in(self.ts_external_module_reference(span, expression), self.allocator) } - /// Build a [`JSXAttributeValue::StringLiteral`]. + /// Build a [`TSNonNullExpression`]. /// - /// This node contains a [`StringLiteral`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_non_null_expression`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The value of the string. - /// * `raw`: The raw string as it appears in source code. + /// * `span`: The [`Span`] covering this node + /// * `expression` #[inline] - pub fn jsx_attribute_value_string_literal( + pub fn ts_non_null_expression( self, span: Span, - value: A, - raw: Option>, - ) -> JSXAttributeValue<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - JSXAttributeValue::StringLiteral(self.alloc_string_literal(span, value, raw)) + expression: Expression<'a>, + ) -> TSNonNullExpression<'a> { + TSNonNullExpression { span, expression } } - /// Build a [`JSXAttributeValue::ExpressionContainer`]. + /// Build a [`TSNonNullExpression`], and store it in the memory arena. /// - /// This node contains a [`JSXExpressionContainer`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_non_null_expression`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `expression`: The expression inside the container. + /// * `span`: The [`Span`] covering this node + /// * `expression` #[inline] - pub fn jsx_attribute_value_jsx_expression_container( + pub fn alloc_ts_non_null_expression( self, span: Span, - expression: JSXExpression<'a>, - ) -> JSXAttributeValue<'a> { - JSXAttributeValue::ExpressionContainer( - self.alloc_jsx_expression_container(span, expression), - ) + expression: Expression<'a>, + ) -> Box<'a, TSNonNullExpression<'a>> { + Box::new_in(self.ts_non_null_expression(span, expression), self.allocator) } - /// Build a [`JSXAttributeValue::Element`]. + /// Build a [`Decorator`]. /// - /// This node contains a [`JSXElement`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_decorator`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `opening_element`: Opening tag of the element. - /// * `closing_element`: Closing tag of the element. Will be [`None`] for self-closing tags. - /// * `children`: Children of the element. This can be text, other elements, or expressions. + /// * `span`: The [`Span`] covering this node + /// * `expression` #[inline] - pub fn jsx_attribute_value_jsx_element( - self, - span: Span, - opening_element: T1, - closing_element: T2, - children: Vec<'a, JSXChild<'a>>, - ) -> JSXAttributeValue<'a> - where - T1: IntoIn<'a, Box<'a, JSXOpeningElement<'a>>>, - T2: IntoIn<'a, Option>>>, - { - JSXAttributeValue::Element(self.alloc_jsx_element( - span, - opening_element, - closing_element, - children, - )) + pub fn decorator(self, span: Span, expression: Expression<'a>) -> Decorator<'a> { + Decorator { span, expression } } - /// Build a [`JSXAttributeValue::Fragment`]. + /// Build a [`Decorator`], and store it in the memory arena. /// - /// This node contains a [`JSXFragment`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::decorator`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `opening_fragment`: `<>` - /// * `closing_fragment`: `` - /// * `children`: Elements inside the fragment. + /// * `span`: The [`Span`] covering this node + /// * `expression` #[inline] - pub fn jsx_attribute_value_jsx_fragment( + pub fn alloc_decorator(self, span: Span, expression: Expression<'a>) -> Box<'a, Decorator<'a>> { + Box::new_in(self.decorator(span, expression), self.allocator) + } + + /// Build a [`TSExportAssignment`]. + /// + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_export_assignment`] instead. + /// + /// ## Parameters + /// * `span`: The [`Span`] covering this node + /// * `expression` + #[inline] + pub fn ts_export_assignment( self, span: Span, - opening_fragment: JSXOpeningFragment, - closing_fragment: JSXClosingFragment, - children: Vec<'a, JSXChild<'a>>, - ) -> JSXAttributeValue<'a> { - JSXAttributeValue::Fragment(self.alloc_jsx_fragment( - span, - opening_fragment, - closing_fragment, - children, - )) + expression: Expression<'a>, + ) -> TSExportAssignment<'a> { + TSExportAssignment { span, expression } } - /// Build a [`JSXIdentifier`]. + /// Build a [`TSExportAssignment`], and store it in the memory arena. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_identifier`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_export_assignment`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The name of the identifier. + /// * `span`: The [`Span`] covering this node + /// * `expression` #[inline] - pub fn jsx_identifier(self, span: Span, name: A) -> JSXIdentifier<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - JSXIdentifier { span, name: name.into_in(self.allocator) } + pub fn alloc_ts_export_assignment( + self, + span: Span, + expression: Expression<'a>, + ) -> Box<'a, TSExportAssignment<'a>> { + Box::new_in(self.ts_export_assignment(span, expression), self.allocator) } - /// Build a [`JSXIdentifier`], and store it in the memory arena. + /// Build a [`TSNamespaceExportDeclaration`]. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_identifier`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_namespace_export_declaration`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `name`: The name of the identifier. + /// * `span`: The [`Span`] covering this node + /// * `id` #[inline] - pub fn alloc_jsx_identifier(self, span: Span, name: A) -> Box<'a, JSXIdentifier<'a>> - where - A: IntoIn<'a, Atom<'a>>, - { - Box::new_in(self.jsx_identifier(span, name), self.allocator) + pub fn ts_namespace_export_declaration( + self, + span: Span, + id: IdentifierName<'a>, + ) -> TSNamespaceExportDeclaration<'a> { + TSNamespaceExportDeclaration { span, id } } - /// Build a [`JSXChild::Text`]. + /// Build a [`TSNamespaceExportDeclaration`], and store it in the memory arena. /// - /// This node contains a [`JSXText`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_namespace_export_declaration`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The text content. + /// * `span`: The [`Span`] covering this node + /// * `id` #[inline] - pub fn jsx_child_jsx_text(self, span: Span, value: A) -> JSXChild<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - JSXChild::Text(self.alloc_jsx_text(span, value)) + pub fn alloc_ts_namespace_export_declaration( + self, + span: Span, + id: IdentifierName<'a>, + ) -> Box<'a, TSNamespaceExportDeclaration<'a>> { + Box::new_in(self.ts_namespace_export_declaration(span, id), self.allocator) } - /// Build a [`JSXChild::Element`]. + /// Build a [`TSInstantiationExpression`]. /// - /// This node contains a [`JSXElement`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_ts_instantiation_expression`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `opening_element`: Opening tag of the element. - /// * `closing_element`: Closing tag of the element. Will be [`None`] for self-closing tags. - /// * `children`: Children of the element. This can be text, other elements, or expressions. + /// * `span`: The [`Span`] covering this node + /// * `expression` + /// * `type_parameters` #[inline] - pub fn jsx_child_jsx_element( + pub fn ts_instantiation_expression( self, span: Span, - opening_element: T1, - closing_element: T2, - children: Vec<'a, JSXChild<'a>>, - ) -> JSXChild<'a> + expression: Expression<'a>, + type_parameters: T1, + ) -> TSInstantiationExpression<'a> where - T1: IntoIn<'a, Box<'a, JSXOpeningElement<'a>>>, - T2: IntoIn<'a, Option>>>, + T1: IntoIn<'a, Box<'a, TSTypeParameterInstantiation<'a>>>, { - JSXChild::Element(self.alloc_jsx_element(span, opening_element, closing_element, children)) + TSInstantiationExpression { + span, + expression, + type_parameters: type_parameters.into_in(self.allocator), + } } - /// Build a [`JSXChild::Fragment`]. + /// Build a [`TSInstantiationExpression`], and store it in the memory arena. /// - /// This node contains a [`JSXFragment`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::ts_instantiation_expression`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `opening_fragment`: `<>` - /// * `closing_fragment`: `` - /// * `children`: Elements inside the fragment. + /// * `span`: The [`Span`] covering this node + /// * `expression` + /// * `type_parameters` #[inline] - pub fn jsx_child_jsx_fragment( + pub fn alloc_ts_instantiation_expression( self, span: Span, - opening_fragment: JSXOpeningFragment, - closing_fragment: JSXClosingFragment, - children: Vec<'a, JSXChild<'a>>, - ) -> JSXChild<'a> { - JSXChild::Fragment(self.alloc_jsx_fragment( - span, - opening_fragment, - closing_fragment, - children, - )) + expression: Expression<'a>, + type_parameters: T1, + ) -> Box<'a, TSInstantiationExpression<'a>> + where + T1: IntoIn<'a, Box<'a, TSTypeParameterInstantiation<'a>>>, + { + Box::new_in( + self.ts_instantiation_expression(span, expression, type_parameters), + self.allocator, + ) } - /// Build a [`JSXChild::ExpressionContainer`]. + /// Build a [`JSDocNullableType`]. /// - /// This node contains a [`JSXExpressionContainer`] that will be stored in the memory arena. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_js_doc_nullable_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `expression`: The expression inside the container. + /// * `span`: The [`Span`] covering this node + /// * `type_annotation` + /// * `postfix`: Was `?` after the type annotation? #[inline] - pub fn jsx_child_jsx_expression_container( + pub fn js_doc_nullable_type( self, span: Span, - expression: JSXExpression<'a>, - ) -> JSXChild<'a> { - JSXChild::ExpressionContainer(self.alloc_jsx_expression_container(span, expression)) + type_annotation: TSType<'a>, + postfix: bool, + ) -> JSDocNullableType<'a> { + JSDocNullableType { span, type_annotation, postfix } } - /// Build a [`JSXChild::Spread`]. + /// Build a [`JSDocNullableType`], and store it in the memory arena. /// - /// This node contains a [`JSXSpreadChild`] that will be stored in the memory arena. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::js_doc_nullable_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `expression`: The expression being spread. + /// * `span`: The [`Span`] covering this node + /// * `type_annotation` + /// * `postfix`: Was `?` after the type annotation? #[inline] - pub fn jsx_child_jsx_spread_child( + pub fn alloc_js_doc_nullable_type( self, span: Span, - expression: Expression<'a>, - ) -> JSXChild<'a> { - JSXChild::Spread(self.alloc_jsx_spread_child(span, expression)) + type_annotation: TSType<'a>, + postfix: bool, + ) -> Box<'a, JSDocNullableType<'a>> { + Box::new_in(self.js_doc_nullable_type(span, type_annotation, postfix), self.allocator) } - /// Build a [`JSXSpreadChild`]. + /// Build a [`JSDocNonNullableType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_spread_child`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_js_doc_non_nullable_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `expression`: The expression being spread. + /// * `span`: The [`Span`] covering this node + /// * `type_annotation` + /// * `postfix` #[inline] - pub fn jsx_spread_child(self, span: Span, expression: Expression<'a>) -> JSXSpreadChild<'a> { - JSXSpreadChild { span, expression } + pub fn js_doc_non_nullable_type( + self, + span: Span, + type_annotation: TSType<'a>, + postfix: bool, + ) -> JSDocNonNullableType<'a> { + JSDocNonNullableType { span, type_annotation, postfix } } - /// Build a [`JSXSpreadChild`], and store it in the memory arena. + /// Build a [`JSDocNonNullableType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_spread_child`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::js_doc_non_nullable_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `expression`: The expression being spread. + /// * `span`: The [`Span`] covering this node + /// * `type_annotation` + /// * `postfix` #[inline] - pub fn alloc_jsx_spread_child( + pub fn alloc_js_doc_non_nullable_type( self, span: Span, - expression: Expression<'a>, - ) -> Box<'a, JSXSpreadChild<'a>> { - Box::new_in(self.jsx_spread_child(span, expression), self.allocator) + type_annotation: TSType<'a>, + postfix: bool, + ) -> Box<'a, JSDocNonNullableType<'a>> { + Box::new_in(self.js_doc_non_nullable_type(span, type_annotation, postfix), self.allocator) } - /// Build a [`JSXText`]. + /// Build a [`JSDocUnknownType`]. /// - /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_jsx_text`] instead. + /// If you want the built node to be allocated in the memory arena, use [`AstBuilder::alloc_js_doc_unknown_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The text content. + /// * `span`: The [`Span`] covering this node #[inline] - pub fn jsx_text(self, span: Span, value: A) -> JSXText<'a> - where - A: IntoIn<'a, Atom<'a>>, - { - JSXText { span, value: value.into_in(self.allocator) } + pub fn js_doc_unknown_type(self, span: Span) -> JSDocUnknownType { + JSDocUnknownType { span } } - /// Build a [`JSXText`], and store it in the memory arena. + /// Build a [`JSDocUnknownType`], and store it in the memory arena. /// - /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::jsx_text`] instead. + /// Returns a [`Box`] containing the newly-allocated node. If you want a stack-allocated node, use [`AstBuilder::js_doc_unknown_type`] instead. /// /// ## Parameters - /// * `span`: Node location in source code - /// * `value`: The text content. + /// * `span`: The [`Span`] covering this node #[inline] - pub fn alloc_jsx_text(self, span: Span, value: A) -> Box<'a, JSXText<'a>> - where - A: IntoIn<'a, Atom<'a>>, - { - Box::new_in(self.jsx_text(span, value), self.allocator) + pub fn alloc_js_doc_unknown_type(self, span: Span) -> Box<'a, JSDocUnknownType> { + Box::new_in(self.js_doc_unknown_type(span), self.allocator) } } diff --git a/crates/oxc_ast/src/generated/ast_kind.rs b/crates/oxc_ast/src/generated/ast_kind.rs index ed187ff7ee6db..5aae6de27c3c2 100644 --- a/crates/oxc_ast/src/generated/ast_kind.rs +++ b/crates/oxc_ast/src/generated/ast_kind.rs @@ -13,183 +13,177 @@ use crate::ast::*; #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u8)] pub enum AstType { - BooleanLiteral = 0, - NullLiteral = 1, - NumericLiteral = 2, - StringLiteral = 3, - BigIntLiteral = 4, - RegExpLiteral = 5, - Program = 6, - IdentifierName = 7, - IdentifierReference = 8, - BindingIdentifier = 9, - LabelIdentifier = 10, - ThisExpression = 11, - ArrayExpression = 12, - ArrayExpressionElement = 13, - Elision = 14, - ObjectExpression = 15, - ObjectProperty = 16, - PropertyKey = 17, - TemplateLiteral = 18, - TaggedTemplateExpression = 19, - MemberExpression = 20, - CallExpression = 21, - NewExpression = 22, - MetaProperty = 23, - SpreadElement = 24, - Argument = 25, - UpdateExpression = 26, - UnaryExpression = 27, - BinaryExpression = 28, - PrivateInExpression = 29, - LogicalExpression = 30, - ConditionalExpression = 31, - AssignmentExpression = 32, - AssignmentTarget = 33, - SimpleAssignmentTarget = 34, - AssignmentTargetPattern = 35, - ArrayAssignmentTarget = 36, - ObjectAssignmentTarget = 37, - AssignmentTargetWithDefault = 38, - SequenceExpression = 39, - Super = 40, - AwaitExpression = 41, - ChainExpression = 42, - ParenthesizedExpression = 43, - Directive = 44, - Hashbang = 45, - BlockStatement = 46, - VariableDeclaration = 47, - VariableDeclarator = 48, - EmptyStatement = 49, - ExpressionStatement = 50, - IfStatement = 51, - DoWhileStatement = 52, - WhileStatement = 53, - ForStatement = 54, - ForStatementInit = 55, - ForInStatement = 56, - ForOfStatement = 57, - ContinueStatement = 58, - BreakStatement = 59, - ReturnStatement = 60, - WithStatement = 61, - SwitchStatement = 62, - SwitchCase = 63, - LabeledStatement = 64, - ThrowStatement = 65, - TryStatement = 66, - CatchClause = 67, - CatchParameter = 68, - DebuggerStatement = 69, - AssignmentPattern = 70, - ObjectPattern = 71, - ArrayPattern = 72, - BindingRestElement = 73, - Function = 74, - FormalParameters = 75, - FormalParameter = 76, - FunctionBody = 77, - ArrowFunctionExpression = 78, - YieldExpression = 79, - Class = 80, - ClassBody = 81, - MethodDefinition = 82, - PropertyDefinition = 83, - PrivateIdentifier = 84, - StaticBlock = 85, - ModuleDeclaration = 86, - ImportExpression = 87, - ImportDeclaration = 88, - ImportSpecifier = 89, - ImportDefaultSpecifier = 90, - ImportNamespaceSpecifier = 91, - ExportNamedDeclaration = 92, - ExportDefaultDeclaration = 93, - ExportAllDeclaration = 94, - ExportSpecifier = 95, - TSThisParameter = 96, - TSEnumDeclaration = 97, - TSEnumMember = 98, - TSTypeAnnotation = 99, - TSLiteralType = 100, - TSConditionalType = 101, - TSUnionType = 102, - TSIntersectionType = 103, - TSParenthesizedType = 104, - TSIndexedAccessType = 105, - TSNamedTupleMember = 106, - TSAnyKeyword = 107, - TSStringKeyword = 108, - TSBooleanKeyword = 109, - TSNumberKeyword = 110, - TSNeverKeyword = 111, - TSIntrinsicKeyword = 112, - TSUnknownKeyword = 113, - TSNullKeyword = 114, - TSUndefinedKeyword = 115, - TSVoidKeyword = 116, - TSSymbolKeyword = 117, - TSThisType = 118, - TSObjectKeyword = 119, - TSBigIntKeyword = 120, - TSTypeReference = 121, - TSTypeName = 122, - TSQualifiedName = 123, - TSTypeParameterInstantiation = 124, - TSTypeParameter = 125, - TSTypeParameterDeclaration = 126, - TSTypeAliasDeclaration = 127, - TSClassImplements = 128, - TSInterfaceDeclaration = 129, - TSPropertySignature = 130, - TSMethodSignature = 131, - TSConstructSignatureDeclaration = 132, - TSInterfaceHeritage = 133, - TSModuleDeclaration = 134, - TSModuleBlock = 135, - TSTypeLiteral = 136, - TSInferType = 137, - TSTypeQuery = 138, - TSImportType = 139, - TSMappedType = 140, - TSTemplateLiteralType = 141, - TSAsExpression = 142, - TSSatisfiesExpression = 143, - TSTypeAssertion = 144, - TSImportEqualsDeclaration = 145, - TSModuleReference = 146, - TSExternalModuleReference = 147, - TSNonNullExpression = 148, - Decorator = 149, - TSExportAssignment = 150, - TSInstantiationExpression = 151, - JSXElement = 152, - JSXOpeningElement = 153, - JSXClosingElement = 154, - JSXFragment = 155, - JSXElementName = 156, - JSXNamespacedName = 157, - JSXMemberExpression = 158, - JSXMemberExpressionObject = 159, - JSXExpressionContainer = 160, - JSXAttributeItem = 161, - JSXSpreadAttribute = 162, - JSXIdentifier = 163, - JSXText = 164, + Program = 0, + IdentifierName = 1, + IdentifierReference = 2, + BindingIdentifier = 3, + LabelIdentifier = 4, + ThisExpression = 5, + ArrayExpression = 6, + ArrayExpressionElement = 7, + Elision = 8, + ObjectExpression = 9, + ObjectProperty = 10, + PropertyKey = 11, + TemplateLiteral = 12, + TaggedTemplateExpression = 13, + MemberExpression = 14, + CallExpression = 15, + NewExpression = 16, + MetaProperty = 17, + SpreadElement = 18, + Argument = 19, + UpdateExpression = 20, + UnaryExpression = 21, + BinaryExpression = 22, + PrivateInExpression = 23, + LogicalExpression = 24, + ConditionalExpression = 25, + AssignmentExpression = 26, + AssignmentTarget = 27, + SimpleAssignmentTarget = 28, + AssignmentTargetPattern = 29, + ArrayAssignmentTarget = 30, + ObjectAssignmentTarget = 31, + AssignmentTargetWithDefault = 32, + SequenceExpression = 33, + Super = 34, + AwaitExpression = 35, + ChainExpression = 36, + ParenthesizedExpression = 37, + Directive = 38, + Hashbang = 39, + BlockStatement = 40, + VariableDeclaration = 41, + VariableDeclarator = 42, + EmptyStatement = 43, + ExpressionStatement = 44, + IfStatement = 45, + DoWhileStatement = 46, + WhileStatement = 47, + ForStatement = 48, + ForStatementInit = 49, + ForInStatement = 50, + ForOfStatement = 51, + ContinueStatement = 52, + BreakStatement = 53, + ReturnStatement = 54, + WithStatement = 55, + SwitchStatement = 56, + SwitchCase = 57, + LabeledStatement = 58, + ThrowStatement = 59, + TryStatement = 60, + CatchClause = 61, + CatchParameter = 62, + DebuggerStatement = 63, + AssignmentPattern = 64, + ObjectPattern = 65, + ArrayPattern = 66, + BindingRestElement = 67, + Function = 68, + FormalParameters = 69, + FormalParameter = 70, + FunctionBody = 71, + ArrowFunctionExpression = 72, + YieldExpression = 73, + Class = 74, + ClassBody = 75, + MethodDefinition = 76, + PropertyDefinition = 77, + PrivateIdentifier = 78, + StaticBlock = 79, + ModuleDeclaration = 80, + ImportExpression = 81, + ImportDeclaration = 82, + ImportSpecifier = 83, + ImportDefaultSpecifier = 84, + ImportNamespaceSpecifier = 85, + ExportNamedDeclaration = 86, + ExportDefaultDeclaration = 87, + ExportAllDeclaration = 88, + ExportSpecifier = 89, + BooleanLiteral = 90, + NullLiteral = 91, + NumericLiteral = 92, + StringLiteral = 93, + BigIntLiteral = 94, + RegExpLiteral = 95, + JSXElement = 96, + JSXOpeningElement = 97, + JSXClosingElement = 98, + JSXFragment = 99, + JSXElementName = 100, + JSXNamespacedName = 101, + JSXMemberExpression = 102, + JSXMemberExpressionObject = 103, + JSXExpressionContainer = 104, + JSXAttributeItem = 105, + JSXSpreadAttribute = 106, + JSXIdentifier = 107, + JSXText = 108, + TSThisParameter = 109, + TSEnumDeclaration = 110, + TSEnumMember = 111, + TSTypeAnnotation = 112, + TSLiteralType = 113, + TSConditionalType = 114, + TSUnionType = 115, + TSIntersectionType = 116, + TSParenthesizedType = 117, + TSIndexedAccessType = 118, + TSNamedTupleMember = 119, + TSAnyKeyword = 120, + TSStringKeyword = 121, + TSBooleanKeyword = 122, + TSNumberKeyword = 123, + TSNeverKeyword = 124, + TSIntrinsicKeyword = 125, + TSUnknownKeyword = 126, + TSNullKeyword = 127, + TSUndefinedKeyword = 128, + TSVoidKeyword = 129, + TSSymbolKeyword = 130, + TSThisType = 131, + TSObjectKeyword = 132, + TSBigIntKeyword = 133, + TSTypeReference = 134, + TSTypeName = 135, + TSQualifiedName = 136, + TSTypeParameterInstantiation = 137, + TSTypeParameter = 138, + TSTypeParameterDeclaration = 139, + TSTypeAliasDeclaration = 140, + TSClassImplements = 141, + TSInterfaceDeclaration = 142, + TSPropertySignature = 143, + TSMethodSignature = 144, + TSConstructSignatureDeclaration = 145, + TSInterfaceHeritage = 146, + TSModuleDeclaration = 147, + TSModuleBlock = 148, + TSTypeLiteral = 149, + TSInferType = 150, + TSTypeQuery = 151, + TSImportType = 152, + TSMappedType = 153, + TSTemplateLiteralType = 154, + TSAsExpression = 155, + TSSatisfiesExpression = 156, + TSTypeAssertion = 157, + TSImportEqualsDeclaration = 158, + TSModuleReference = 159, + TSExternalModuleReference = 160, + TSNonNullExpression = 161, + Decorator = 162, + TSExportAssignment = 163, + TSInstantiationExpression = 164, } /// Untyped AST Node Kind #[derive(Debug, Clone, Copy)] #[repr(C, u8)] pub enum AstKind<'a> { - BooleanLiteral(&'a BooleanLiteral) = AstType::BooleanLiteral as u8, - NullLiteral(&'a NullLiteral) = AstType::NullLiteral as u8, - NumericLiteral(&'a NumericLiteral<'a>) = AstType::NumericLiteral as u8, - StringLiteral(&'a StringLiteral<'a>) = AstType::StringLiteral as u8, - BigIntLiteral(&'a BigIntLiteral<'a>) = AstType::BigIntLiteral as u8, - RegExpLiteral(&'a RegExpLiteral<'a>) = AstType::RegExpLiteral as u8, Program(&'a Program<'a>) = AstType::Program as u8, IdentifierName(&'a IdentifierName<'a>) = AstType::IdentifierName as u8, IdentifierReference(&'a IdentifierReference<'a>) = AstType::IdentifierReference as u8, @@ -287,6 +281,26 @@ pub enum AstKind<'a> { AstType::ExportDefaultDeclaration as u8, ExportAllDeclaration(&'a ExportAllDeclaration<'a>) = AstType::ExportAllDeclaration as u8, ExportSpecifier(&'a ExportSpecifier<'a>) = AstType::ExportSpecifier as u8, + BooleanLiteral(&'a BooleanLiteral) = AstType::BooleanLiteral as u8, + NullLiteral(&'a NullLiteral) = AstType::NullLiteral as u8, + NumericLiteral(&'a NumericLiteral<'a>) = AstType::NumericLiteral as u8, + StringLiteral(&'a StringLiteral<'a>) = AstType::StringLiteral as u8, + BigIntLiteral(&'a BigIntLiteral<'a>) = AstType::BigIntLiteral as u8, + RegExpLiteral(&'a RegExpLiteral<'a>) = AstType::RegExpLiteral as u8, + JSXElement(&'a JSXElement<'a>) = AstType::JSXElement as u8, + JSXOpeningElement(&'a JSXOpeningElement<'a>) = AstType::JSXOpeningElement as u8, + JSXClosingElement(&'a JSXClosingElement<'a>) = AstType::JSXClosingElement as u8, + JSXFragment(&'a JSXFragment<'a>) = AstType::JSXFragment as u8, + JSXElementName(&'a JSXElementName<'a>) = AstType::JSXElementName as u8, + JSXNamespacedName(&'a JSXNamespacedName<'a>) = AstType::JSXNamespacedName as u8, + JSXMemberExpression(&'a JSXMemberExpression<'a>) = AstType::JSXMemberExpression as u8, + JSXMemberExpressionObject(&'a JSXMemberExpressionObject<'a>) = + AstType::JSXMemberExpressionObject as u8, + JSXExpressionContainer(&'a JSXExpressionContainer<'a>) = AstType::JSXExpressionContainer as u8, + JSXAttributeItem(&'a JSXAttributeItem<'a>) = AstType::JSXAttributeItem as u8, + JSXSpreadAttribute(&'a JSXSpreadAttribute<'a>) = AstType::JSXSpreadAttribute as u8, + JSXIdentifier(&'a JSXIdentifier<'a>) = AstType::JSXIdentifier as u8, + JSXText(&'a JSXText<'a>) = AstType::JSXText as u8, TSThisParameter(&'a TSThisParameter<'a>) = AstType::TSThisParameter as u8, TSEnumDeclaration(&'a TSEnumDeclaration<'a>) = AstType::TSEnumDeclaration as u8, TSEnumMember(&'a TSEnumMember<'a>) = AstType::TSEnumMember as u8, @@ -349,20 +363,6 @@ pub enum AstKind<'a> { TSExportAssignment(&'a TSExportAssignment<'a>) = AstType::TSExportAssignment as u8, TSInstantiationExpression(&'a TSInstantiationExpression<'a>) = AstType::TSInstantiationExpression as u8, - JSXElement(&'a JSXElement<'a>) = AstType::JSXElement as u8, - JSXOpeningElement(&'a JSXOpeningElement<'a>) = AstType::JSXOpeningElement as u8, - JSXClosingElement(&'a JSXClosingElement<'a>) = AstType::JSXClosingElement as u8, - JSXFragment(&'a JSXFragment<'a>) = AstType::JSXFragment as u8, - JSXElementName(&'a JSXElementName<'a>) = AstType::JSXElementName as u8, - JSXNamespacedName(&'a JSXNamespacedName<'a>) = AstType::JSXNamespacedName as u8, - JSXMemberExpression(&'a JSXMemberExpression<'a>) = AstType::JSXMemberExpression as u8, - JSXMemberExpressionObject(&'a JSXMemberExpressionObject<'a>) = - AstType::JSXMemberExpressionObject as u8, - JSXExpressionContainer(&'a JSXExpressionContainer<'a>) = AstType::JSXExpressionContainer as u8, - JSXAttributeItem(&'a JSXAttributeItem<'a>) = AstType::JSXAttributeItem as u8, - JSXSpreadAttribute(&'a JSXSpreadAttribute<'a>) = AstType::JSXSpreadAttribute as u8, - JSXIdentifier(&'a JSXIdentifier<'a>) = AstType::JSXIdentifier as u8, - JSXText(&'a JSXText<'a>) = AstType::JSXText as u8, } impl AstKind<'_> { @@ -380,12 +380,6 @@ impl AstKind<'_> { impl GetSpan for AstKind<'_> { fn span(&self) -> Span { match self { - Self::BooleanLiteral(it) => it.span(), - Self::NullLiteral(it) => it.span(), - Self::NumericLiteral(it) => it.span(), - Self::StringLiteral(it) => it.span(), - Self::BigIntLiteral(it) => it.span(), - Self::RegExpLiteral(it) => it.span(), Self::Program(it) => it.span(), Self::IdentifierName(it) => it.span(), Self::IdentifierReference(it) => it.span(), @@ -476,6 +470,25 @@ impl GetSpan for AstKind<'_> { Self::ExportDefaultDeclaration(it) => it.span(), Self::ExportAllDeclaration(it) => it.span(), Self::ExportSpecifier(it) => it.span(), + Self::BooleanLiteral(it) => it.span(), + Self::NullLiteral(it) => it.span(), + Self::NumericLiteral(it) => it.span(), + Self::StringLiteral(it) => it.span(), + Self::BigIntLiteral(it) => it.span(), + Self::RegExpLiteral(it) => it.span(), + Self::JSXElement(it) => it.span(), + Self::JSXOpeningElement(it) => it.span(), + Self::JSXClosingElement(it) => it.span(), + Self::JSXFragment(it) => it.span(), + Self::JSXElementName(it) => it.span(), + Self::JSXNamespacedName(it) => it.span(), + Self::JSXMemberExpression(it) => it.span(), + Self::JSXMemberExpressionObject(it) => it.span(), + Self::JSXExpressionContainer(it) => it.span(), + Self::JSXAttributeItem(it) => it.span(), + Self::JSXSpreadAttribute(it) => it.span(), + Self::JSXIdentifier(it) => it.span(), + Self::JSXText(it) => it.span(), Self::TSThisParameter(it) => it.span(), Self::TSEnumDeclaration(it) => it.span(), Self::TSEnumMember(it) => it.span(), @@ -532,78 +545,11 @@ impl GetSpan for AstKind<'_> { Self::Decorator(it) => it.span(), Self::TSExportAssignment(it) => it.span(), Self::TSInstantiationExpression(it) => it.span(), - Self::JSXElement(it) => it.span(), - Self::JSXOpeningElement(it) => it.span(), - Self::JSXClosingElement(it) => it.span(), - Self::JSXFragment(it) => it.span(), - Self::JSXElementName(it) => it.span(), - Self::JSXNamespacedName(it) => it.span(), - Self::JSXMemberExpression(it) => it.span(), - Self::JSXMemberExpressionObject(it) => it.span(), - Self::JSXExpressionContainer(it) => it.span(), - Self::JSXAttributeItem(it) => it.span(), - Self::JSXSpreadAttribute(it) => it.span(), - Self::JSXIdentifier(it) => it.span(), - Self::JSXText(it) => it.span(), } } } impl<'a> AstKind<'a> { - #[inline] - pub fn as_boolean_literal(self) -> Option<&'a BooleanLiteral> { - if let Self::BooleanLiteral(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_null_literal(self) -> Option<&'a NullLiteral> { - if let Self::NullLiteral(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_numeric_literal(self) -> Option<&'a NumericLiteral<'a>> { - if let Self::NumericLiteral(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_string_literal(self) -> Option<&'a StringLiteral<'a>> { - if let Self::StringLiteral(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_big_int_literal(self) -> Option<&'a BigIntLiteral<'a>> { - if let Self::BigIntLiteral(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_reg_exp_literal(self) -> Option<&'a RegExpLiteral<'a>> { - if let Self::RegExpLiteral(v) = self { - Some(v) - } else { - None - } - } - #[inline] pub fn as_program(self) -> Option<&'a Program<'a>> { if let Self::Program(v) = self { @@ -1414,6 +1360,177 @@ impl<'a> AstKind<'a> { } } + #[inline] + pub fn as_boolean_literal(self) -> Option<&'a BooleanLiteral> { + if let Self::BooleanLiteral(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_null_literal(self) -> Option<&'a NullLiteral> { + if let Self::NullLiteral(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_numeric_literal(self) -> Option<&'a NumericLiteral<'a>> { + if let Self::NumericLiteral(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_string_literal(self) -> Option<&'a StringLiteral<'a>> { + if let Self::StringLiteral(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_big_int_literal(self) -> Option<&'a BigIntLiteral<'a>> { + if let Self::BigIntLiteral(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_reg_exp_literal(self) -> Option<&'a RegExpLiteral<'a>> { + if let Self::RegExpLiteral(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_element(self) -> Option<&'a JSXElement<'a>> { + if let Self::JSXElement(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_opening_element(self) -> Option<&'a JSXOpeningElement<'a>> { + if let Self::JSXOpeningElement(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_closing_element(self) -> Option<&'a JSXClosingElement<'a>> { + if let Self::JSXClosingElement(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_fragment(self) -> Option<&'a JSXFragment<'a>> { + if let Self::JSXFragment(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_element_name(self) -> Option<&'a JSXElementName<'a>> { + if let Self::JSXElementName(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_namespaced_name(self) -> Option<&'a JSXNamespacedName<'a>> { + if let Self::JSXNamespacedName(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_member_expression(self) -> Option<&'a JSXMemberExpression<'a>> { + if let Self::JSXMemberExpression(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_member_expression_object(self) -> Option<&'a JSXMemberExpressionObject<'a>> { + if let Self::JSXMemberExpressionObject(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_expression_container(self) -> Option<&'a JSXExpressionContainer<'a>> { + if let Self::JSXExpressionContainer(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_attribute_item(self) -> Option<&'a JSXAttributeItem<'a>> { + if let Self::JSXAttributeItem(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_spread_attribute(self) -> Option<&'a JSXSpreadAttribute<'a>> { + if let Self::JSXSpreadAttribute(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_identifier(self) -> Option<&'a JSXIdentifier<'a>> { + if let Self::JSXIdentifier(v) = self { + Some(v) + } else { + None + } + } + + #[inline] + pub fn as_jsx_text(self) -> Option<&'a JSXText<'a>> { + if let Self::JSXText(v) = self { + Some(v) + } else { + None + } + } + #[inline] pub fn as_ts_this_parameter(self) -> Option<&'a TSThisParameter<'a>> { if let Self::TSThisParameter(v) = self { @@ -1921,121 +2038,4 @@ impl<'a> AstKind<'a> { None } } - - #[inline] - pub fn as_jsx_element(self) -> Option<&'a JSXElement<'a>> { - if let Self::JSXElement(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_opening_element(self) -> Option<&'a JSXOpeningElement<'a>> { - if let Self::JSXOpeningElement(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_closing_element(self) -> Option<&'a JSXClosingElement<'a>> { - if let Self::JSXClosingElement(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_fragment(self) -> Option<&'a JSXFragment<'a>> { - if let Self::JSXFragment(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_element_name(self) -> Option<&'a JSXElementName<'a>> { - if let Self::JSXElementName(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_namespaced_name(self) -> Option<&'a JSXNamespacedName<'a>> { - if let Self::JSXNamespacedName(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_member_expression(self) -> Option<&'a JSXMemberExpression<'a>> { - if let Self::JSXMemberExpression(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_member_expression_object(self) -> Option<&'a JSXMemberExpressionObject<'a>> { - if let Self::JSXMemberExpressionObject(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_expression_container(self) -> Option<&'a JSXExpressionContainer<'a>> { - if let Self::JSXExpressionContainer(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_attribute_item(self) -> Option<&'a JSXAttributeItem<'a>> { - if let Self::JSXAttributeItem(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_spread_attribute(self) -> Option<&'a JSXSpreadAttribute<'a>> { - if let Self::JSXSpreadAttribute(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_identifier(self) -> Option<&'a JSXIdentifier<'a>> { - if let Self::JSXIdentifier(v) = self { - Some(v) - } else { - None - } - } - - #[inline] - pub fn as_jsx_text(self) -> Option<&'a JSXText<'a>> { - if let Self::JSXText(v) = self { - Some(v) - } else { - None - } - } } diff --git a/crates/oxc_ast/src/generated/derive_clone_in.rs b/crates/oxc_ast/src/generated/derive_clone_in.rs index d786f857c792a..a017734b250fc 100644 --- a/crates/oxc_ast/src/generated/derive_clone_in.rs +++ b/crates/oxc_ast/src/generated/derive_clone_in.rs @@ -11,89 +11,6 @@ use crate::ast::jsx::*; use crate::ast::literal::*; use crate::ast::ts::*; -impl<'alloc> CloneIn<'alloc> for BooleanLiteral { - type Cloned = BooleanLiteral; - fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { - BooleanLiteral { - span: CloneIn::clone_in(&self.span, allocator), - value: CloneIn::clone_in(&self.value, allocator), - } - } -} - -impl<'alloc> CloneIn<'alloc> for NullLiteral { - type Cloned = NullLiteral; - fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { - NullLiteral { span: CloneIn::clone_in(&self.span, allocator) } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for NumericLiteral<'_> { - type Cloned = NumericLiteral<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - NumericLiteral { - span: CloneIn::clone_in(&self.span, allocator), - value: CloneIn::clone_in(&self.value, allocator), - raw: CloneIn::clone_in(&self.raw, allocator), - base: CloneIn::clone_in(&self.base, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for StringLiteral<'_> { - type Cloned = StringLiteral<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - StringLiteral { - span: CloneIn::clone_in(&self.span, allocator), - value: CloneIn::clone_in(&self.value, allocator), - raw: CloneIn::clone_in(&self.raw, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for BigIntLiteral<'_> { - type Cloned = BigIntLiteral<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - BigIntLiteral { - span: CloneIn::clone_in(&self.span, allocator), - raw: CloneIn::clone_in(&self.raw, allocator), - base: CloneIn::clone_in(&self.base, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for RegExpLiteral<'_> { - type Cloned = RegExpLiteral<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - RegExpLiteral { - span: CloneIn::clone_in(&self.span, allocator), - regex: CloneIn::clone_in(&self.regex, allocator), - raw: CloneIn::clone_in(&self.raw, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for RegExp<'_> { - type Cloned = RegExp<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - RegExp { - pattern: CloneIn::clone_in(&self.pattern, allocator), - flags: CloneIn::clone_in(&self.flags, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for RegExpPattern<'_> { - type Cloned = RegExpPattern<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::Raw(it) => RegExpPattern::Raw(CloneIn::clone_in(it, allocator)), - Self::Invalid(it) => RegExpPattern::Invalid(CloneIn::clone_in(it, allocator)), - Self::Pattern(it) => RegExpPattern::Pattern(CloneIn::clone_in(it, allocator)), - } - } -} - impl<'new_alloc> CloneIn<'new_alloc> for Program<'_> { type Cloned = Program<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { @@ -2564,112 +2481,564 @@ impl<'new_alloc> CloneIn<'new_alloc> for ModuleExportName<'_> { } } -impl<'new_alloc> CloneIn<'new_alloc> for TSThisParameter<'_> { - type Cloned = TSThisParameter<'new_alloc>; +impl<'alloc> CloneIn<'alloc> for BooleanLiteral { + type Cloned = BooleanLiteral; + fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { + BooleanLiteral { + span: CloneIn::clone_in(&self.span, allocator), + value: CloneIn::clone_in(&self.value, allocator), + } + } +} + +impl<'alloc> CloneIn<'alloc> for NullLiteral { + type Cloned = NullLiteral; + fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { + NullLiteral { span: CloneIn::clone_in(&self.span, allocator) } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for NumericLiteral<'_> { + type Cloned = NumericLiteral<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSThisParameter { + NumericLiteral { span: CloneIn::clone_in(&self.span, allocator), - this_span: CloneIn::clone_in(&self.this_span, allocator), - type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), + value: CloneIn::clone_in(&self.value, allocator), + raw: CloneIn::clone_in(&self.raw, allocator), + base: CloneIn::clone_in(&self.base, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSEnumDeclaration<'_> { - type Cloned = TSEnumDeclaration<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for StringLiteral<'_> { + type Cloned = StringLiteral<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSEnumDeclaration { + StringLiteral { span: CloneIn::clone_in(&self.span, allocator), - id: CloneIn::clone_in(&self.id, allocator), - members: CloneIn::clone_in(&self.members, allocator), - r#const: CloneIn::clone_in(&self.r#const, allocator), - declare: CloneIn::clone_in(&self.declare, allocator), - scope_id: Default::default(), + value: CloneIn::clone_in(&self.value, allocator), + raw: CloneIn::clone_in(&self.raw, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSEnumMember<'_> { - type Cloned = TSEnumMember<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for BigIntLiteral<'_> { + type Cloned = BigIntLiteral<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSEnumMember { + BigIntLiteral { span: CloneIn::clone_in(&self.span, allocator), - id: CloneIn::clone_in(&self.id, allocator), - initializer: CloneIn::clone_in(&self.initializer, allocator), + raw: CloneIn::clone_in(&self.raw, allocator), + base: CloneIn::clone_in(&self.base, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSEnumMemberName<'_> { - type Cloned = TSEnumMemberName<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for RegExpLiteral<'_> { + type Cloned = RegExpLiteral<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + RegExpLiteral { + span: CloneIn::clone_in(&self.span, allocator), + regex: CloneIn::clone_in(&self.regex, allocator), + raw: CloneIn::clone_in(&self.raw, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for RegExp<'_> { + type Cloned = RegExp<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + RegExp { + pattern: CloneIn::clone_in(&self.pattern, allocator), + flags: CloneIn::clone_in(&self.flags, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for RegExpPattern<'_> { + type Cloned = RegExpPattern<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { match self { - Self::Identifier(it) => TSEnumMemberName::Identifier(CloneIn::clone_in(it, allocator)), - Self::String(it) => TSEnumMemberName::String(CloneIn::clone_in(it, allocator)), + Self::Raw(it) => RegExpPattern::Raw(CloneIn::clone_in(it, allocator)), + Self::Invalid(it) => RegExpPattern::Invalid(CloneIn::clone_in(it, allocator)), + Self::Pattern(it) => RegExpPattern::Pattern(CloneIn::clone_in(it, allocator)), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSTypeAnnotation<'_> { - type Cloned = TSTypeAnnotation<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for JSXElement<'_> { + type Cloned = JSXElement<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSTypeAnnotation { + JSXElement { span: CloneIn::clone_in(&self.span, allocator), - type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), + opening_element: CloneIn::clone_in(&self.opening_element, allocator), + closing_element: CloneIn::clone_in(&self.closing_element, allocator), + children: CloneIn::clone_in(&self.children, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSLiteralType<'_> { - type Cloned = TSLiteralType<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for JSXOpeningElement<'_> { + type Cloned = JSXOpeningElement<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSLiteralType { + JSXOpeningElement { span: CloneIn::clone_in(&self.span, allocator), - literal: CloneIn::clone_in(&self.literal, allocator), + self_closing: CloneIn::clone_in(&self.self_closing, allocator), + name: CloneIn::clone_in(&self.name, allocator), + attributes: CloneIn::clone_in(&self.attributes, allocator), + type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSLiteral<'_> { - type Cloned = TSLiteral<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for JSXClosingElement<'_> { + type Cloned = JSXClosingElement<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::BooleanLiteral(it) => TSLiteral::BooleanLiteral(CloneIn::clone_in(it, allocator)), - Self::NullLiteral(it) => TSLiteral::NullLiteral(CloneIn::clone_in(it, allocator)), - Self::NumericLiteral(it) => TSLiteral::NumericLiteral(CloneIn::clone_in(it, allocator)), - Self::BigIntLiteral(it) => TSLiteral::BigIntLiteral(CloneIn::clone_in(it, allocator)), - Self::RegExpLiteral(it) => TSLiteral::RegExpLiteral(CloneIn::clone_in(it, allocator)), - Self::StringLiteral(it) => TSLiteral::StringLiteral(CloneIn::clone_in(it, allocator)), - Self::TemplateLiteral(it) => { - TSLiteral::TemplateLiteral(CloneIn::clone_in(it, allocator)) - } - Self::UnaryExpression(it) => { - TSLiteral::UnaryExpression(CloneIn::clone_in(it, allocator)) - } + JSXClosingElement { + span: CloneIn::clone_in(&self.span, allocator), + name: CloneIn::clone_in(&self.name, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSType<'_> { - type Cloned = TSType<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for JSXFragment<'_> { + type Cloned = JSXFragment<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXFragment { + span: CloneIn::clone_in(&self.span, allocator), + opening_fragment: CloneIn::clone_in(&self.opening_fragment, allocator), + closing_fragment: CloneIn::clone_in(&self.closing_fragment, allocator), + children: CloneIn::clone_in(&self.children, allocator), + } + } +} + +impl<'alloc> CloneIn<'alloc> for JSXOpeningFragment { + type Cloned = JSXOpeningFragment; + fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { + JSXOpeningFragment { span: CloneIn::clone_in(&self.span, allocator) } + } +} + +impl<'alloc> CloneIn<'alloc> for JSXClosingFragment { + type Cloned = JSXClosingFragment; + fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { + JSXClosingFragment { span: CloneIn::clone_in(&self.span, allocator) } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXElementName<'_> { + type Cloned = JSXElementName<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { match self { - Self::TSAnyKeyword(it) => TSType::TSAnyKeyword(CloneIn::clone_in(it, allocator)), - Self::TSBigIntKeyword(it) => TSType::TSBigIntKeyword(CloneIn::clone_in(it, allocator)), - Self::TSBooleanKeyword(it) => { - TSType::TSBooleanKeyword(CloneIn::clone_in(it, allocator)) + Self::Identifier(it) => JSXElementName::Identifier(CloneIn::clone_in(it, allocator)), + Self::IdentifierReference(it) => { + JSXElementName::IdentifierReference(CloneIn::clone_in(it, allocator)) } - Self::TSIntrinsicKeyword(it) => { - TSType::TSIntrinsicKeyword(CloneIn::clone_in(it, allocator)) + Self::NamespacedName(it) => { + JSXElementName::NamespacedName(CloneIn::clone_in(it, allocator)) } - Self::TSNeverKeyword(it) => TSType::TSNeverKeyword(CloneIn::clone_in(it, allocator)), - Self::TSNullKeyword(it) => TSType::TSNullKeyword(CloneIn::clone_in(it, allocator)), - Self::TSNumberKeyword(it) => TSType::TSNumberKeyword(CloneIn::clone_in(it, allocator)), - Self::TSObjectKeyword(it) => TSType::TSObjectKeyword(CloneIn::clone_in(it, allocator)), - Self::TSStringKeyword(it) => TSType::TSStringKeyword(CloneIn::clone_in(it, allocator)), - Self::TSSymbolKeyword(it) => TSType::TSSymbolKeyword(CloneIn::clone_in(it, allocator)), - Self::TSUndefinedKeyword(it) => { - TSType::TSUndefinedKeyword(CloneIn::clone_in(it, allocator)) + Self::MemberExpression(it) => { + JSXElementName::MemberExpression(CloneIn::clone_in(it, allocator)) + } + Self::ThisExpression(it) => { + JSXElementName::ThisExpression(CloneIn::clone_in(it, allocator)) + } + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXNamespacedName<'_> { + type Cloned = JSXNamespacedName<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXNamespacedName { + span: CloneIn::clone_in(&self.span, allocator), + namespace: CloneIn::clone_in(&self.namespace, allocator), + property: CloneIn::clone_in(&self.property, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXMemberExpression<'_> { + type Cloned = JSXMemberExpression<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXMemberExpression { + span: CloneIn::clone_in(&self.span, allocator), + object: CloneIn::clone_in(&self.object, allocator), + property: CloneIn::clone_in(&self.property, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXMemberExpressionObject<'_> { + type Cloned = JSXMemberExpressionObject<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::IdentifierReference(it) => { + JSXMemberExpressionObject::IdentifierReference(CloneIn::clone_in(it, allocator)) + } + Self::MemberExpression(it) => { + JSXMemberExpressionObject::MemberExpression(CloneIn::clone_in(it, allocator)) + } + Self::ThisExpression(it) => { + JSXMemberExpressionObject::ThisExpression(CloneIn::clone_in(it, allocator)) + } + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXExpressionContainer<'_> { + type Cloned = JSXExpressionContainer<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXExpressionContainer { + span: CloneIn::clone_in(&self.span, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXExpression<'_> { + type Cloned = JSXExpression<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::EmptyExpression(it) => { + JSXExpression::EmptyExpression(CloneIn::clone_in(it, allocator)) + } + Self::BooleanLiteral(it) => { + JSXExpression::BooleanLiteral(CloneIn::clone_in(it, allocator)) + } + Self::NullLiteral(it) => JSXExpression::NullLiteral(CloneIn::clone_in(it, allocator)), + Self::NumericLiteral(it) => { + JSXExpression::NumericLiteral(CloneIn::clone_in(it, allocator)) + } + Self::BigIntLiteral(it) => { + JSXExpression::BigIntLiteral(CloneIn::clone_in(it, allocator)) + } + Self::RegExpLiteral(it) => { + JSXExpression::RegExpLiteral(CloneIn::clone_in(it, allocator)) + } + Self::StringLiteral(it) => { + JSXExpression::StringLiteral(CloneIn::clone_in(it, allocator)) + } + Self::TemplateLiteral(it) => { + JSXExpression::TemplateLiteral(CloneIn::clone_in(it, allocator)) + } + Self::Identifier(it) => JSXExpression::Identifier(CloneIn::clone_in(it, allocator)), + Self::MetaProperty(it) => JSXExpression::MetaProperty(CloneIn::clone_in(it, allocator)), + Self::Super(it) => JSXExpression::Super(CloneIn::clone_in(it, allocator)), + Self::ArrayExpression(it) => { + JSXExpression::ArrayExpression(CloneIn::clone_in(it, allocator)) + } + Self::ArrowFunctionExpression(it) => { + JSXExpression::ArrowFunctionExpression(CloneIn::clone_in(it, allocator)) + } + Self::AssignmentExpression(it) => { + JSXExpression::AssignmentExpression(CloneIn::clone_in(it, allocator)) + } + Self::AwaitExpression(it) => { + JSXExpression::AwaitExpression(CloneIn::clone_in(it, allocator)) + } + Self::BinaryExpression(it) => { + JSXExpression::BinaryExpression(CloneIn::clone_in(it, allocator)) + } + Self::CallExpression(it) => { + JSXExpression::CallExpression(CloneIn::clone_in(it, allocator)) + } + Self::ChainExpression(it) => { + JSXExpression::ChainExpression(CloneIn::clone_in(it, allocator)) + } + Self::ClassExpression(it) => { + JSXExpression::ClassExpression(CloneIn::clone_in(it, allocator)) + } + Self::ConditionalExpression(it) => { + JSXExpression::ConditionalExpression(CloneIn::clone_in(it, allocator)) + } + Self::FunctionExpression(it) => { + JSXExpression::FunctionExpression(CloneIn::clone_in(it, allocator)) + } + Self::ImportExpression(it) => { + JSXExpression::ImportExpression(CloneIn::clone_in(it, allocator)) + } + Self::LogicalExpression(it) => { + JSXExpression::LogicalExpression(CloneIn::clone_in(it, allocator)) + } + Self::NewExpression(it) => { + JSXExpression::NewExpression(CloneIn::clone_in(it, allocator)) + } + Self::ObjectExpression(it) => { + JSXExpression::ObjectExpression(CloneIn::clone_in(it, allocator)) + } + Self::ParenthesizedExpression(it) => { + JSXExpression::ParenthesizedExpression(CloneIn::clone_in(it, allocator)) + } + Self::SequenceExpression(it) => { + JSXExpression::SequenceExpression(CloneIn::clone_in(it, allocator)) + } + Self::TaggedTemplateExpression(it) => { + JSXExpression::TaggedTemplateExpression(CloneIn::clone_in(it, allocator)) + } + Self::ThisExpression(it) => { + JSXExpression::ThisExpression(CloneIn::clone_in(it, allocator)) + } + Self::UnaryExpression(it) => { + JSXExpression::UnaryExpression(CloneIn::clone_in(it, allocator)) + } + Self::UpdateExpression(it) => { + JSXExpression::UpdateExpression(CloneIn::clone_in(it, allocator)) + } + Self::YieldExpression(it) => { + JSXExpression::YieldExpression(CloneIn::clone_in(it, allocator)) + } + Self::PrivateInExpression(it) => { + JSXExpression::PrivateInExpression(CloneIn::clone_in(it, allocator)) + } + Self::JSXElement(it) => JSXExpression::JSXElement(CloneIn::clone_in(it, allocator)), + Self::JSXFragment(it) => JSXExpression::JSXFragment(CloneIn::clone_in(it, allocator)), + Self::TSAsExpression(it) => { + JSXExpression::TSAsExpression(CloneIn::clone_in(it, allocator)) + } + Self::TSSatisfiesExpression(it) => { + JSXExpression::TSSatisfiesExpression(CloneIn::clone_in(it, allocator)) + } + Self::TSTypeAssertion(it) => { + JSXExpression::TSTypeAssertion(CloneIn::clone_in(it, allocator)) + } + Self::TSNonNullExpression(it) => { + JSXExpression::TSNonNullExpression(CloneIn::clone_in(it, allocator)) + } + Self::TSInstantiationExpression(it) => { + JSXExpression::TSInstantiationExpression(CloneIn::clone_in(it, allocator)) + } + Self::ComputedMemberExpression(it) => { + JSXExpression::ComputedMemberExpression(CloneIn::clone_in(it, allocator)) + } + Self::StaticMemberExpression(it) => { + JSXExpression::StaticMemberExpression(CloneIn::clone_in(it, allocator)) + } + Self::PrivateFieldExpression(it) => { + JSXExpression::PrivateFieldExpression(CloneIn::clone_in(it, allocator)) + } + } + } +} + +impl<'alloc> CloneIn<'alloc> for JSXEmptyExpression { + type Cloned = JSXEmptyExpression; + fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { + JSXEmptyExpression { span: CloneIn::clone_in(&self.span, allocator) } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXAttributeItem<'_> { + type Cloned = JSXAttributeItem<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::Attribute(it) => JSXAttributeItem::Attribute(CloneIn::clone_in(it, allocator)), + Self::SpreadAttribute(it) => { + JSXAttributeItem::SpreadAttribute(CloneIn::clone_in(it, allocator)) + } + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXAttribute<'_> { + type Cloned = JSXAttribute<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXAttribute { + span: CloneIn::clone_in(&self.span, allocator), + name: CloneIn::clone_in(&self.name, allocator), + value: CloneIn::clone_in(&self.value, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXSpreadAttribute<'_> { + type Cloned = JSXSpreadAttribute<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXSpreadAttribute { + span: CloneIn::clone_in(&self.span, allocator), + argument: CloneIn::clone_in(&self.argument, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXAttributeName<'_> { + type Cloned = JSXAttributeName<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::Identifier(it) => JSXAttributeName::Identifier(CloneIn::clone_in(it, allocator)), + Self::NamespacedName(it) => { + JSXAttributeName::NamespacedName(CloneIn::clone_in(it, allocator)) + } + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXAttributeValue<'_> { + type Cloned = JSXAttributeValue<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::StringLiteral(it) => { + JSXAttributeValue::StringLiteral(CloneIn::clone_in(it, allocator)) + } + Self::ExpressionContainer(it) => { + JSXAttributeValue::ExpressionContainer(CloneIn::clone_in(it, allocator)) + } + Self::Element(it) => JSXAttributeValue::Element(CloneIn::clone_in(it, allocator)), + Self::Fragment(it) => JSXAttributeValue::Fragment(CloneIn::clone_in(it, allocator)), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXIdentifier<'_> { + type Cloned = JSXIdentifier<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXIdentifier { + span: CloneIn::clone_in(&self.span, allocator), + name: CloneIn::clone_in(&self.name, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXChild<'_> { + type Cloned = JSXChild<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::Text(it) => JSXChild::Text(CloneIn::clone_in(it, allocator)), + Self::Element(it) => JSXChild::Element(CloneIn::clone_in(it, allocator)), + Self::Fragment(it) => JSXChild::Fragment(CloneIn::clone_in(it, allocator)), + Self::ExpressionContainer(it) => { + JSXChild::ExpressionContainer(CloneIn::clone_in(it, allocator)) + } + Self::Spread(it) => JSXChild::Spread(CloneIn::clone_in(it, allocator)), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXSpreadChild<'_> { + type Cloned = JSXSpreadChild<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXSpreadChild { + span: CloneIn::clone_in(&self.span, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for JSXText<'_> { + type Cloned = JSXText<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + JSXText { + span: CloneIn::clone_in(&self.span, allocator), + value: CloneIn::clone_in(&self.value, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSThisParameter<'_> { + type Cloned = TSThisParameter<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + TSThisParameter { + span: CloneIn::clone_in(&self.span, allocator), + this_span: CloneIn::clone_in(&self.this_span, allocator), + type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSEnumDeclaration<'_> { + type Cloned = TSEnumDeclaration<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + TSEnumDeclaration { + span: CloneIn::clone_in(&self.span, allocator), + id: CloneIn::clone_in(&self.id, allocator), + members: CloneIn::clone_in(&self.members, allocator), + r#const: CloneIn::clone_in(&self.r#const, allocator), + declare: CloneIn::clone_in(&self.declare, allocator), + scope_id: Default::default(), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSEnumMember<'_> { + type Cloned = TSEnumMember<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + TSEnumMember { + span: CloneIn::clone_in(&self.span, allocator), + id: CloneIn::clone_in(&self.id, allocator), + initializer: CloneIn::clone_in(&self.initializer, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSEnumMemberName<'_> { + type Cloned = TSEnumMemberName<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::Identifier(it) => TSEnumMemberName::Identifier(CloneIn::clone_in(it, allocator)), + Self::String(it) => TSEnumMemberName::String(CloneIn::clone_in(it, allocator)), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSTypeAnnotation<'_> { + type Cloned = TSTypeAnnotation<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + TSTypeAnnotation { + span: CloneIn::clone_in(&self.span, allocator), + type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSLiteralType<'_> { + type Cloned = TSLiteralType<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + TSLiteralType { + span: CloneIn::clone_in(&self.span, allocator), + literal: CloneIn::clone_in(&self.literal, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSLiteral<'_> { + type Cloned = TSLiteral<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::BooleanLiteral(it) => TSLiteral::BooleanLiteral(CloneIn::clone_in(it, allocator)), + Self::NullLiteral(it) => TSLiteral::NullLiteral(CloneIn::clone_in(it, allocator)), + Self::NumericLiteral(it) => TSLiteral::NumericLiteral(CloneIn::clone_in(it, allocator)), + Self::BigIntLiteral(it) => TSLiteral::BigIntLiteral(CloneIn::clone_in(it, allocator)), + Self::RegExpLiteral(it) => TSLiteral::RegExpLiteral(CloneIn::clone_in(it, allocator)), + Self::StringLiteral(it) => TSLiteral::StringLiteral(CloneIn::clone_in(it, allocator)), + Self::TemplateLiteral(it) => { + TSLiteral::TemplateLiteral(CloneIn::clone_in(it, allocator)) + } + Self::UnaryExpression(it) => { + TSLiteral::UnaryExpression(CloneIn::clone_in(it, allocator)) + } + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSType<'_> { + type Cloned = TSType<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + match self { + Self::TSAnyKeyword(it) => TSType::TSAnyKeyword(CloneIn::clone_in(it, allocator)), + Self::TSBigIntKeyword(it) => TSType::TSBigIntKeyword(CloneIn::clone_in(it, allocator)), + Self::TSBooleanKeyword(it) => { + TSType::TSBooleanKeyword(CloneIn::clone_in(it, allocator)) + } + Self::TSIntrinsicKeyword(it) => { + TSType::TSIntrinsicKeyword(CloneIn::clone_in(it, allocator)) + } + Self::TSNeverKeyword(it) => TSType::TSNeverKeyword(CloneIn::clone_in(it, allocator)), + Self::TSNullKeyword(it) => TSType::TSNullKeyword(CloneIn::clone_in(it, allocator)), + Self::TSNumberKeyword(it) => TSType::TSNumberKeyword(CloneIn::clone_in(it, allocator)), + Self::TSObjectKeyword(it) => TSType::TSObjectKeyword(CloneIn::clone_in(it, allocator)), + Self::TSStringKeyword(it) => TSType::TSStringKeyword(CloneIn::clone_in(it, allocator)), + Self::TSSymbolKeyword(it) => TSType::TSSymbolKeyword(CloneIn::clone_in(it, allocator)), + Self::TSUndefinedKeyword(it) => { + TSType::TSUndefinedKeyword(CloneIn::clone_in(it, allocator)) } Self::TSUnknownKeyword(it) => { TSType::TSUnknownKeyword(CloneIn::clone_in(it, allocator)) @@ -3366,745 +3735,376 @@ impl<'alloc> CloneIn<'alloc> for TSModuleDeclarationKind { type Cloned = TSModuleDeclarationKind; fn clone_in(&self, _: &'alloc Allocator) -> Self::Cloned { match self { - Self::Global => TSModuleDeclarationKind::Global, - Self::Module => TSModuleDeclarationKind::Module, - Self::Namespace => TSModuleDeclarationKind::Namespace, - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSModuleDeclarationName<'_> { - type Cloned = TSModuleDeclarationName<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::Identifier(it) => { - TSModuleDeclarationName::Identifier(CloneIn::clone_in(it, allocator)) - } - Self::StringLiteral(it) => { - TSModuleDeclarationName::StringLiteral(CloneIn::clone_in(it, allocator)) - } - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSModuleDeclarationBody<'_> { - type Cloned = TSModuleDeclarationBody<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::TSModuleDeclaration(it) => { - TSModuleDeclarationBody::TSModuleDeclaration(CloneIn::clone_in(it, allocator)) - } - Self::TSModuleBlock(it) => { - TSModuleDeclarationBody::TSModuleBlock(CloneIn::clone_in(it, allocator)) - } - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSModuleBlock<'_> { - type Cloned = TSModuleBlock<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSModuleBlock { - span: CloneIn::clone_in(&self.span, allocator), - directives: CloneIn::clone_in(&self.directives, allocator), - body: CloneIn::clone_in(&self.body, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSTypeLiteral<'_> { - type Cloned = TSTypeLiteral<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSTypeLiteral { - span: CloneIn::clone_in(&self.span, allocator), - members: CloneIn::clone_in(&self.members, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSInferType<'_> { - type Cloned = TSInferType<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSInferType { - span: CloneIn::clone_in(&self.span, allocator), - type_parameter: CloneIn::clone_in(&self.type_parameter, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSTypeQuery<'_> { - type Cloned = TSTypeQuery<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSTypeQuery { - span: CloneIn::clone_in(&self.span, allocator), - expr_name: CloneIn::clone_in(&self.expr_name, allocator), - type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSTypeQueryExprName<'_> { - type Cloned = TSTypeQueryExprName<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::TSImportType(it) => { - TSTypeQueryExprName::TSImportType(CloneIn::clone_in(it, allocator)) - } - Self::IdentifierReference(it) => { - TSTypeQueryExprName::IdentifierReference(CloneIn::clone_in(it, allocator)) - } - Self::QualifiedName(it) => { - TSTypeQueryExprName::QualifiedName(CloneIn::clone_in(it, allocator)) - } - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSImportType<'_> { - type Cloned = TSImportType<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSImportType { - span: CloneIn::clone_in(&self.span, allocator), - is_type_of: CloneIn::clone_in(&self.is_type_of, allocator), - parameter: CloneIn::clone_in(&self.parameter, allocator), - qualifier: CloneIn::clone_in(&self.qualifier, allocator), - attributes: CloneIn::clone_in(&self.attributes, allocator), - type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSImportAttributes<'_> { - type Cloned = TSImportAttributes<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSImportAttributes { - span: CloneIn::clone_in(&self.span, allocator), - attributes_keyword: CloneIn::clone_in(&self.attributes_keyword, allocator), - elements: CloneIn::clone_in(&self.elements, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSImportAttribute<'_> { - type Cloned = TSImportAttribute<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSImportAttribute { - span: CloneIn::clone_in(&self.span, allocator), - name: CloneIn::clone_in(&self.name, allocator), - value: CloneIn::clone_in(&self.value, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSImportAttributeName<'_> { - type Cloned = TSImportAttributeName<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::Identifier(it) => { - TSImportAttributeName::Identifier(CloneIn::clone_in(it, allocator)) - } - Self::StringLiteral(it) => { - TSImportAttributeName::StringLiteral(CloneIn::clone_in(it, allocator)) - } - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSFunctionType<'_> { - type Cloned = TSFunctionType<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSFunctionType { - span: CloneIn::clone_in(&self.span, allocator), - type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), - this_param: CloneIn::clone_in(&self.this_param, allocator), - params: CloneIn::clone_in(&self.params, allocator), - return_type: CloneIn::clone_in(&self.return_type, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSConstructorType<'_> { - type Cloned = TSConstructorType<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSConstructorType { - span: CloneIn::clone_in(&self.span, allocator), - r#abstract: CloneIn::clone_in(&self.r#abstract, allocator), - type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), - params: CloneIn::clone_in(&self.params, allocator), - return_type: CloneIn::clone_in(&self.return_type, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSMappedType<'_> { - type Cloned = TSMappedType<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSMappedType { - span: CloneIn::clone_in(&self.span, allocator), - type_parameter: CloneIn::clone_in(&self.type_parameter, allocator), - name_type: CloneIn::clone_in(&self.name_type, allocator), - type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), - optional: CloneIn::clone_in(&self.optional, allocator), - readonly: CloneIn::clone_in(&self.readonly, allocator), - scope_id: Default::default(), - } - } -} - -impl<'alloc> CloneIn<'alloc> for TSMappedTypeModifierOperator { - type Cloned = TSMappedTypeModifierOperator; - fn clone_in(&self, _: &'alloc Allocator) -> Self::Cloned { - match self { - Self::True => TSMappedTypeModifierOperator::True, - Self::Plus => TSMappedTypeModifierOperator::Plus, - Self::Minus => TSMappedTypeModifierOperator::Minus, - Self::None => TSMappedTypeModifierOperator::None, - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSTemplateLiteralType<'_> { - type Cloned = TSTemplateLiteralType<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSTemplateLiteralType { - span: CloneIn::clone_in(&self.span, allocator), - quasis: CloneIn::clone_in(&self.quasis, allocator), - types: CloneIn::clone_in(&self.types, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSAsExpression<'_> { - type Cloned = TSAsExpression<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSAsExpression { - span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), - type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSSatisfiesExpression<'_> { - type Cloned = TSSatisfiesExpression<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSSatisfiesExpression { - span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), - type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSTypeAssertion<'_> { - type Cloned = TSTypeAssertion<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSTypeAssertion { - span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), - type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSImportEqualsDeclaration<'_> { - type Cloned = TSImportEqualsDeclaration<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSImportEqualsDeclaration { - span: CloneIn::clone_in(&self.span, allocator), - id: CloneIn::clone_in(&self.id, allocator), - module_reference: CloneIn::clone_in(&self.module_reference, allocator), - import_kind: CloneIn::clone_in(&self.import_kind, allocator), + Self::Global => TSModuleDeclarationKind::Global, + Self::Module => TSModuleDeclarationKind::Module, + Self::Namespace => TSModuleDeclarationKind::Namespace, } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSModuleReference<'_> { - type Cloned = TSModuleReference<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSModuleDeclarationName<'_> { + type Cloned = TSModuleDeclarationName<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { match self { - Self::ExternalModuleReference(it) => { - TSModuleReference::ExternalModuleReference(CloneIn::clone_in(it, allocator)) - } - Self::IdentifierReference(it) => { - TSModuleReference::IdentifierReference(CloneIn::clone_in(it, allocator)) + Self::Identifier(it) => { + TSModuleDeclarationName::Identifier(CloneIn::clone_in(it, allocator)) } - Self::QualifiedName(it) => { - TSModuleReference::QualifiedName(CloneIn::clone_in(it, allocator)) + Self::StringLiteral(it) => { + TSModuleDeclarationName::StringLiteral(CloneIn::clone_in(it, allocator)) } } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSExternalModuleReference<'_> { - type Cloned = TSExternalModuleReference<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSExternalModuleReference { - span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), - } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for TSNonNullExpression<'_> { - type Cloned = TSNonNullExpression<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSModuleDeclarationBody<'_> { + type Cloned = TSModuleDeclarationBody<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSNonNullExpression { - span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), + match self { + Self::TSModuleDeclaration(it) => { + TSModuleDeclarationBody::TSModuleDeclaration(CloneIn::clone_in(it, allocator)) + } + Self::TSModuleBlock(it) => { + TSModuleDeclarationBody::TSModuleBlock(CloneIn::clone_in(it, allocator)) + } } } } -impl<'new_alloc> CloneIn<'new_alloc> for Decorator<'_> { - type Cloned = Decorator<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSModuleBlock<'_> { + type Cloned = TSModuleBlock<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - Decorator { + TSModuleBlock { span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), + directives: CloneIn::clone_in(&self.directives, allocator), + body: CloneIn::clone_in(&self.body, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSExportAssignment<'_> { - type Cloned = TSExportAssignment<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSTypeLiteral<'_> { + type Cloned = TSTypeLiteral<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSExportAssignment { + TSTypeLiteral { span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), + members: CloneIn::clone_in(&self.members, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSNamespaceExportDeclaration<'_> { - type Cloned = TSNamespaceExportDeclaration<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSInferType<'_> { + type Cloned = TSInferType<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSNamespaceExportDeclaration { + TSInferType { span: CloneIn::clone_in(&self.span, allocator), - id: CloneIn::clone_in(&self.id, allocator), + type_parameter: CloneIn::clone_in(&self.type_parameter, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for TSInstantiationExpression<'_> { - type Cloned = TSInstantiationExpression<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSTypeQuery<'_> { + type Cloned = TSTypeQuery<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - TSInstantiationExpression { + TSTypeQuery { span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), + expr_name: CloneIn::clone_in(&self.expr_name, allocator), type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), } } } -impl<'alloc> CloneIn<'alloc> for ImportOrExportKind { - type Cloned = ImportOrExportKind; - fn clone_in(&self, _: &'alloc Allocator) -> Self::Cloned { +impl<'new_alloc> CloneIn<'new_alloc> for TSTypeQueryExprName<'_> { + type Cloned = TSTypeQueryExprName<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { match self { - Self::Value => ImportOrExportKind::Value, - Self::Type => ImportOrExportKind::Type, + Self::TSImportType(it) => { + TSTypeQueryExprName::TSImportType(CloneIn::clone_in(it, allocator)) + } + Self::IdentifierReference(it) => { + TSTypeQueryExprName::IdentifierReference(CloneIn::clone_in(it, allocator)) + } + Self::QualifiedName(it) => { + TSTypeQueryExprName::QualifiedName(CloneIn::clone_in(it, allocator)) + } } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSDocNullableType<'_> { - type Cloned = JSDocNullableType<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSImportType<'_> { + type Cloned = TSImportType<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSDocNullableType { + TSImportType { span: CloneIn::clone_in(&self.span, allocator), - type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), - postfix: CloneIn::clone_in(&self.postfix, allocator), + is_type_of: CloneIn::clone_in(&self.is_type_of, allocator), + parameter: CloneIn::clone_in(&self.parameter, allocator), + qualifier: CloneIn::clone_in(&self.qualifier, allocator), + attributes: CloneIn::clone_in(&self.attributes, allocator), + type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSDocNonNullableType<'_> { - type Cloned = JSDocNonNullableType<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSImportAttributes<'_> { + type Cloned = TSImportAttributes<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSDocNonNullableType { + TSImportAttributes { span: CloneIn::clone_in(&self.span, allocator), - type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), - postfix: CloneIn::clone_in(&self.postfix, allocator), + attributes_keyword: CloneIn::clone_in(&self.attributes_keyword, allocator), + elements: CloneIn::clone_in(&self.elements, allocator), } } } -impl<'alloc> CloneIn<'alloc> for JSDocUnknownType { - type Cloned = JSDocUnknownType; - fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { - JSDocUnknownType { span: CloneIn::clone_in(&self.span, allocator) } +impl<'new_alloc> CloneIn<'new_alloc> for TSImportAttribute<'_> { + type Cloned = TSImportAttribute<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + TSImportAttribute { + span: CloneIn::clone_in(&self.span, allocator), + name: CloneIn::clone_in(&self.name, allocator), + value: CloneIn::clone_in(&self.value, allocator), + } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXElement<'_> { - type Cloned = JSXElement<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSImportAttributeName<'_> { + type Cloned = TSImportAttributeName<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXElement { - span: CloneIn::clone_in(&self.span, allocator), - opening_element: CloneIn::clone_in(&self.opening_element, allocator), - closing_element: CloneIn::clone_in(&self.closing_element, allocator), - children: CloneIn::clone_in(&self.children, allocator), + match self { + Self::Identifier(it) => { + TSImportAttributeName::Identifier(CloneIn::clone_in(it, allocator)) + } + Self::StringLiteral(it) => { + TSImportAttributeName::StringLiteral(CloneIn::clone_in(it, allocator)) + } } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXOpeningElement<'_> { - type Cloned = JSXOpeningElement<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSFunctionType<'_> { + type Cloned = TSFunctionType<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXOpeningElement { + TSFunctionType { span: CloneIn::clone_in(&self.span, allocator), - self_closing: CloneIn::clone_in(&self.self_closing, allocator), - name: CloneIn::clone_in(&self.name, allocator), - attributes: CloneIn::clone_in(&self.attributes, allocator), type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), + this_param: CloneIn::clone_in(&self.this_param, allocator), + params: CloneIn::clone_in(&self.params, allocator), + return_type: CloneIn::clone_in(&self.return_type, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXClosingElement<'_> { - type Cloned = JSXClosingElement<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSConstructorType<'_> { + type Cloned = TSConstructorType<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXClosingElement { + TSConstructorType { span: CloneIn::clone_in(&self.span, allocator), - name: CloneIn::clone_in(&self.name, allocator), + r#abstract: CloneIn::clone_in(&self.r#abstract, allocator), + type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), + params: CloneIn::clone_in(&self.params, allocator), + return_type: CloneIn::clone_in(&self.return_type, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXFragment<'_> { - type Cloned = JSXFragment<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSMappedType<'_> { + type Cloned = TSMappedType<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXFragment { + TSMappedType { span: CloneIn::clone_in(&self.span, allocator), - opening_fragment: CloneIn::clone_in(&self.opening_fragment, allocator), - closing_fragment: CloneIn::clone_in(&self.closing_fragment, allocator), - children: CloneIn::clone_in(&self.children, allocator), + type_parameter: CloneIn::clone_in(&self.type_parameter, allocator), + name_type: CloneIn::clone_in(&self.name_type, allocator), + type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), + optional: CloneIn::clone_in(&self.optional, allocator), + readonly: CloneIn::clone_in(&self.readonly, allocator), + scope_id: Default::default(), } } } -impl<'alloc> CloneIn<'alloc> for JSXOpeningFragment { - type Cloned = JSXOpeningFragment; - fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { - JSXOpeningFragment { span: CloneIn::clone_in(&self.span, allocator) } - } -} - -impl<'alloc> CloneIn<'alloc> for JSXClosingFragment { - type Cloned = JSXClosingFragment; - fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { - JSXClosingFragment { span: CloneIn::clone_in(&self.span, allocator) } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for JSXElementName<'_> { - type Cloned = JSXElementName<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { +impl<'alloc> CloneIn<'alloc> for TSMappedTypeModifierOperator { + type Cloned = TSMappedTypeModifierOperator; + fn clone_in(&self, _: &'alloc Allocator) -> Self::Cloned { match self { - Self::Identifier(it) => JSXElementName::Identifier(CloneIn::clone_in(it, allocator)), - Self::IdentifierReference(it) => { - JSXElementName::IdentifierReference(CloneIn::clone_in(it, allocator)) - } - Self::NamespacedName(it) => { - JSXElementName::NamespacedName(CloneIn::clone_in(it, allocator)) - } - Self::MemberExpression(it) => { - JSXElementName::MemberExpression(CloneIn::clone_in(it, allocator)) - } - Self::ThisExpression(it) => { - JSXElementName::ThisExpression(CloneIn::clone_in(it, allocator)) - } + Self::True => TSMappedTypeModifierOperator::True, + Self::Plus => TSMappedTypeModifierOperator::Plus, + Self::Minus => TSMappedTypeModifierOperator::Minus, + Self::None => TSMappedTypeModifierOperator::None, } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXNamespacedName<'_> { - type Cloned = JSXNamespacedName<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSTemplateLiteralType<'_> { + type Cloned = TSTemplateLiteralType<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXNamespacedName { + TSTemplateLiteralType { span: CloneIn::clone_in(&self.span, allocator), - namespace: CloneIn::clone_in(&self.namespace, allocator), - property: CloneIn::clone_in(&self.property, allocator), + quasis: CloneIn::clone_in(&self.quasis, allocator), + types: CloneIn::clone_in(&self.types, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXMemberExpression<'_> { - type Cloned = JSXMemberExpression<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSAsExpression<'_> { + type Cloned = TSAsExpression<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXMemberExpression { + TSAsExpression { span: CloneIn::clone_in(&self.span, allocator), - object: CloneIn::clone_in(&self.object, allocator), - property: CloneIn::clone_in(&self.property, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), + type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXMemberExpressionObject<'_> { - type Cloned = JSXMemberExpressionObject<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSSatisfiesExpression<'_> { + type Cloned = TSSatisfiesExpression<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::IdentifierReference(it) => { - JSXMemberExpressionObject::IdentifierReference(CloneIn::clone_in(it, allocator)) - } - Self::MemberExpression(it) => { - JSXMemberExpressionObject::MemberExpression(CloneIn::clone_in(it, allocator)) - } - Self::ThisExpression(it) => { - JSXMemberExpressionObject::ThisExpression(CloneIn::clone_in(it, allocator)) - } + TSSatisfiesExpression { + span: CloneIn::clone_in(&self.span, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), + type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXExpressionContainer<'_> { - type Cloned = JSXExpressionContainer<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSTypeAssertion<'_> { + type Cloned = TSTypeAssertion<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXExpressionContainer { + TSTypeAssertion { span: CloneIn::clone_in(&self.span, allocator), expression: CloneIn::clone_in(&self.expression, allocator), + type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXExpression<'_> { - type Cloned = JSXExpression<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSImportEqualsDeclaration<'_> { + type Cloned = TSImportEqualsDeclaration<'new_alloc>; + fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { + TSImportEqualsDeclaration { + span: CloneIn::clone_in(&self.span, allocator), + id: CloneIn::clone_in(&self.id, allocator), + module_reference: CloneIn::clone_in(&self.module_reference, allocator), + import_kind: CloneIn::clone_in(&self.import_kind, allocator), + } + } +} + +impl<'new_alloc> CloneIn<'new_alloc> for TSModuleReference<'_> { + type Cloned = TSModuleReference<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { match self { - Self::EmptyExpression(it) => { - JSXExpression::EmptyExpression(CloneIn::clone_in(it, allocator)) - } - Self::BooleanLiteral(it) => { - JSXExpression::BooleanLiteral(CloneIn::clone_in(it, allocator)) - } - Self::NullLiteral(it) => JSXExpression::NullLiteral(CloneIn::clone_in(it, allocator)), - Self::NumericLiteral(it) => { - JSXExpression::NumericLiteral(CloneIn::clone_in(it, allocator)) - } - Self::BigIntLiteral(it) => { - JSXExpression::BigIntLiteral(CloneIn::clone_in(it, allocator)) - } - Self::RegExpLiteral(it) => { - JSXExpression::RegExpLiteral(CloneIn::clone_in(it, allocator)) - } - Self::StringLiteral(it) => { - JSXExpression::StringLiteral(CloneIn::clone_in(it, allocator)) - } - Self::TemplateLiteral(it) => { - JSXExpression::TemplateLiteral(CloneIn::clone_in(it, allocator)) - } - Self::Identifier(it) => JSXExpression::Identifier(CloneIn::clone_in(it, allocator)), - Self::MetaProperty(it) => JSXExpression::MetaProperty(CloneIn::clone_in(it, allocator)), - Self::Super(it) => JSXExpression::Super(CloneIn::clone_in(it, allocator)), - Self::ArrayExpression(it) => { - JSXExpression::ArrayExpression(CloneIn::clone_in(it, allocator)) - } - Self::ArrowFunctionExpression(it) => { - JSXExpression::ArrowFunctionExpression(CloneIn::clone_in(it, allocator)) - } - Self::AssignmentExpression(it) => { - JSXExpression::AssignmentExpression(CloneIn::clone_in(it, allocator)) - } - Self::AwaitExpression(it) => { - JSXExpression::AwaitExpression(CloneIn::clone_in(it, allocator)) - } - Self::BinaryExpression(it) => { - JSXExpression::BinaryExpression(CloneIn::clone_in(it, allocator)) - } - Self::CallExpression(it) => { - JSXExpression::CallExpression(CloneIn::clone_in(it, allocator)) - } - Self::ChainExpression(it) => { - JSXExpression::ChainExpression(CloneIn::clone_in(it, allocator)) - } - Self::ClassExpression(it) => { - JSXExpression::ClassExpression(CloneIn::clone_in(it, allocator)) - } - Self::ConditionalExpression(it) => { - JSXExpression::ConditionalExpression(CloneIn::clone_in(it, allocator)) - } - Self::FunctionExpression(it) => { - JSXExpression::FunctionExpression(CloneIn::clone_in(it, allocator)) - } - Self::ImportExpression(it) => { - JSXExpression::ImportExpression(CloneIn::clone_in(it, allocator)) - } - Self::LogicalExpression(it) => { - JSXExpression::LogicalExpression(CloneIn::clone_in(it, allocator)) - } - Self::NewExpression(it) => { - JSXExpression::NewExpression(CloneIn::clone_in(it, allocator)) - } - Self::ObjectExpression(it) => { - JSXExpression::ObjectExpression(CloneIn::clone_in(it, allocator)) - } - Self::ParenthesizedExpression(it) => { - JSXExpression::ParenthesizedExpression(CloneIn::clone_in(it, allocator)) - } - Self::SequenceExpression(it) => { - JSXExpression::SequenceExpression(CloneIn::clone_in(it, allocator)) - } - Self::TaggedTemplateExpression(it) => { - JSXExpression::TaggedTemplateExpression(CloneIn::clone_in(it, allocator)) - } - Self::ThisExpression(it) => { - JSXExpression::ThisExpression(CloneIn::clone_in(it, allocator)) - } - Self::UnaryExpression(it) => { - JSXExpression::UnaryExpression(CloneIn::clone_in(it, allocator)) - } - Self::UpdateExpression(it) => { - JSXExpression::UpdateExpression(CloneIn::clone_in(it, allocator)) - } - Self::YieldExpression(it) => { - JSXExpression::YieldExpression(CloneIn::clone_in(it, allocator)) - } - Self::PrivateInExpression(it) => { - JSXExpression::PrivateInExpression(CloneIn::clone_in(it, allocator)) - } - Self::JSXElement(it) => JSXExpression::JSXElement(CloneIn::clone_in(it, allocator)), - Self::JSXFragment(it) => JSXExpression::JSXFragment(CloneIn::clone_in(it, allocator)), - Self::TSAsExpression(it) => { - JSXExpression::TSAsExpression(CloneIn::clone_in(it, allocator)) - } - Self::TSSatisfiesExpression(it) => { - JSXExpression::TSSatisfiesExpression(CloneIn::clone_in(it, allocator)) - } - Self::TSTypeAssertion(it) => { - JSXExpression::TSTypeAssertion(CloneIn::clone_in(it, allocator)) - } - Self::TSNonNullExpression(it) => { - JSXExpression::TSNonNullExpression(CloneIn::clone_in(it, allocator)) - } - Self::TSInstantiationExpression(it) => { - JSXExpression::TSInstantiationExpression(CloneIn::clone_in(it, allocator)) - } - Self::ComputedMemberExpression(it) => { - JSXExpression::ComputedMemberExpression(CloneIn::clone_in(it, allocator)) + Self::ExternalModuleReference(it) => { + TSModuleReference::ExternalModuleReference(CloneIn::clone_in(it, allocator)) } - Self::StaticMemberExpression(it) => { - JSXExpression::StaticMemberExpression(CloneIn::clone_in(it, allocator)) + Self::IdentifierReference(it) => { + TSModuleReference::IdentifierReference(CloneIn::clone_in(it, allocator)) } - Self::PrivateFieldExpression(it) => { - JSXExpression::PrivateFieldExpression(CloneIn::clone_in(it, allocator)) + Self::QualifiedName(it) => { + TSModuleReference::QualifiedName(CloneIn::clone_in(it, allocator)) } } } } -impl<'alloc> CloneIn<'alloc> for JSXEmptyExpression { - type Cloned = JSXEmptyExpression; - fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { - JSXEmptyExpression { span: CloneIn::clone_in(&self.span, allocator) } - } -} - -impl<'new_alloc> CloneIn<'new_alloc> for JSXAttributeItem<'_> { - type Cloned = JSXAttributeItem<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSExternalModuleReference<'_> { + type Cloned = TSExternalModuleReference<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::Attribute(it) => JSXAttributeItem::Attribute(CloneIn::clone_in(it, allocator)), - Self::SpreadAttribute(it) => { - JSXAttributeItem::SpreadAttribute(CloneIn::clone_in(it, allocator)) - } + TSExternalModuleReference { + span: CloneIn::clone_in(&self.span, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXAttribute<'_> { - type Cloned = JSXAttribute<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSNonNullExpression<'_> { + type Cloned = TSNonNullExpression<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXAttribute { + TSNonNullExpression { span: CloneIn::clone_in(&self.span, allocator), - name: CloneIn::clone_in(&self.name, allocator), - value: CloneIn::clone_in(&self.value, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXSpreadAttribute<'_> { - type Cloned = JSXSpreadAttribute<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for Decorator<'_> { + type Cloned = Decorator<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXSpreadAttribute { + Decorator { span: CloneIn::clone_in(&self.span, allocator), - argument: CloneIn::clone_in(&self.argument, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXAttributeName<'_> { - type Cloned = JSXAttributeName<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSExportAssignment<'_> { + type Cloned = TSExportAssignment<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::Identifier(it) => JSXAttributeName::Identifier(CloneIn::clone_in(it, allocator)), - Self::NamespacedName(it) => { - JSXAttributeName::NamespacedName(CloneIn::clone_in(it, allocator)) - } + TSExportAssignment { + span: CloneIn::clone_in(&self.span, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXAttributeValue<'_> { - type Cloned = JSXAttributeValue<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSNamespaceExportDeclaration<'_> { + type Cloned = TSNamespaceExportDeclaration<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - match self { - Self::StringLiteral(it) => { - JSXAttributeValue::StringLiteral(CloneIn::clone_in(it, allocator)) - } - Self::ExpressionContainer(it) => { - JSXAttributeValue::ExpressionContainer(CloneIn::clone_in(it, allocator)) - } - Self::Element(it) => JSXAttributeValue::Element(CloneIn::clone_in(it, allocator)), - Self::Fragment(it) => JSXAttributeValue::Fragment(CloneIn::clone_in(it, allocator)), + TSNamespaceExportDeclaration { + span: CloneIn::clone_in(&self.span, allocator), + id: CloneIn::clone_in(&self.id, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXIdentifier<'_> { - type Cloned = JSXIdentifier<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for TSInstantiationExpression<'_> { + type Cloned = TSInstantiationExpression<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXIdentifier { + TSInstantiationExpression { span: CloneIn::clone_in(&self.span, allocator), - name: CloneIn::clone_in(&self.name, allocator), + expression: CloneIn::clone_in(&self.expression, allocator), + type_parameters: CloneIn::clone_in(&self.type_parameters, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXChild<'_> { - type Cloned = JSXChild<'new_alloc>; - fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { +impl<'alloc> CloneIn<'alloc> for ImportOrExportKind { + type Cloned = ImportOrExportKind; + fn clone_in(&self, _: &'alloc Allocator) -> Self::Cloned { match self { - Self::Text(it) => JSXChild::Text(CloneIn::clone_in(it, allocator)), - Self::Element(it) => JSXChild::Element(CloneIn::clone_in(it, allocator)), - Self::Fragment(it) => JSXChild::Fragment(CloneIn::clone_in(it, allocator)), - Self::ExpressionContainer(it) => { - JSXChild::ExpressionContainer(CloneIn::clone_in(it, allocator)) - } - Self::Spread(it) => JSXChild::Spread(CloneIn::clone_in(it, allocator)), + Self::Value => ImportOrExportKind::Value, + Self::Type => ImportOrExportKind::Type, } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXSpreadChild<'_> { - type Cloned = JSXSpreadChild<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for JSDocNullableType<'_> { + type Cloned = JSDocNullableType<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXSpreadChild { + JSDocNullableType { span: CloneIn::clone_in(&self.span, allocator), - expression: CloneIn::clone_in(&self.expression, allocator), + type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), + postfix: CloneIn::clone_in(&self.postfix, allocator), } } } -impl<'new_alloc> CloneIn<'new_alloc> for JSXText<'_> { - type Cloned = JSXText<'new_alloc>; +impl<'new_alloc> CloneIn<'new_alloc> for JSDocNonNullableType<'_> { + type Cloned = JSDocNonNullableType<'new_alloc>; fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { - JSXText { + JSDocNonNullableType { span: CloneIn::clone_in(&self.span, allocator), - value: CloneIn::clone_in(&self.value, allocator), + type_annotation: CloneIn::clone_in(&self.type_annotation, allocator), + postfix: CloneIn::clone_in(&self.postfix, allocator), } } } +impl<'alloc> CloneIn<'alloc> for JSDocUnknownType { + type Cloned = JSDocUnknownType; + fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned { + JSDocUnknownType { span: CloneIn::clone_in(&self.span, allocator) } + } +} + impl<'alloc> CloneIn<'alloc> for CommentKind { type Cloned = CommentKind; fn clone_in(&self, _: &'alloc Allocator) -> Self::Cloned { diff --git a/crates/oxc_ast/src/generated/derive_content_eq.rs b/crates/oxc_ast/src/generated/derive_content_eq.rs index 554e4022402c7..f0b97b8f13c1e 100644 --- a/crates/oxc_ast/src/generated/derive_content_eq.rs +++ b/crates/oxc_ast/src/generated/derive_content_eq.rs @@ -11,25 +11,6 @@ use crate::ast::jsx::*; use crate::ast::literal::*; use crate::ast::ts::*; -impl ContentEq for BooleanLiteral { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.value, &other.value) - } -} - -impl ContentEq for NullLiteral { - fn content_eq(&self, _: &Self) -> bool { - true - } -} - -impl ContentEq for RegExp<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.pattern, &other.pattern) - && ContentEq::content_eq(&self.flags, &other.flags) - } -} - impl ContentEq for Program<'_> { fn content_eq(&self, other: &Self) -> bool { ContentEq::content_eq(&self.source_type, &other.source_type) @@ -1465,6 +1446,251 @@ impl ContentEq for ModuleExportName<'_> { } } +impl ContentEq for BooleanLiteral { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.value, &other.value) + } +} + +impl ContentEq for NullLiteral { + fn content_eq(&self, _: &Self) -> bool { + true + } +} + +impl ContentEq for RegExp<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.pattern, &other.pattern) + && ContentEq::content_eq(&self.flags, &other.flags) + } +} + +impl ContentEq for JSXElement<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.opening_element, &other.opening_element) + && ContentEq::content_eq(&self.closing_element, &other.closing_element) + && ContentEq::content_eq(&self.children, &other.children) + } +} + +impl ContentEq for JSXOpeningElement<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.self_closing, &other.self_closing) + && ContentEq::content_eq(&self.name, &other.name) + && ContentEq::content_eq(&self.attributes, &other.attributes) + && ContentEq::content_eq(&self.type_parameters, &other.type_parameters) + } +} + +impl ContentEq for JSXClosingElement<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.name, &other.name) + } +} + +impl ContentEq for JSXFragment<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.opening_fragment, &other.opening_fragment) + && ContentEq::content_eq(&self.closing_fragment, &other.closing_fragment) + && ContentEq::content_eq(&self.children, &other.children) + } +} + +impl ContentEq for JSXOpeningFragment { + fn content_eq(&self, _: &Self) -> bool { + true + } +} + +impl ContentEq for JSXClosingFragment { + fn content_eq(&self, _: &Self) -> bool { + true + } +} + +impl ContentEq for JSXElementName<'_> { + fn content_eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Identifier(a), Self::Identifier(b)) => a.content_eq(b), + (Self::IdentifierReference(a), Self::IdentifierReference(b)) => a.content_eq(b), + (Self::NamespacedName(a), Self::NamespacedName(b)) => a.content_eq(b), + (Self::MemberExpression(a), Self::MemberExpression(b)) => a.content_eq(b), + (Self::ThisExpression(a), Self::ThisExpression(b)) => a.content_eq(b), + _ => false, + } + } +} + +impl ContentEq for JSXNamespacedName<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.namespace, &other.namespace) + && ContentEq::content_eq(&self.property, &other.property) + } +} + +impl ContentEq for JSXMemberExpression<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.object, &other.object) + && ContentEq::content_eq(&self.property, &other.property) + } +} + +impl ContentEq for JSXMemberExpressionObject<'_> { + fn content_eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::IdentifierReference(a), Self::IdentifierReference(b)) => a.content_eq(b), + (Self::MemberExpression(a), Self::MemberExpression(b)) => a.content_eq(b), + (Self::ThisExpression(a), Self::ThisExpression(b)) => a.content_eq(b), + _ => false, + } + } +} + +impl ContentEq for JSXExpressionContainer<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.expression, &other.expression) + } +} + +impl ContentEq for JSXExpression<'_> { + fn content_eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::EmptyExpression(a), Self::EmptyExpression(b)) => a.content_eq(b), + (Self::BooleanLiteral(a), Self::BooleanLiteral(b)) => a.content_eq(b), + (Self::NullLiteral(a), Self::NullLiteral(b)) => a.content_eq(b), + (Self::NumericLiteral(a), Self::NumericLiteral(b)) => a.content_eq(b), + (Self::BigIntLiteral(a), Self::BigIntLiteral(b)) => a.content_eq(b), + (Self::RegExpLiteral(a), Self::RegExpLiteral(b)) => a.content_eq(b), + (Self::StringLiteral(a), Self::StringLiteral(b)) => a.content_eq(b), + (Self::TemplateLiteral(a), Self::TemplateLiteral(b)) => a.content_eq(b), + (Self::Identifier(a), Self::Identifier(b)) => a.content_eq(b), + (Self::MetaProperty(a), Self::MetaProperty(b)) => a.content_eq(b), + (Self::Super(a), Self::Super(b)) => a.content_eq(b), + (Self::ArrayExpression(a), Self::ArrayExpression(b)) => a.content_eq(b), + (Self::ArrowFunctionExpression(a), Self::ArrowFunctionExpression(b)) => a.content_eq(b), + (Self::AssignmentExpression(a), Self::AssignmentExpression(b)) => a.content_eq(b), + (Self::AwaitExpression(a), Self::AwaitExpression(b)) => a.content_eq(b), + (Self::BinaryExpression(a), Self::BinaryExpression(b)) => a.content_eq(b), + (Self::CallExpression(a), Self::CallExpression(b)) => a.content_eq(b), + (Self::ChainExpression(a), Self::ChainExpression(b)) => a.content_eq(b), + (Self::ClassExpression(a), Self::ClassExpression(b)) => a.content_eq(b), + (Self::ConditionalExpression(a), Self::ConditionalExpression(b)) => a.content_eq(b), + (Self::FunctionExpression(a), Self::FunctionExpression(b)) => a.content_eq(b), + (Self::ImportExpression(a), Self::ImportExpression(b)) => a.content_eq(b), + (Self::LogicalExpression(a), Self::LogicalExpression(b)) => a.content_eq(b), + (Self::NewExpression(a), Self::NewExpression(b)) => a.content_eq(b), + (Self::ObjectExpression(a), Self::ObjectExpression(b)) => a.content_eq(b), + (Self::ParenthesizedExpression(a), Self::ParenthesizedExpression(b)) => a.content_eq(b), + (Self::SequenceExpression(a), Self::SequenceExpression(b)) => a.content_eq(b), + (Self::TaggedTemplateExpression(a), Self::TaggedTemplateExpression(b)) => { + a.content_eq(b) + } + (Self::ThisExpression(a), Self::ThisExpression(b)) => a.content_eq(b), + (Self::UnaryExpression(a), Self::UnaryExpression(b)) => a.content_eq(b), + (Self::UpdateExpression(a), Self::UpdateExpression(b)) => a.content_eq(b), + (Self::YieldExpression(a), Self::YieldExpression(b)) => a.content_eq(b), + (Self::PrivateInExpression(a), Self::PrivateInExpression(b)) => a.content_eq(b), + (Self::JSXElement(a), Self::JSXElement(b)) => a.content_eq(b), + (Self::JSXFragment(a), Self::JSXFragment(b)) => a.content_eq(b), + (Self::TSAsExpression(a), Self::TSAsExpression(b)) => a.content_eq(b), + (Self::TSSatisfiesExpression(a), Self::TSSatisfiesExpression(b)) => a.content_eq(b), + (Self::TSTypeAssertion(a), Self::TSTypeAssertion(b)) => a.content_eq(b), + (Self::TSNonNullExpression(a), Self::TSNonNullExpression(b)) => a.content_eq(b), + (Self::TSInstantiationExpression(a), Self::TSInstantiationExpression(b)) => { + a.content_eq(b) + } + (Self::ComputedMemberExpression(a), Self::ComputedMemberExpression(b)) => { + a.content_eq(b) + } + (Self::StaticMemberExpression(a), Self::StaticMemberExpression(b)) => a.content_eq(b), + (Self::PrivateFieldExpression(a), Self::PrivateFieldExpression(b)) => a.content_eq(b), + _ => false, + } + } +} + +impl ContentEq for JSXEmptyExpression { + fn content_eq(&self, _: &Self) -> bool { + true + } +} + +impl ContentEq for JSXAttributeItem<'_> { + fn content_eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Attribute(a), Self::Attribute(b)) => a.content_eq(b), + (Self::SpreadAttribute(a), Self::SpreadAttribute(b)) => a.content_eq(b), + _ => false, + } + } +} + +impl ContentEq for JSXAttribute<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.name, &other.name) + && ContentEq::content_eq(&self.value, &other.value) + } +} + +impl ContentEq for JSXSpreadAttribute<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.argument, &other.argument) + } +} + +impl ContentEq for JSXAttributeName<'_> { + fn content_eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Identifier(a), Self::Identifier(b)) => a.content_eq(b), + (Self::NamespacedName(a), Self::NamespacedName(b)) => a.content_eq(b), + _ => false, + } + } +} + +impl ContentEq for JSXAttributeValue<'_> { + fn content_eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::StringLiteral(a), Self::StringLiteral(b)) => a.content_eq(b), + (Self::ExpressionContainer(a), Self::ExpressionContainer(b)) => a.content_eq(b), + (Self::Element(a), Self::Element(b)) => a.content_eq(b), + (Self::Fragment(a), Self::Fragment(b)) => a.content_eq(b), + _ => false, + } + } +} + +impl ContentEq for JSXIdentifier<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.name, &other.name) + } +} + +impl ContentEq for JSXChild<'_> { + fn content_eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Text(a), Self::Text(b)) => a.content_eq(b), + (Self::Element(a), Self::Element(b)) => a.content_eq(b), + (Self::Fragment(a), Self::Fragment(b)) => a.content_eq(b), + (Self::ExpressionContainer(a), Self::ExpressionContainer(b)) => a.content_eq(b), + (Self::Spread(a), Self::Spread(b)) => a.content_eq(b), + _ => false, + } + } +} + +impl ContentEq for JSXSpreadChild<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.expression, &other.expression) + } +} + +impl ContentEq for JSXText<'_> { + fn content_eq(&self, other: &Self) -> bool { + ContentEq::content_eq(&self.value, &other.value) + } +} + impl ContentEq for TSThisParameter<'_> { fn content_eq(&self, other: &Self) -> bool { ContentEq::content_eq(&self.type_annotation, &other.type_annotation) @@ -2222,232 +2448,6 @@ impl ContentEq for JSDocUnknownType { } } -impl ContentEq for JSXElement<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.opening_element, &other.opening_element) - && ContentEq::content_eq(&self.closing_element, &other.closing_element) - && ContentEq::content_eq(&self.children, &other.children) - } -} - -impl ContentEq for JSXOpeningElement<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.self_closing, &other.self_closing) - && ContentEq::content_eq(&self.name, &other.name) - && ContentEq::content_eq(&self.attributes, &other.attributes) - && ContentEq::content_eq(&self.type_parameters, &other.type_parameters) - } -} - -impl ContentEq for JSXClosingElement<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.name, &other.name) - } -} - -impl ContentEq for JSXFragment<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.opening_fragment, &other.opening_fragment) - && ContentEq::content_eq(&self.closing_fragment, &other.closing_fragment) - && ContentEq::content_eq(&self.children, &other.children) - } -} - -impl ContentEq for JSXOpeningFragment { - fn content_eq(&self, _: &Self) -> bool { - true - } -} - -impl ContentEq for JSXClosingFragment { - fn content_eq(&self, _: &Self) -> bool { - true - } -} - -impl ContentEq for JSXElementName<'_> { - fn content_eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::Identifier(a), Self::Identifier(b)) => a.content_eq(b), - (Self::IdentifierReference(a), Self::IdentifierReference(b)) => a.content_eq(b), - (Self::NamespacedName(a), Self::NamespacedName(b)) => a.content_eq(b), - (Self::MemberExpression(a), Self::MemberExpression(b)) => a.content_eq(b), - (Self::ThisExpression(a), Self::ThisExpression(b)) => a.content_eq(b), - _ => false, - } - } -} - -impl ContentEq for JSXNamespacedName<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.namespace, &other.namespace) - && ContentEq::content_eq(&self.property, &other.property) - } -} - -impl ContentEq for JSXMemberExpression<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.object, &other.object) - && ContentEq::content_eq(&self.property, &other.property) - } -} - -impl ContentEq for JSXMemberExpressionObject<'_> { - fn content_eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::IdentifierReference(a), Self::IdentifierReference(b)) => a.content_eq(b), - (Self::MemberExpression(a), Self::MemberExpression(b)) => a.content_eq(b), - (Self::ThisExpression(a), Self::ThisExpression(b)) => a.content_eq(b), - _ => false, - } - } -} - -impl ContentEq for JSXExpressionContainer<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.expression, &other.expression) - } -} - -impl ContentEq for JSXExpression<'_> { - fn content_eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::EmptyExpression(a), Self::EmptyExpression(b)) => a.content_eq(b), - (Self::BooleanLiteral(a), Self::BooleanLiteral(b)) => a.content_eq(b), - (Self::NullLiteral(a), Self::NullLiteral(b)) => a.content_eq(b), - (Self::NumericLiteral(a), Self::NumericLiteral(b)) => a.content_eq(b), - (Self::BigIntLiteral(a), Self::BigIntLiteral(b)) => a.content_eq(b), - (Self::RegExpLiteral(a), Self::RegExpLiteral(b)) => a.content_eq(b), - (Self::StringLiteral(a), Self::StringLiteral(b)) => a.content_eq(b), - (Self::TemplateLiteral(a), Self::TemplateLiteral(b)) => a.content_eq(b), - (Self::Identifier(a), Self::Identifier(b)) => a.content_eq(b), - (Self::MetaProperty(a), Self::MetaProperty(b)) => a.content_eq(b), - (Self::Super(a), Self::Super(b)) => a.content_eq(b), - (Self::ArrayExpression(a), Self::ArrayExpression(b)) => a.content_eq(b), - (Self::ArrowFunctionExpression(a), Self::ArrowFunctionExpression(b)) => a.content_eq(b), - (Self::AssignmentExpression(a), Self::AssignmentExpression(b)) => a.content_eq(b), - (Self::AwaitExpression(a), Self::AwaitExpression(b)) => a.content_eq(b), - (Self::BinaryExpression(a), Self::BinaryExpression(b)) => a.content_eq(b), - (Self::CallExpression(a), Self::CallExpression(b)) => a.content_eq(b), - (Self::ChainExpression(a), Self::ChainExpression(b)) => a.content_eq(b), - (Self::ClassExpression(a), Self::ClassExpression(b)) => a.content_eq(b), - (Self::ConditionalExpression(a), Self::ConditionalExpression(b)) => a.content_eq(b), - (Self::FunctionExpression(a), Self::FunctionExpression(b)) => a.content_eq(b), - (Self::ImportExpression(a), Self::ImportExpression(b)) => a.content_eq(b), - (Self::LogicalExpression(a), Self::LogicalExpression(b)) => a.content_eq(b), - (Self::NewExpression(a), Self::NewExpression(b)) => a.content_eq(b), - (Self::ObjectExpression(a), Self::ObjectExpression(b)) => a.content_eq(b), - (Self::ParenthesizedExpression(a), Self::ParenthesizedExpression(b)) => a.content_eq(b), - (Self::SequenceExpression(a), Self::SequenceExpression(b)) => a.content_eq(b), - (Self::TaggedTemplateExpression(a), Self::TaggedTemplateExpression(b)) => { - a.content_eq(b) - } - (Self::ThisExpression(a), Self::ThisExpression(b)) => a.content_eq(b), - (Self::UnaryExpression(a), Self::UnaryExpression(b)) => a.content_eq(b), - (Self::UpdateExpression(a), Self::UpdateExpression(b)) => a.content_eq(b), - (Self::YieldExpression(a), Self::YieldExpression(b)) => a.content_eq(b), - (Self::PrivateInExpression(a), Self::PrivateInExpression(b)) => a.content_eq(b), - (Self::JSXElement(a), Self::JSXElement(b)) => a.content_eq(b), - (Self::JSXFragment(a), Self::JSXFragment(b)) => a.content_eq(b), - (Self::TSAsExpression(a), Self::TSAsExpression(b)) => a.content_eq(b), - (Self::TSSatisfiesExpression(a), Self::TSSatisfiesExpression(b)) => a.content_eq(b), - (Self::TSTypeAssertion(a), Self::TSTypeAssertion(b)) => a.content_eq(b), - (Self::TSNonNullExpression(a), Self::TSNonNullExpression(b)) => a.content_eq(b), - (Self::TSInstantiationExpression(a), Self::TSInstantiationExpression(b)) => { - a.content_eq(b) - } - (Self::ComputedMemberExpression(a), Self::ComputedMemberExpression(b)) => { - a.content_eq(b) - } - (Self::StaticMemberExpression(a), Self::StaticMemberExpression(b)) => a.content_eq(b), - (Self::PrivateFieldExpression(a), Self::PrivateFieldExpression(b)) => a.content_eq(b), - _ => false, - } - } -} - -impl ContentEq for JSXEmptyExpression { - fn content_eq(&self, _: &Self) -> bool { - true - } -} - -impl ContentEq for JSXAttributeItem<'_> { - fn content_eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::Attribute(a), Self::Attribute(b)) => a.content_eq(b), - (Self::SpreadAttribute(a), Self::SpreadAttribute(b)) => a.content_eq(b), - _ => false, - } - } -} - -impl ContentEq for JSXAttribute<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.name, &other.name) - && ContentEq::content_eq(&self.value, &other.value) - } -} - -impl ContentEq for JSXSpreadAttribute<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.argument, &other.argument) - } -} - -impl ContentEq for JSXAttributeName<'_> { - fn content_eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::Identifier(a), Self::Identifier(b)) => a.content_eq(b), - (Self::NamespacedName(a), Self::NamespacedName(b)) => a.content_eq(b), - _ => false, - } - } -} - -impl ContentEq for JSXAttributeValue<'_> { - fn content_eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::StringLiteral(a), Self::StringLiteral(b)) => a.content_eq(b), - (Self::ExpressionContainer(a), Self::ExpressionContainer(b)) => a.content_eq(b), - (Self::Element(a), Self::Element(b)) => a.content_eq(b), - (Self::Fragment(a), Self::Fragment(b)) => a.content_eq(b), - _ => false, - } - } -} - -impl ContentEq for JSXIdentifier<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.name, &other.name) - } -} - -impl ContentEq for JSXChild<'_> { - fn content_eq(&self, other: &Self) -> bool { - match (self, other) { - (Self::Text(a), Self::Text(b)) => a.content_eq(b), - (Self::Element(a), Self::Element(b)) => a.content_eq(b), - (Self::Fragment(a), Self::Fragment(b)) => a.content_eq(b), - (Self::ExpressionContainer(a), Self::ExpressionContainer(b)) => a.content_eq(b), - (Self::Spread(a), Self::Spread(b)) => a.content_eq(b), - _ => false, - } - } -} - -impl ContentEq for JSXSpreadChild<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.expression, &other.expression) - } -} - -impl ContentEq for JSXText<'_> { - fn content_eq(&self, other: &Self) -> bool { - ContentEq::content_eq(&self.value, &other.value) - } -} - impl ContentEq for CommentKind { fn content_eq(&self, other: &Self) -> bool { self == other diff --git a/crates/oxc_ast/src/generated/derive_estree.rs b/crates/oxc_ast/src/generated/derive_estree.rs index 589a18a1773b3..fa7bc41e25cca 100644 --- a/crates/oxc_ast/src/generated/derive_estree.rs +++ b/crates/oxc_ast/src/generated/derive_estree.rs @@ -10,61 +10,6 @@ use crate::ast::jsx::*; use crate::ast::literal::*; use crate::ast::ts::*; -impl Serialize for BooleanLiteral { - fn serialize(&self, serializer: S) -> Result { - crate::serialize::ESTreeLiteral::from(self).serialize(serializer) - } -} - -impl Serialize for NullLiteral { - fn serialize(&self, serializer: S) -> Result { - crate::serialize::ESTreeLiteral::from(self).serialize(serializer) - } -} - -impl Serialize for NumericLiteral<'_> { - fn serialize(&self, serializer: S) -> Result { - crate::serialize::ESTreeLiteral::from(self).serialize(serializer) - } -} - -impl Serialize for StringLiteral<'_> { - fn serialize(&self, serializer: S) -> Result { - crate::serialize::ESTreeLiteral::from(self).serialize(serializer) - } -} - -impl Serialize for BigIntLiteral<'_> { - fn serialize(&self, serializer: S) -> Result { - crate::serialize::ESTreeLiteral::from(self).serialize(serializer) - } -} - -impl Serialize for RegExpLiteral<'_> { - fn serialize(&self, serializer: S) -> Result { - crate::serialize::ESTreeLiteral::from(self).serialize(serializer) - } -} - -impl Serialize for RegExp<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("pattern", &self.pattern)?; - map.serialize_entry("flags", &self.flags)?; - map.end() - } -} - -impl Serialize for RegExpPattern<'_> { - fn serialize(&self, serializer: S) -> Result { - match self { - RegExpPattern::Raw(it) => Serialize::serialize(it, serializer), - RegExpPattern::Invalid(it) => Serialize::serialize(it, serializer), - RegExpPattern::Pattern(it) => Serialize::serialize(it, serializer), - } - } -} - impl Serialize for Program<'_> { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; @@ -1986,249 +1931,552 @@ impl Serialize for ModuleExportName<'_> { } } -impl Serialize for TSThisParameter<'_> { +impl Serialize for BooleanLiteral { fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSThisParameter")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("typeAnnotation", &self.type_annotation)?; - map.end() + crate::serialize::ESTreeLiteral::from(self).serialize(serializer) } } -impl Serialize for TSEnumDeclaration<'_> { +impl Serialize for NullLiteral { fn serialize(&self, serializer: S) -> Result { - 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() + crate::serialize::ESTreeLiteral::from(self).serialize(serializer) } } -impl Serialize for TSEnumMember<'_> { +impl Serialize for NumericLiteral<'_> { fn serialize(&self, serializer: S) -> Result { - 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() + crate::serialize::ESTreeLiteral::from(self).serialize(serializer) } } -impl Serialize for TSEnumMemberName<'_> { +impl Serialize for StringLiteral<'_> { fn serialize(&self, serializer: S) -> Result { - match self { - TSEnumMemberName::Identifier(it) => Serialize::serialize(it, serializer), - TSEnumMemberName::String(it) => Serialize::serialize(it, serializer), - } + crate::serialize::ESTreeLiteral::from(self).serialize(serializer) } } -impl Serialize for TSTypeAnnotation<'_> { +impl Serialize for BigIntLiteral<'_> { fn serialize(&self, serializer: S) -> Result { - 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() + crate::serialize::ESTreeLiteral::from(self).serialize(serializer) } } -impl Serialize for TSLiteralType<'_> { +impl Serialize for RegExpLiteral<'_> { fn serialize(&self, serializer: S) -> Result { - 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() + crate::serialize::ESTreeLiteral::from(self).serialize(serializer) } } -impl Serialize for TSLiteral<'_> { +impl Serialize for RegExp<'_> { fn serialize(&self, serializer: S) -> Result { - match self { - TSLiteral::BooleanLiteral(it) => Serialize::serialize(it, serializer), - TSLiteral::NullLiteral(it) => Serialize::serialize(it, serializer), - TSLiteral::NumericLiteral(it) => Serialize::serialize(it, serializer), - TSLiteral::BigIntLiteral(it) => Serialize::serialize(it, serializer), - TSLiteral::RegExpLiteral(it) => Serialize::serialize(it, serializer), - TSLiteral::StringLiteral(it) => Serialize::serialize(it, serializer), - TSLiteral::TemplateLiteral(it) => Serialize::serialize(it, serializer), - TSLiteral::UnaryExpression(it) => Serialize::serialize(it, serializer), - } + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("pattern", &self.pattern)?; + map.serialize_entry("flags", &self.flags)?; + map.end() } } -impl Serialize for TSType<'_> { +impl Serialize for RegExpPattern<'_> { fn serialize(&self, serializer: S) -> Result { match self { - TSType::TSAnyKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSBigIntKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSBooleanKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSIntrinsicKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSNeverKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSNullKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSNumberKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSObjectKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSStringKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSSymbolKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSUndefinedKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSUnknownKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSVoidKeyword(it) => Serialize::serialize(it, serializer), - TSType::TSArrayType(it) => Serialize::serialize(it, serializer), - TSType::TSConditionalType(it) => Serialize::serialize(it, serializer), - TSType::TSConstructorType(it) => Serialize::serialize(it, serializer), - TSType::TSFunctionType(it) => Serialize::serialize(it, serializer), - TSType::TSImportType(it) => Serialize::serialize(it, serializer), - TSType::TSIndexedAccessType(it) => Serialize::serialize(it, serializer), - TSType::TSInferType(it) => Serialize::serialize(it, serializer), - TSType::TSIntersectionType(it) => Serialize::serialize(it, serializer), - TSType::TSLiteralType(it) => Serialize::serialize(it, serializer), - TSType::TSMappedType(it) => Serialize::serialize(it, serializer), - TSType::TSNamedTupleMember(it) => Serialize::serialize(it, serializer), - TSType::TSQualifiedName(it) => Serialize::serialize(it, serializer), - TSType::TSTemplateLiteralType(it) => Serialize::serialize(it, serializer), - TSType::TSThisType(it) => Serialize::serialize(it, serializer), - TSType::TSTupleType(it) => Serialize::serialize(it, serializer), - TSType::TSTypeLiteral(it) => Serialize::serialize(it, serializer), - TSType::TSTypeOperatorType(it) => Serialize::serialize(it, serializer), - TSType::TSTypePredicate(it) => Serialize::serialize(it, serializer), - TSType::TSTypeQuery(it) => Serialize::serialize(it, serializer), - TSType::TSTypeReference(it) => Serialize::serialize(it, serializer), - TSType::TSUnionType(it) => Serialize::serialize(it, serializer), - TSType::TSParenthesizedType(it) => Serialize::serialize(it, serializer), - TSType::JSDocNullableType(it) => Serialize::serialize(it, serializer), - TSType::JSDocNonNullableType(it) => Serialize::serialize(it, serializer), - TSType::JSDocUnknownType(it) => Serialize::serialize(it, serializer), + RegExpPattern::Raw(it) => Serialize::serialize(it, serializer), + RegExpPattern::Invalid(it) => Serialize::serialize(it, serializer), + RegExpPattern::Pattern(it) => Serialize::serialize(it, serializer), } } } -impl Serialize for TSConditionalType<'_> { +impl Serialize for JSXElement<'_> { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSConditionalType")?; + map.serialize_entry("type", "JSXElement")?; 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.serialize_entry("openingElement", &self.opening_element)?; + map.serialize_entry("closingElement", &self.closing_element)?; + map.serialize_entry("children", &self.children)?; map.end() } } -impl Serialize for TSUnionType<'_> { +impl Serialize for JSXOpeningElement<'_> { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSUnionType")?; + map.serialize_entry("type", "JSXOpeningElement")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("types", &self.types)?; + 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() } } -impl Serialize for TSIntersectionType<'_> { +impl Serialize for JSXClosingElement<'_> { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSIntersectionType")?; + map.serialize_entry("type", "JSXClosingElement")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("types", &self.types)?; + map.serialize_entry("name", &self.name)?; map.end() } } -impl Serialize for TSParenthesizedType<'_> { +impl Serialize for JSXFragment<'_> { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSParenthesizedType")?; + map.serialize_entry("type", "JSXFragment")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("typeAnnotation", &self.type_annotation)?; + map.serialize_entry("openingFragment", &self.opening_fragment)?; + map.serialize_entry("closingFragment", &self.closing_fragment)?; + map.serialize_entry("children", &self.children)?; map.end() } } -impl Serialize for TSTypeOperator<'_> { +impl Serialize for JSXOpeningFragment { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSTypeOperator")?; + map.serialize_entry("type", "JSXOpeningFragment")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("operator", &self.operator)?; - map.serialize_entry("typeAnnotation", &self.type_annotation)?; map.end() } } -impl Serialize for TSTypeOperatorOperator { - fn serialize(&self, serializer: S) -> Result { - match *self { - TSTypeOperatorOperator::Keyof => { - serializer.serialize_unit_variant("TSTypeOperatorOperator", 0u32, "keyof") - } - TSTypeOperatorOperator::Unique => { - serializer.serialize_unit_variant("TSTypeOperatorOperator", 1u32, "unique") - } - TSTypeOperatorOperator::Readonly => { - serializer.serialize_unit_variant("TSTypeOperatorOperator", 2u32, "readonly") - } - } - } -} - -impl Serialize for TSArrayType<'_> { +impl Serialize for JSXClosingFragment { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSArrayType")?; + map.serialize_entry("type", "JSXClosingFragment")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("elementType", &self.element_type)?; map.end() } } -impl Serialize for TSIndexedAccessType<'_> { +impl Serialize for JSXNamespacedName<'_> { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSIndexedAccessType")?; + map.serialize_entry("type", "JSXNamespacedName")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("objectType", &self.object_type)?; - map.serialize_entry("indexType", &self.index_type)?; + map.serialize_entry("namespace", &self.namespace)?; + map.serialize_entry("property", &self.property)?; map.end() } } -impl Serialize for TSTupleType<'_> { +impl Serialize for JSXMemberExpression<'_> { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSTupleType")?; + map.serialize_entry("type", "JSXMemberExpression")?; self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("elementTypes", &self.element_types)?; + map.serialize_entry("object", &self.object)?; + map.serialize_entry("property", &self.property)?; map.end() } } -impl Serialize for TSNamedTupleMember<'_> { +impl Serialize for JSXExpressionContainer<'_> { fn serialize(&self, serializer: S) -> Result { let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "TSNamedTupleMember")?; + map.serialize_entry("type", "JSXExpressionContainer")?; 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.serialize_entry("expression", &self.expression)?; map.end() } } -impl Serialize for TSOptionalType<'_> { +impl Serialize for JSXExpression<'_> { fn serialize(&self, serializer: S) -> Result { - 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() + match self { + JSXExpression::EmptyExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::BooleanLiteral(it) => Serialize::serialize(it, serializer), + JSXExpression::NullLiteral(it) => Serialize::serialize(it, serializer), + JSXExpression::NumericLiteral(it) => Serialize::serialize(it, serializer), + JSXExpression::BigIntLiteral(it) => Serialize::serialize(it, serializer), + JSXExpression::RegExpLiteral(it) => Serialize::serialize(it, serializer), + JSXExpression::StringLiteral(it) => Serialize::serialize(it, serializer), + JSXExpression::TemplateLiteral(it) => Serialize::serialize(it, serializer), + JSXExpression::Identifier(it) => Serialize::serialize(it, serializer), + JSXExpression::MetaProperty(it) => Serialize::serialize(it, serializer), + JSXExpression::Super(it) => Serialize::serialize(it, serializer), + JSXExpression::ArrayExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ArrowFunctionExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::AssignmentExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::AwaitExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::BinaryExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::CallExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ChainExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ClassExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ConditionalExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::FunctionExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ImportExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::LogicalExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::NewExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ObjectExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ParenthesizedExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::SequenceExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::TaggedTemplateExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ThisExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::UnaryExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::UpdateExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::YieldExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::PrivateInExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::JSXElement(it) => Serialize::serialize(it, serializer), + JSXExpression::JSXFragment(it) => Serialize::serialize(it, serializer), + JSXExpression::TSAsExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::TSSatisfiesExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::TSTypeAssertion(it) => Serialize::serialize(it, serializer), + JSXExpression::TSNonNullExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::TSInstantiationExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::ComputedMemberExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::StaticMemberExpression(it) => Serialize::serialize(it, serializer), + JSXExpression::PrivateFieldExpression(it) => Serialize::serialize(it, serializer), + } + } +} + +impl Serialize for JSXEmptyExpression { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXEmptyExpression")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.end() + } +} + +impl Serialize for JSXAttributeItem<'_> { + fn serialize(&self, serializer: S) -> Result { + match self { + JSXAttributeItem::Attribute(it) => Serialize::serialize(it, serializer), + JSXAttributeItem::SpreadAttribute(it) => Serialize::serialize(it, serializer), + } + } +} + +impl Serialize for JSXAttribute<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXAttribute")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.serialize_entry("value", &self.value)?; + map.end() + } +} + +impl Serialize for JSXSpreadAttribute<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXSpreadAttribute")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("argument", &self.argument)?; + map.end() + } +} + +impl Serialize for JSXAttributeName<'_> { + fn serialize(&self, serializer: S) -> Result { + match self { + JSXAttributeName::Identifier(it) => Serialize::serialize(it, serializer), + JSXAttributeName::NamespacedName(it) => Serialize::serialize(it, serializer), + } + } +} + +impl Serialize for JSXAttributeValue<'_> { + fn serialize(&self, serializer: S) -> Result { + match self { + JSXAttributeValue::StringLiteral(it) => Serialize::serialize(it, serializer), + JSXAttributeValue::ExpressionContainer(it) => Serialize::serialize(it, serializer), + JSXAttributeValue::Element(it) => Serialize::serialize(it, serializer), + JSXAttributeValue::Fragment(it) => Serialize::serialize(it, serializer), + } + } +} + +impl Serialize for JSXIdentifier<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXIdentifier")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("name", &self.name)?; + map.end() + } +} + +impl Serialize for JSXChild<'_> { + fn serialize(&self, serializer: S) -> Result { + match self { + JSXChild::Text(it) => Serialize::serialize(it, serializer), + JSXChild::Element(it) => Serialize::serialize(it, serializer), + JSXChild::Fragment(it) => Serialize::serialize(it, serializer), + JSXChild::ExpressionContainer(it) => Serialize::serialize(it, serializer), + JSXChild::Spread(it) => Serialize::serialize(it, serializer), + } + } +} + +impl Serialize for JSXSpreadChild<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "JSXSpreadChild")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("expression", &self.expression)?; + map.end() + } +} + +impl Serialize for JSXText<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSThisParameter<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSThisParameter")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("typeAnnotation", &self.type_annotation)?; + map.end() + } +} + +impl Serialize for TSEnumDeclaration<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSEnumDeclaration")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("members", &self.members)?; + map.serialize_entry("const", &self.r#const)?; + map.serialize_entry("declare", &self.declare)?; + map.end() + } +} + +impl Serialize for TSEnumMember<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSEnumMember")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("id", &self.id)?; + map.serialize_entry("initializer", &self.initializer)?; + map.end() + } +} + +impl Serialize for TSEnumMemberName<'_> { + fn serialize(&self, serializer: S) -> Result { + match self { + TSEnumMemberName::Identifier(it) => Serialize::serialize(it, serializer), + TSEnumMemberName::String(it) => Serialize::serialize(it, serializer), + } + } +} + +impl Serialize for TSTypeAnnotation<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSLiteralType<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSLiteralType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("literal", &self.literal)?; + map.end() + } +} + +impl Serialize for TSLiteral<'_> { + fn serialize(&self, serializer: S) -> Result { + match self { + TSLiteral::BooleanLiteral(it) => Serialize::serialize(it, serializer), + TSLiteral::NullLiteral(it) => Serialize::serialize(it, serializer), + TSLiteral::NumericLiteral(it) => Serialize::serialize(it, serializer), + TSLiteral::BigIntLiteral(it) => Serialize::serialize(it, serializer), + TSLiteral::RegExpLiteral(it) => Serialize::serialize(it, serializer), + TSLiteral::StringLiteral(it) => Serialize::serialize(it, serializer), + TSLiteral::TemplateLiteral(it) => Serialize::serialize(it, serializer), + TSLiteral::UnaryExpression(it) => Serialize::serialize(it, serializer), + } + } +} + +impl Serialize for TSType<'_> { + fn serialize(&self, serializer: S) -> Result { + match self { + TSType::TSAnyKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSBigIntKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSBooleanKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSIntrinsicKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSNeverKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSNullKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSNumberKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSObjectKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSStringKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSSymbolKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSUndefinedKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSUnknownKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSVoidKeyword(it) => Serialize::serialize(it, serializer), + TSType::TSArrayType(it) => Serialize::serialize(it, serializer), + TSType::TSConditionalType(it) => Serialize::serialize(it, serializer), + TSType::TSConstructorType(it) => Serialize::serialize(it, serializer), + TSType::TSFunctionType(it) => Serialize::serialize(it, serializer), + TSType::TSImportType(it) => Serialize::serialize(it, serializer), + TSType::TSIndexedAccessType(it) => Serialize::serialize(it, serializer), + TSType::TSInferType(it) => Serialize::serialize(it, serializer), + TSType::TSIntersectionType(it) => Serialize::serialize(it, serializer), + TSType::TSLiteralType(it) => Serialize::serialize(it, serializer), + TSType::TSMappedType(it) => Serialize::serialize(it, serializer), + TSType::TSNamedTupleMember(it) => Serialize::serialize(it, serializer), + TSType::TSQualifiedName(it) => Serialize::serialize(it, serializer), + TSType::TSTemplateLiteralType(it) => Serialize::serialize(it, serializer), + TSType::TSThisType(it) => Serialize::serialize(it, serializer), + TSType::TSTupleType(it) => Serialize::serialize(it, serializer), + TSType::TSTypeLiteral(it) => Serialize::serialize(it, serializer), + TSType::TSTypeOperatorType(it) => Serialize::serialize(it, serializer), + TSType::TSTypePredicate(it) => Serialize::serialize(it, serializer), + TSType::TSTypeQuery(it) => Serialize::serialize(it, serializer), + TSType::TSTypeReference(it) => Serialize::serialize(it, serializer), + TSType::TSUnionType(it) => Serialize::serialize(it, serializer), + TSType::TSParenthesizedType(it) => Serialize::serialize(it, serializer), + TSType::JSDocNullableType(it) => Serialize::serialize(it, serializer), + TSType::JSDocNonNullableType(it) => Serialize::serialize(it, serializer), + TSType::JSDocUnknownType(it) => Serialize::serialize(it, serializer), + } + } +} + +impl Serialize for TSConditionalType<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSUnionType<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSUnionType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("types", &self.types)?; + map.end() + } +} + +impl Serialize for TSIntersectionType<'_> { + fn serialize(&self, serializer: S) -> Result { + let mut map = serializer.serialize_map(None)?; + map.serialize_entry("type", "TSIntersectionType")?; + self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; + map.serialize_entry("types", &self.types)?; + map.end() + } +} + +impl Serialize for TSParenthesizedType<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSTypeOperator<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSTypeOperatorOperator { + fn serialize(&self, serializer: S) -> Result { + match *self { + TSTypeOperatorOperator::Keyof => { + serializer.serialize_unit_variant("TSTypeOperatorOperator", 0u32, "keyof") + } + TSTypeOperatorOperator::Unique => { + serializer.serialize_unit_variant("TSTypeOperatorOperator", 1u32, "unique") + } + TSTypeOperatorOperator::Readonly => { + serializer.serialize_unit_variant("TSTypeOperatorOperator", 2u32, "readonly") + } + } + } +} + +impl Serialize for TSArrayType<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSIndexedAccessType<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSTupleType<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSNamedTupleMember<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() + } +} + +impl Serialize for TSOptionalType<'_> { + fn serialize(&self, serializer: S) -> Result { + 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() } } @@ -3051,251 +3299,3 @@ impl Serialize for JSDocUnknownType { map.end() } } - -impl Serialize for JSXElement<'_> { - fn serialize(&self, serializer: S) -> Result { - 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() - } -} - -impl Serialize for JSXOpeningElement<'_> { - fn serialize(&self, serializer: S) -> Result { - 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() - } -} - -impl Serialize for JSXClosingElement<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXClosingElement")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("name", &self.name)?; - map.end() - } -} - -impl Serialize for JSXFragment<'_> { - fn serialize(&self, serializer: S) -> Result { - 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() - } -} - -impl Serialize for JSXOpeningFragment { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXOpeningFragment")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.end() - } -} - -impl Serialize for JSXClosingFragment { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXClosingFragment")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.end() - } -} - -impl Serialize for JSXNamespacedName<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXNamespacedName")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("namespace", &self.namespace)?; - map.serialize_entry("property", &self.property)?; - map.end() - } -} - -impl Serialize for JSXMemberExpression<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXMemberExpression")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("object", &self.object)?; - map.serialize_entry("property", &self.property)?; - map.end() - } -} - -impl Serialize for JSXExpressionContainer<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXExpressionContainer")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("expression", &self.expression)?; - map.end() - } -} - -impl Serialize for JSXExpression<'_> { - fn serialize(&self, serializer: S) -> Result { - match self { - JSXExpression::EmptyExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::BooleanLiteral(it) => Serialize::serialize(it, serializer), - JSXExpression::NullLiteral(it) => Serialize::serialize(it, serializer), - JSXExpression::NumericLiteral(it) => Serialize::serialize(it, serializer), - JSXExpression::BigIntLiteral(it) => Serialize::serialize(it, serializer), - JSXExpression::RegExpLiteral(it) => Serialize::serialize(it, serializer), - JSXExpression::StringLiteral(it) => Serialize::serialize(it, serializer), - JSXExpression::TemplateLiteral(it) => Serialize::serialize(it, serializer), - JSXExpression::Identifier(it) => Serialize::serialize(it, serializer), - JSXExpression::MetaProperty(it) => Serialize::serialize(it, serializer), - JSXExpression::Super(it) => Serialize::serialize(it, serializer), - JSXExpression::ArrayExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ArrowFunctionExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::AssignmentExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::AwaitExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::BinaryExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::CallExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ChainExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ClassExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ConditionalExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::FunctionExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ImportExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::LogicalExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::NewExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ObjectExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ParenthesizedExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::SequenceExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::TaggedTemplateExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ThisExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::UnaryExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::UpdateExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::YieldExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::PrivateInExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::JSXElement(it) => Serialize::serialize(it, serializer), - JSXExpression::JSXFragment(it) => Serialize::serialize(it, serializer), - JSXExpression::TSAsExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::TSSatisfiesExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::TSTypeAssertion(it) => Serialize::serialize(it, serializer), - JSXExpression::TSNonNullExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::TSInstantiationExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::ComputedMemberExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::StaticMemberExpression(it) => Serialize::serialize(it, serializer), - JSXExpression::PrivateFieldExpression(it) => Serialize::serialize(it, serializer), - } - } -} - -impl Serialize for JSXEmptyExpression { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXEmptyExpression")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.end() - } -} - -impl Serialize for JSXAttributeItem<'_> { - fn serialize(&self, serializer: S) -> Result { - match self { - JSXAttributeItem::Attribute(it) => Serialize::serialize(it, serializer), - JSXAttributeItem::SpreadAttribute(it) => Serialize::serialize(it, serializer), - } - } -} - -impl Serialize for JSXAttribute<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXAttribute")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("name", &self.name)?; - map.serialize_entry("value", &self.value)?; - map.end() - } -} - -impl Serialize for JSXSpreadAttribute<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXSpreadAttribute")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("argument", &self.argument)?; - map.end() - } -} - -impl Serialize for JSXAttributeName<'_> { - fn serialize(&self, serializer: S) -> Result { - match self { - JSXAttributeName::Identifier(it) => Serialize::serialize(it, serializer), - JSXAttributeName::NamespacedName(it) => Serialize::serialize(it, serializer), - } - } -} - -impl Serialize for JSXAttributeValue<'_> { - fn serialize(&self, serializer: S) -> Result { - match self { - JSXAttributeValue::StringLiteral(it) => Serialize::serialize(it, serializer), - JSXAttributeValue::ExpressionContainer(it) => Serialize::serialize(it, serializer), - JSXAttributeValue::Element(it) => Serialize::serialize(it, serializer), - JSXAttributeValue::Fragment(it) => Serialize::serialize(it, serializer), - } - } -} - -impl Serialize for JSXIdentifier<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXIdentifier")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("name", &self.name)?; - map.end() - } -} - -impl Serialize for JSXChild<'_> { - fn serialize(&self, serializer: S) -> Result { - match self { - JSXChild::Text(it) => Serialize::serialize(it, serializer), - JSXChild::Element(it) => Serialize::serialize(it, serializer), - JSXChild::Fragment(it) => Serialize::serialize(it, serializer), - JSXChild::ExpressionContainer(it) => Serialize::serialize(it, serializer), - JSXChild::Spread(it) => Serialize::serialize(it, serializer), - } - } -} - -impl Serialize for JSXSpreadChild<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXSpreadChild")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("expression", &self.expression)?; - map.end() - } -} - -impl Serialize for JSXText<'_> { - fn serialize(&self, serializer: S) -> Result { - let mut map = serializer.serialize_map(None)?; - map.serialize_entry("type", "JSXText")?; - self.span.serialize(serde::__private::ser::FlatMapSerializer(&mut map))?; - map.serialize_entry("value", &self.value)?; - map.end() - } -} diff --git a/crates/oxc_ast/src/generated/derive_get_address.rs b/crates/oxc_ast/src/generated/derive_get_address.rs index b1ee8dda1b287..de409769ecb17 100644 --- a/crates/oxc_ast/src/generated/derive_get_address.rs +++ b/crates/oxc_ast/src/generated/derive_get_address.rs @@ -522,6 +522,81 @@ impl GetAddress for ExportDefaultDeclarationKind<'_> { } } +impl GetAddress for JSXElementName<'_> { + // `#[inline]` because compiler should boil this down to a single assembly instruction + #[inline] + fn address(&self) -> Address { + match self { + Self::Identifier(it) => GetAddress::address(it), + Self::IdentifierReference(it) => GetAddress::address(it), + Self::NamespacedName(it) => GetAddress::address(it), + Self::MemberExpression(it) => GetAddress::address(it), + Self::ThisExpression(it) => GetAddress::address(it), + } + } +} + +impl GetAddress for JSXMemberExpressionObject<'_> { + // `#[inline]` because compiler should boil this down to a single assembly instruction + #[inline] + fn address(&self) -> Address { + match self { + Self::IdentifierReference(it) => GetAddress::address(it), + Self::MemberExpression(it) => GetAddress::address(it), + Self::ThisExpression(it) => GetAddress::address(it), + } + } +} + +impl GetAddress for JSXAttributeItem<'_> { + // `#[inline]` because compiler should boil this down to a single assembly instruction + #[inline] + fn address(&self) -> Address { + match self { + Self::Attribute(it) => GetAddress::address(it), + Self::SpreadAttribute(it) => GetAddress::address(it), + } + } +} + +impl GetAddress for JSXAttributeName<'_> { + // `#[inline]` because compiler should boil this down to a single assembly instruction + #[inline] + fn address(&self) -> Address { + match self { + Self::Identifier(it) => GetAddress::address(it), + Self::NamespacedName(it) => GetAddress::address(it), + } + } +} + +impl GetAddress for JSXAttributeValue<'_> { + // `#[inline]` because compiler should boil this down to a single assembly instruction + #[inline] + fn address(&self) -> Address { + match self { + Self::StringLiteral(it) => GetAddress::address(it), + Self::ExpressionContainer(it) => GetAddress::address(it), + Self::Element(it) => GetAddress::address(it), + Self::Fragment(it) => GetAddress::address(it), + } + } +} + +impl GetAddress for JSXChild<'_> { + // `#[inline]` because compiler should boil this down to a single assembly instruction + #[inline] + fn address(&self) -> Address { + match self { + Self::Text(it) => GetAddress::address(it), + Self::Element(it) => GetAddress::address(it), + Self::Fragment(it) => GetAddress::address(it), + Self::ExpressionContainer(it) => GetAddress::address(it), + Self::Spread(it) => GetAddress::address(it), + } + } +} + impl GetAddress for TSEnumMemberName<'_> { // `#[inline]` because compiler should boil this down to a single assembly instruction #[inline] @@ -705,78 +780,3 @@ impl GetAddress for TSModuleReference<'_> { } } } - -impl GetAddress for JSXElementName<'_> { - // `#[inline]` because compiler should boil this down to a single assembly instruction - #[inline] - fn address(&self) -> Address { - match self { - Self::Identifier(it) => GetAddress::address(it), - Self::IdentifierReference(it) => GetAddress::address(it), - Self::NamespacedName(it) => GetAddress::address(it), - Self::MemberExpression(it) => GetAddress::address(it), - Self::ThisExpression(it) => GetAddress::address(it), - } - } -} - -impl GetAddress for JSXMemberExpressionObject<'_> { - // `#[inline]` because compiler should boil this down to a single assembly instruction - #[inline] - fn address(&self) -> Address { - match self { - Self::IdentifierReference(it) => GetAddress::address(it), - Self::MemberExpression(it) => GetAddress::address(it), - Self::ThisExpression(it) => GetAddress::address(it), - } - } -} - -impl GetAddress for JSXAttributeItem<'_> { - // `#[inline]` because compiler should boil this down to a single assembly instruction - #[inline] - fn address(&self) -> Address { - match self { - Self::Attribute(it) => GetAddress::address(it), - Self::SpreadAttribute(it) => GetAddress::address(it), - } - } -} - -impl GetAddress for JSXAttributeName<'_> { - // `#[inline]` because compiler should boil this down to a single assembly instruction - #[inline] - fn address(&self) -> Address { - match self { - Self::Identifier(it) => GetAddress::address(it), - Self::NamespacedName(it) => GetAddress::address(it), - } - } -} - -impl GetAddress for JSXAttributeValue<'_> { - // `#[inline]` because compiler should boil this down to a single assembly instruction - #[inline] - fn address(&self) -> Address { - match self { - Self::StringLiteral(it) => GetAddress::address(it), - Self::ExpressionContainer(it) => GetAddress::address(it), - Self::Element(it) => GetAddress::address(it), - Self::Fragment(it) => GetAddress::address(it), - } - } -} - -impl GetAddress for JSXChild<'_> { - // `#[inline]` because compiler should boil this down to a single assembly instruction - #[inline] - fn address(&self) -> Address { - match self { - Self::Text(it) => GetAddress::address(it), - Self::Element(it) => GetAddress::address(it), - Self::Fragment(it) => GetAddress::address(it), - Self::ExpressionContainer(it) => GetAddress::address(it), - Self::Spread(it) => GetAddress::address(it), - } - } -} diff --git a/crates/oxc_ast/src/generated/derive_get_span.rs b/crates/oxc_ast/src/generated/derive_get_span.rs index eb9f351b25681..ac9b27de5f0f8 100644 --- a/crates/oxc_ast/src/generated/derive_get_span.rs +++ b/crates/oxc_ast/src/generated/derive_get_span.rs @@ -10,48 +10,6 @@ use crate::ast::jsx::*; use crate::ast::literal::*; use crate::ast::ts::*; -impl GetSpan for BooleanLiteral { - #[inline] - fn span(&self) -> Span { - self.span - } -} - -impl GetSpan for NullLiteral { - #[inline] - fn span(&self) -> Span { - self.span - } -} - -impl GetSpan for NumericLiteral<'_> { - #[inline] - fn span(&self) -> Span { - self.span - } -} - -impl GetSpan for StringLiteral<'_> { - #[inline] - fn span(&self) -> Span { - self.span - } -} - -impl GetSpan for BigIntLiteral<'_> { - #[inline] - fn span(&self) -> Span { - self.span - } -} - -impl GetSpan for RegExpLiteral<'_> { - #[inline] - fn span(&self) -> Span { - self.span - } -} - impl GetSpan for Program<'_> { #[inline] fn span(&self) -> Span { @@ -1246,915 +1204,957 @@ impl GetSpan for ModuleExportName<'_> { } } -impl GetSpan for TSThisParameter<'_> { +impl GetSpan for BooleanLiteral { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSEnumDeclaration<'_> { +impl GetSpan for NullLiteral { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSEnumMember<'_> { +impl GetSpan for NumericLiteral<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSEnumMemberName<'_> { +impl GetSpan for StringLiteral<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::Identifier(it) => GetSpan::span(it.as_ref()), - Self::String(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for TSTypeAnnotation<'_> { +impl GetSpan for BigIntLiteral<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSLiteralType<'_> { +impl GetSpan for RegExpLiteral<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSLiteral<'_> { +impl GetSpan for JSXElement<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::BooleanLiteral(it) => GetSpan::span(it.as_ref()), - Self::NullLiteral(it) => GetSpan::span(it.as_ref()), - Self::NumericLiteral(it) => GetSpan::span(it.as_ref()), - Self::BigIntLiteral(it) => GetSpan::span(it.as_ref()), - Self::RegExpLiteral(it) => GetSpan::span(it.as_ref()), - Self::StringLiteral(it) => GetSpan::span(it.as_ref()), - Self::TemplateLiteral(it) => GetSpan::span(it.as_ref()), - Self::UnaryExpression(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for TSType<'_> { +impl GetSpan for JSXOpeningElement<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::TSAnyKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSBigIntKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSBooleanKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSIntrinsicKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSNeverKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSNullKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSNumberKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSObjectKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSStringKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSSymbolKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSUndefinedKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSUnknownKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSVoidKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSArrayType(it) => GetSpan::span(it.as_ref()), - Self::TSConditionalType(it) => GetSpan::span(it.as_ref()), - Self::TSConstructorType(it) => GetSpan::span(it.as_ref()), - Self::TSFunctionType(it) => GetSpan::span(it.as_ref()), - Self::TSImportType(it) => GetSpan::span(it.as_ref()), - Self::TSIndexedAccessType(it) => GetSpan::span(it.as_ref()), - Self::TSInferType(it) => GetSpan::span(it.as_ref()), - Self::TSIntersectionType(it) => GetSpan::span(it.as_ref()), - Self::TSLiteralType(it) => GetSpan::span(it.as_ref()), - Self::TSMappedType(it) => GetSpan::span(it.as_ref()), - Self::TSNamedTupleMember(it) => GetSpan::span(it.as_ref()), - Self::TSQualifiedName(it) => GetSpan::span(it.as_ref()), - Self::TSTemplateLiteralType(it) => GetSpan::span(it.as_ref()), - Self::TSThisType(it) => GetSpan::span(it.as_ref()), - Self::TSTupleType(it) => GetSpan::span(it.as_ref()), - Self::TSTypeLiteral(it) => GetSpan::span(it.as_ref()), - Self::TSTypeOperatorType(it) => GetSpan::span(it.as_ref()), - Self::TSTypePredicate(it) => GetSpan::span(it.as_ref()), - Self::TSTypeQuery(it) => GetSpan::span(it.as_ref()), - Self::TSTypeReference(it) => GetSpan::span(it.as_ref()), - Self::TSUnionType(it) => GetSpan::span(it.as_ref()), - Self::TSParenthesizedType(it) => GetSpan::span(it.as_ref()), - Self::JSDocNullableType(it) => GetSpan::span(it.as_ref()), - Self::JSDocNonNullableType(it) => GetSpan::span(it.as_ref()), - Self::JSDocUnknownType(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for TSConditionalType<'_> { +impl GetSpan for JSXClosingElement<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSUnionType<'_> { +impl GetSpan for JSXFragment<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSIntersectionType<'_> { +impl GetSpan for JSXOpeningFragment { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSParenthesizedType<'_> { +impl GetSpan for JSXClosingFragment { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeOperator<'_> { - #[inline] +impl GetSpan for JSXElementName<'_> { fn span(&self) -> Span { - self.span + match self { + Self::Identifier(it) => GetSpan::span(it.as_ref()), + Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), + Self::NamespacedName(it) => GetSpan::span(it.as_ref()), + Self::MemberExpression(it) => GetSpan::span(it.as_ref()), + Self::ThisExpression(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for TSArrayType<'_> { +impl GetSpan for JSXNamespacedName<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSIndexedAccessType<'_> { +impl GetSpan for JSXMemberExpression<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTupleType<'_> { - #[inline] +impl GetSpan for JSXMemberExpressionObject<'_> { fn span(&self) -> Span { - self.span + match self { + Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), + Self::MemberExpression(it) => GetSpan::span(it.as_ref()), + Self::ThisExpression(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for TSNamedTupleMember<'_> { +impl GetSpan for JSXExpressionContainer<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSOptionalType<'_> { - #[inline] +impl GetSpan for JSXExpression<'_> { fn span(&self) -> Span { - self.span + match self { + Self::EmptyExpression(it) => GetSpan::span(it), + Self::BooleanLiteral(it) => GetSpan::span(it.as_ref()), + Self::NullLiteral(it) => GetSpan::span(it.as_ref()), + Self::NumericLiteral(it) => GetSpan::span(it.as_ref()), + Self::BigIntLiteral(it) => GetSpan::span(it.as_ref()), + Self::RegExpLiteral(it) => GetSpan::span(it.as_ref()), + Self::StringLiteral(it) => GetSpan::span(it.as_ref()), + Self::TemplateLiteral(it) => GetSpan::span(it.as_ref()), + Self::Identifier(it) => GetSpan::span(it.as_ref()), + Self::MetaProperty(it) => GetSpan::span(it.as_ref()), + Self::Super(it) => GetSpan::span(it.as_ref()), + Self::ArrayExpression(it) => GetSpan::span(it.as_ref()), + Self::ArrowFunctionExpression(it) => GetSpan::span(it.as_ref()), + Self::AssignmentExpression(it) => GetSpan::span(it.as_ref()), + Self::AwaitExpression(it) => GetSpan::span(it.as_ref()), + Self::BinaryExpression(it) => GetSpan::span(it.as_ref()), + Self::CallExpression(it) => GetSpan::span(it.as_ref()), + Self::ChainExpression(it) => GetSpan::span(it.as_ref()), + Self::ClassExpression(it) => GetSpan::span(it.as_ref()), + Self::ConditionalExpression(it) => GetSpan::span(it.as_ref()), + Self::FunctionExpression(it) => GetSpan::span(it.as_ref()), + Self::ImportExpression(it) => GetSpan::span(it.as_ref()), + Self::LogicalExpression(it) => GetSpan::span(it.as_ref()), + Self::NewExpression(it) => GetSpan::span(it.as_ref()), + Self::ObjectExpression(it) => GetSpan::span(it.as_ref()), + Self::ParenthesizedExpression(it) => GetSpan::span(it.as_ref()), + Self::SequenceExpression(it) => GetSpan::span(it.as_ref()), + Self::TaggedTemplateExpression(it) => GetSpan::span(it.as_ref()), + Self::ThisExpression(it) => GetSpan::span(it.as_ref()), + Self::UnaryExpression(it) => GetSpan::span(it.as_ref()), + Self::UpdateExpression(it) => GetSpan::span(it.as_ref()), + Self::YieldExpression(it) => GetSpan::span(it.as_ref()), + Self::PrivateInExpression(it) => GetSpan::span(it.as_ref()), + Self::JSXElement(it) => GetSpan::span(it.as_ref()), + Self::JSXFragment(it) => GetSpan::span(it.as_ref()), + Self::TSAsExpression(it) => GetSpan::span(it.as_ref()), + Self::TSSatisfiesExpression(it) => GetSpan::span(it.as_ref()), + Self::TSTypeAssertion(it) => GetSpan::span(it.as_ref()), + Self::TSNonNullExpression(it) => GetSpan::span(it.as_ref()), + Self::TSInstantiationExpression(it) => GetSpan::span(it.as_ref()), + Self::ComputedMemberExpression(it) => GetSpan::span(it.as_ref()), + Self::StaticMemberExpression(it) => GetSpan::span(it.as_ref()), + Self::PrivateFieldExpression(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for TSRestType<'_> { +impl GetSpan for JSXEmptyExpression { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTupleElement<'_> { +impl GetSpan for JSXAttributeItem<'_> { fn span(&self) -> Span { match self { - Self::TSOptionalType(it) => GetSpan::span(it.as_ref()), - Self::TSRestType(it) => GetSpan::span(it.as_ref()), - Self::TSAnyKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSBigIntKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSBooleanKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSIntrinsicKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSNeverKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSNullKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSNumberKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSObjectKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSStringKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSSymbolKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSUndefinedKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSUnknownKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSVoidKeyword(it) => GetSpan::span(it.as_ref()), - Self::TSArrayType(it) => GetSpan::span(it.as_ref()), - Self::TSConditionalType(it) => GetSpan::span(it.as_ref()), - Self::TSConstructorType(it) => GetSpan::span(it.as_ref()), - Self::TSFunctionType(it) => GetSpan::span(it.as_ref()), - Self::TSImportType(it) => GetSpan::span(it.as_ref()), - Self::TSIndexedAccessType(it) => GetSpan::span(it.as_ref()), - Self::TSInferType(it) => GetSpan::span(it.as_ref()), - Self::TSIntersectionType(it) => GetSpan::span(it.as_ref()), - Self::TSLiteralType(it) => GetSpan::span(it.as_ref()), - Self::TSMappedType(it) => GetSpan::span(it.as_ref()), - Self::TSNamedTupleMember(it) => GetSpan::span(it.as_ref()), - Self::TSQualifiedName(it) => GetSpan::span(it.as_ref()), - Self::TSTemplateLiteralType(it) => GetSpan::span(it.as_ref()), - Self::TSThisType(it) => GetSpan::span(it.as_ref()), - Self::TSTupleType(it) => GetSpan::span(it.as_ref()), - Self::TSTypeLiteral(it) => GetSpan::span(it.as_ref()), - Self::TSTypeOperatorType(it) => GetSpan::span(it.as_ref()), - Self::TSTypePredicate(it) => GetSpan::span(it.as_ref()), - Self::TSTypeQuery(it) => GetSpan::span(it.as_ref()), - Self::TSTypeReference(it) => GetSpan::span(it.as_ref()), - Self::TSUnionType(it) => GetSpan::span(it.as_ref()), - Self::TSParenthesizedType(it) => GetSpan::span(it.as_ref()), - Self::JSDocNullableType(it) => GetSpan::span(it.as_ref()), - Self::JSDocNonNullableType(it) => GetSpan::span(it.as_ref()), - Self::JSDocUnknownType(it) => GetSpan::span(it.as_ref()), + Self::Attribute(it) => GetSpan::span(it.as_ref()), + Self::SpreadAttribute(it) => GetSpan::span(it.as_ref()), } } } -impl GetSpan for TSAnyKeyword { +impl GetSpan for JSXAttribute<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSStringKeyword { +impl GetSpan for JSXSpreadAttribute<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSBooleanKeyword { - #[inline] +impl GetSpan for JSXAttributeName<'_> { fn span(&self) -> Span { - self.span - } + match self { + Self::Identifier(it) => GetSpan::span(it.as_ref()), + Self::NamespacedName(it) => GetSpan::span(it.as_ref()), + } + } } -impl GetSpan for TSNumberKeyword { - #[inline] +impl GetSpan for JSXAttributeValue<'_> { fn span(&self) -> Span { - self.span + match self { + Self::StringLiteral(it) => GetSpan::span(it.as_ref()), + Self::ExpressionContainer(it) => GetSpan::span(it.as_ref()), + Self::Element(it) => GetSpan::span(it.as_ref()), + Self::Fragment(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for TSNeverKeyword { +impl GetSpan for JSXIdentifier<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSIntrinsicKeyword { - #[inline] +impl GetSpan for JSXChild<'_> { fn span(&self) -> Span { - self.span + match self { + Self::Text(it) => GetSpan::span(it.as_ref()), + Self::Element(it) => GetSpan::span(it.as_ref()), + Self::Fragment(it) => GetSpan::span(it.as_ref()), + Self::ExpressionContainer(it) => GetSpan::span(it.as_ref()), + Self::Spread(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for TSUnknownKeyword { +impl GetSpan for JSXSpreadChild<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSNullKeyword { +impl GetSpan for JSXText<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSUndefinedKeyword { +impl GetSpan for TSThisParameter<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSVoidKeyword { +impl GetSpan for TSEnumDeclaration<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSSymbolKeyword { +impl GetSpan for TSEnumMember<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSThisType { - #[inline] +impl GetSpan for TSEnumMemberName<'_> { fn span(&self) -> Span { - self.span + match self { + Self::Identifier(it) => GetSpan::span(it.as_ref()), + Self::String(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for TSObjectKeyword { +impl GetSpan for TSTypeAnnotation<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSBigIntKeyword { +impl GetSpan for TSLiteralType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeReference<'_> { - #[inline] +impl GetSpan for TSLiteral<'_> { fn span(&self) -> Span { - self.span + match self { + Self::BooleanLiteral(it) => GetSpan::span(it.as_ref()), + Self::NullLiteral(it) => GetSpan::span(it.as_ref()), + Self::NumericLiteral(it) => GetSpan::span(it.as_ref()), + Self::BigIntLiteral(it) => GetSpan::span(it.as_ref()), + Self::RegExpLiteral(it) => GetSpan::span(it.as_ref()), + Self::StringLiteral(it) => GetSpan::span(it.as_ref()), + Self::TemplateLiteral(it) => GetSpan::span(it.as_ref()), + Self::UnaryExpression(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for TSTypeName<'_> { +impl GetSpan for TSType<'_> { fn span(&self) -> Span { match self { - Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), - Self::QualifiedName(it) => GetSpan::span(it.as_ref()), + Self::TSAnyKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSBigIntKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSBooleanKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSIntrinsicKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSNeverKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSNullKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSNumberKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSObjectKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSStringKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSSymbolKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSUndefinedKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSUnknownKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSVoidKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSArrayType(it) => GetSpan::span(it.as_ref()), + Self::TSConditionalType(it) => GetSpan::span(it.as_ref()), + Self::TSConstructorType(it) => GetSpan::span(it.as_ref()), + Self::TSFunctionType(it) => GetSpan::span(it.as_ref()), + Self::TSImportType(it) => GetSpan::span(it.as_ref()), + Self::TSIndexedAccessType(it) => GetSpan::span(it.as_ref()), + Self::TSInferType(it) => GetSpan::span(it.as_ref()), + Self::TSIntersectionType(it) => GetSpan::span(it.as_ref()), + Self::TSLiteralType(it) => GetSpan::span(it.as_ref()), + Self::TSMappedType(it) => GetSpan::span(it.as_ref()), + Self::TSNamedTupleMember(it) => GetSpan::span(it.as_ref()), + Self::TSQualifiedName(it) => GetSpan::span(it.as_ref()), + Self::TSTemplateLiteralType(it) => GetSpan::span(it.as_ref()), + Self::TSThisType(it) => GetSpan::span(it.as_ref()), + Self::TSTupleType(it) => GetSpan::span(it.as_ref()), + Self::TSTypeLiteral(it) => GetSpan::span(it.as_ref()), + Self::TSTypeOperatorType(it) => GetSpan::span(it.as_ref()), + Self::TSTypePredicate(it) => GetSpan::span(it.as_ref()), + Self::TSTypeQuery(it) => GetSpan::span(it.as_ref()), + Self::TSTypeReference(it) => GetSpan::span(it.as_ref()), + Self::TSUnionType(it) => GetSpan::span(it.as_ref()), + Self::TSParenthesizedType(it) => GetSpan::span(it.as_ref()), + Self::JSDocNullableType(it) => GetSpan::span(it.as_ref()), + Self::JSDocNonNullableType(it) => GetSpan::span(it.as_ref()), + Self::JSDocUnknownType(it) => GetSpan::span(it.as_ref()), } } } -impl GetSpan for TSQualifiedName<'_> { +impl GetSpan for TSConditionalType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeParameterInstantiation<'_> { +impl GetSpan for TSUnionType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeParameter<'_> { +impl GetSpan for TSIntersectionType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeParameterDeclaration<'_> { +impl GetSpan for TSParenthesizedType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeAliasDeclaration<'_> { +impl GetSpan for TSTypeOperator<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSClassImplements<'_> { +impl GetSpan for TSArrayType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSInterfaceDeclaration<'_> { +impl GetSpan for TSIndexedAccessType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSInterfaceBody<'_> { +impl GetSpan for TSTupleType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSPropertySignature<'_> { +impl GetSpan for TSNamedTupleMember<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSSignature<'_> { +impl GetSpan for TSOptionalType<'_> { + #[inline] + fn span(&self) -> Span { + self.span + } +} + +impl GetSpan for TSRestType<'_> { + #[inline] + fn span(&self) -> Span { + self.span + } +} + +impl GetSpan for TSTupleElement<'_> { fn span(&self) -> Span { match self { - Self::TSIndexSignature(it) => GetSpan::span(it.as_ref()), - Self::TSPropertySignature(it) => GetSpan::span(it.as_ref()), - Self::TSCallSignatureDeclaration(it) => GetSpan::span(it.as_ref()), - Self::TSConstructSignatureDeclaration(it) => GetSpan::span(it.as_ref()), - Self::TSMethodSignature(it) => GetSpan::span(it.as_ref()), + Self::TSOptionalType(it) => GetSpan::span(it.as_ref()), + Self::TSRestType(it) => GetSpan::span(it.as_ref()), + Self::TSAnyKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSBigIntKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSBooleanKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSIntrinsicKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSNeverKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSNullKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSNumberKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSObjectKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSStringKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSSymbolKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSUndefinedKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSUnknownKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSVoidKeyword(it) => GetSpan::span(it.as_ref()), + Self::TSArrayType(it) => GetSpan::span(it.as_ref()), + Self::TSConditionalType(it) => GetSpan::span(it.as_ref()), + Self::TSConstructorType(it) => GetSpan::span(it.as_ref()), + Self::TSFunctionType(it) => GetSpan::span(it.as_ref()), + Self::TSImportType(it) => GetSpan::span(it.as_ref()), + Self::TSIndexedAccessType(it) => GetSpan::span(it.as_ref()), + Self::TSInferType(it) => GetSpan::span(it.as_ref()), + Self::TSIntersectionType(it) => GetSpan::span(it.as_ref()), + Self::TSLiteralType(it) => GetSpan::span(it.as_ref()), + Self::TSMappedType(it) => GetSpan::span(it.as_ref()), + Self::TSNamedTupleMember(it) => GetSpan::span(it.as_ref()), + Self::TSQualifiedName(it) => GetSpan::span(it.as_ref()), + Self::TSTemplateLiteralType(it) => GetSpan::span(it.as_ref()), + Self::TSThisType(it) => GetSpan::span(it.as_ref()), + Self::TSTupleType(it) => GetSpan::span(it.as_ref()), + Self::TSTypeLiteral(it) => GetSpan::span(it.as_ref()), + Self::TSTypeOperatorType(it) => GetSpan::span(it.as_ref()), + Self::TSTypePredicate(it) => GetSpan::span(it.as_ref()), + Self::TSTypeQuery(it) => GetSpan::span(it.as_ref()), + Self::TSTypeReference(it) => GetSpan::span(it.as_ref()), + Self::TSUnionType(it) => GetSpan::span(it.as_ref()), + Self::TSParenthesizedType(it) => GetSpan::span(it.as_ref()), + Self::JSDocNullableType(it) => GetSpan::span(it.as_ref()), + Self::JSDocNonNullableType(it) => GetSpan::span(it.as_ref()), + Self::JSDocUnknownType(it) => GetSpan::span(it.as_ref()), } } } -impl GetSpan for TSIndexSignature<'_> { +impl GetSpan for TSAnyKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSCallSignatureDeclaration<'_> { +impl GetSpan for TSStringKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSMethodSignature<'_> { +impl GetSpan for TSBooleanKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSConstructSignatureDeclaration<'_> { +impl GetSpan for TSNumberKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSIndexSignatureName<'_> { +impl GetSpan for TSNeverKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSInterfaceHeritage<'_> { +impl GetSpan for TSIntrinsicKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypePredicate<'_> { +impl GetSpan for TSUnknownKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypePredicateName<'_> { +impl GetSpan for TSNullKeyword { + #[inline] fn span(&self) -> Span { - match self { - Self::Identifier(it) => GetSpan::span(it.as_ref()), - Self::This(it) => GetSpan::span(it), - } + self.span } } -impl GetSpan for TSModuleDeclaration<'_> { +impl GetSpan for TSUndefinedKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSModuleDeclarationName<'_> { +impl GetSpan for TSVoidKeyword { + #[inline] fn span(&self) -> Span { - match self { - Self::Identifier(it) => GetSpan::span(it), - Self::StringLiteral(it) => GetSpan::span(it), - } + self.span } } -impl GetSpan for TSModuleDeclarationBody<'_> { +impl GetSpan for TSSymbolKeyword { + #[inline] fn span(&self) -> Span { - match self { - Self::TSModuleDeclaration(it) => GetSpan::span(it.as_ref()), - Self::TSModuleBlock(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for TSModuleBlock<'_> { +impl GetSpan for TSThisType { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeLiteral<'_> { +impl GetSpan for TSObjectKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSInferType<'_> { +impl GetSpan for TSBigIntKeyword { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeQuery<'_> { +impl GetSpan for TSTypeReference<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTypeQueryExprName<'_> { +impl GetSpan for TSTypeName<'_> { fn span(&self) -> Span { match self { - Self::TSImportType(it) => GetSpan::span(it.as_ref()), Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), Self::QualifiedName(it) => GetSpan::span(it.as_ref()), } } } -impl GetSpan for TSImportType<'_> { +impl GetSpan for TSQualifiedName<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSImportAttributes<'_> { +impl GetSpan for TSTypeParameterInstantiation<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSImportAttribute<'_> { +impl GetSpan for TSTypeParameter<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSImportAttributeName<'_> { +impl GetSpan for TSTypeParameterDeclaration<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::Identifier(it) => GetSpan::span(it), - Self::StringLiteral(it) => GetSpan::span(it), - } + self.span } } -impl GetSpan for TSFunctionType<'_> { +impl GetSpan for TSTypeAliasDeclaration<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSConstructorType<'_> { +impl GetSpan for TSClassImplements<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSMappedType<'_> { +impl GetSpan for TSInterfaceDeclaration<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSTemplateLiteralType<'_> { +impl GetSpan for TSInterfaceBody<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSAsExpression<'_> { +impl GetSpan for TSPropertySignature<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSSatisfiesExpression<'_> { - #[inline] +impl GetSpan for TSSignature<'_> { fn span(&self) -> Span { - self.span + match self { + Self::TSIndexSignature(it) => GetSpan::span(it.as_ref()), + Self::TSPropertySignature(it) => GetSpan::span(it.as_ref()), + Self::TSCallSignatureDeclaration(it) => GetSpan::span(it.as_ref()), + Self::TSConstructSignatureDeclaration(it) => GetSpan::span(it.as_ref()), + Self::TSMethodSignature(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for TSTypeAssertion<'_> { +impl GetSpan for TSIndexSignature<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSImportEqualsDeclaration<'_> { +impl GetSpan for TSCallSignatureDeclaration<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSModuleReference<'_> { +impl GetSpan for TSMethodSignature<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::ExternalModuleReference(it) => GetSpan::span(it.as_ref()), - Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), - Self::QualifiedName(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for TSExternalModuleReference<'_> { +impl GetSpan for TSConstructSignatureDeclaration<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSNonNullExpression<'_> { +impl GetSpan for TSIndexSignatureName<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for Decorator<'_> { +impl GetSpan for TSInterfaceHeritage<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSExportAssignment<'_> { +impl GetSpan for TSTypePredicate<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for TSNamespaceExportDeclaration<'_> { - #[inline] +impl GetSpan for TSTypePredicateName<'_> { fn span(&self) -> Span { - self.span + match self { + Self::Identifier(it) => GetSpan::span(it.as_ref()), + Self::This(it) => GetSpan::span(it), + } } } -impl GetSpan for TSInstantiationExpression<'_> { +impl GetSpan for TSModuleDeclaration<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSDocNullableType<'_> { - #[inline] +impl GetSpan for TSModuleDeclarationName<'_> { fn span(&self) -> Span { - self.span + match self { + Self::Identifier(it) => GetSpan::span(it), + Self::StringLiteral(it) => GetSpan::span(it), + } } } -impl GetSpan for JSDocNonNullableType<'_> { - #[inline] +impl GetSpan for TSModuleDeclarationBody<'_> { fn span(&self) -> Span { - self.span + match self { + Self::TSModuleDeclaration(it) => GetSpan::span(it.as_ref()), + Self::TSModuleBlock(it) => GetSpan::span(it.as_ref()), + } } } -impl GetSpan for JSDocUnknownType { +impl GetSpan for TSModuleBlock<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXElement<'_> { +impl GetSpan for TSTypeLiteral<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXOpeningElement<'_> { +impl GetSpan for TSInferType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXClosingElement<'_> { +impl GetSpan for TSTypeQuery<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXFragment<'_> { +impl GetSpan for TSTypeQueryExprName<'_> { + fn span(&self) -> Span { + match self { + Self::TSImportType(it) => GetSpan::span(it.as_ref()), + Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), + Self::QualifiedName(it) => GetSpan::span(it.as_ref()), + } + } +} + +impl GetSpan for TSImportType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXOpeningFragment { +impl GetSpan for TSImportAttributes<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXClosingFragment { +impl GetSpan for TSImportAttribute<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXElementName<'_> { +impl GetSpan for TSImportAttributeName<'_> { fn span(&self) -> Span { match self { - Self::Identifier(it) => GetSpan::span(it.as_ref()), - Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), - Self::NamespacedName(it) => GetSpan::span(it.as_ref()), - Self::MemberExpression(it) => GetSpan::span(it.as_ref()), - Self::ThisExpression(it) => GetSpan::span(it.as_ref()), + Self::Identifier(it) => GetSpan::span(it), + Self::StringLiteral(it) => GetSpan::span(it), } } } -impl GetSpan for JSXNamespacedName<'_> { +impl GetSpan for TSFunctionType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXMemberExpression<'_> { +impl GetSpan for TSConstructorType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXMemberExpressionObject<'_> { +impl GetSpan for TSMappedType<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), - Self::MemberExpression(it) => GetSpan::span(it.as_ref()), - Self::ThisExpression(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for JSXExpressionContainer<'_> { +impl GetSpan for TSTemplateLiteralType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXExpression<'_> { +impl GetSpan for TSAsExpression<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::EmptyExpression(it) => GetSpan::span(it), - Self::BooleanLiteral(it) => GetSpan::span(it.as_ref()), - Self::NullLiteral(it) => GetSpan::span(it.as_ref()), - Self::NumericLiteral(it) => GetSpan::span(it.as_ref()), - Self::BigIntLiteral(it) => GetSpan::span(it.as_ref()), - Self::RegExpLiteral(it) => GetSpan::span(it.as_ref()), - Self::StringLiteral(it) => GetSpan::span(it.as_ref()), - Self::TemplateLiteral(it) => GetSpan::span(it.as_ref()), - Self::Identifier(it) => GetSpan::span(it.as_ref()), - Self::MetaProperty(it) => GetSpan::span(it.as_ref()), - Self::Super(it) => GetSpan::span(it.as_ref()), - Self::ArrayExpression(it) => GetSpan::span(it.as_ref()), - Self::ArrowFunctionExpression(it) => GetSpan::span(it.as_ref()), - Self::AssignmentExpression(it) => GetSpan::span(it.as_ref()), - Self::AwaitExpression(it) => GetSpan::span(it.as_ref()), - Self::BinaryExpression(it) => GetSpan::span(it.as_ref()), - Self::CallExpression(it) => GetSpan::span(it.as_ref()), - Self::ChainExpression(it) => GetSpan::span(it.as_ref()), - Self::ClassExpression(it) => GetSpan::span(it.as_ref()), - Self::ConditionalExpression(it) => GetSpan::span(it.as_ref()), - Self::FunctionExpression(it) => GetSpan::span(it.as_ref()), - Self::ImportExpression(it) => GetSpan::span(it.as_ref()), - Self::LogicalExpression(it) => GetSpan::span(it.as_ref()), - Self::NewExpression(it) => GetSpan::span(it.as_ref()), - Self::ObjectExpression(it) => GetSpan::span(it.as_ref()), - Self::ParenthesizedExpression(it) => GetSpan::span(it.as_ref()), - Self::SequenceExpression(it) => GetSpan::span(it.as_ref()), - Self::TaggedTemplateExpression(it) => GetSpan::span(it.as_ref()), - Self::ThisExpression(it) => GetSpan::span(it.as_ref()), - Self::UnaryExpression(it) => GetSpan::span(it.as_ref()), - Self::UpdateExpression(it) => GetSpan::span(it.as_ref()), - Self::YieldExpression(it) => GetSpan::span(it.as_ref()), - Self::PrivateInExpression(it) => GetSpan::span(it.as_ref()), - Self::JSXElement(it) => GetSpan::span(it.as_ref()), - Self::JSXFragment(it) => GetSpan::span(it.as_ref()), - Self::TSAsExpression(it) => GetSpan::span(it.as_ref()), - Self::TSSatisfiesExpression(it) => GetSpan::span(it.as_ref()), - Self::TSTypeAssertion(it) => GetSpan::span(it.as_ref()), - Self::TSNonNullExpression(it) => GetSpan::span(it.as_ref()), - Self::TSInstantiationExpression(it) => GetSpan::span(it.as_ref()), - Self::ComputedMemberExpression(it) => GetSpan::span(it.as_ref()), - Self::StaticMemberExpression(it) => GetSpan::span(it.as_ref()), - Self::PrivateFieldExpression(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for JSXEmptyExpression { +impl GetSpan for TSSatisfiesExpression<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXAttributeItem<'_> { +impl GetSpan for TSTypeAssertion<'_> { + #[inline] + fn span(&self) -> Span { + self.span + } +} + +impl GetSpan for TSImportEqualsDeclaration<'_> { + #[inline] + fn span(&self) -> Span { + self.span + } +} + +impl GetSpan for TSModuleReference<'_> { fn span(&self) -> Span { match self { - Self::Attribute(it) => GetSpan::span(it.as_ref()), - Self::SpreadAttribute(it) => GetSpan::span(it.as_ref()), + Self::ExternalModuleReference(it) => GetSpan::span(it.as_ref()), + Self::IdentifierReference(it) => GetSpan::span(it.as_ref()), + Self::QualifiedName(it) => GetSpan::span(it.as_ref()), } } } -impl GetSpan for JSXAttribute<'_> { +impl GetSpan for TSExternalModuleReference<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXSpreadAttribute<'_> { +impl GetSpan for TSNonNullExpression<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXAttributeName<'_> { +impl GetSpan for Decorator<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::Identifier(it) => GetSpan::span(it.as_ref()), - Self::NamespacedName(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for JSXAttributeValue<'_> { +impl GetSpan for TSExportAssignment<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::StringLiteral(it) => GetSpan::span(it.as_ref()), - Self::ExpressionContainer(it) => GetSpan::span(it.as_ref()), - Self::Element(it) => GetSpan::span(it.as_ref()), - Self::Fragment(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for JSXIdentifier<'_> { +impl GetSpan for TSNamespaceExportDeclaration<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXChild<'_> { +impl GetSpan for TSInstantiationExpression<'_> { + #[inline] fn span(&self) -> Span { - match self { - Self::Text(it) => GetSpan::span(it.as_ref()), - Self::Element(it) => GetSpan::span(it.as_ref()), - Self::Fragment(it) => GetSpan::span(it.as_ref()), - Self::ExpressionContainer(it) => GetSpan::span(it.as_ref()), - Self::Spread(it) => GetSpan::span(it.as_ref()), - } + self.span } } -impl GetSpan for JSXSpreadChild<'_> { +impl GetSpan for JSDocNullableType<'_> { #[inline] fn span(&self) -> Span { self.span } } -impl GetSpan for JSXText<'_> { +impl GetSpan for JSDocNonNullableType<'_> { + #[inline] + fn span(&self) -> Span { + self.span + } +} + +impl GetSpan for JSDocUnknownType { #[inline] fn span(&self) -> Span { self.span diff --git a/crates/oxc_ast/src/generated/derive_get_span_mut.rs b/crates/oxc_ast/src/generated/derive_get_span_mut.rs index 705eb520a670f..57f522eae5781 100644 --- a/crates/oxc_ast/src/generated/derive_get_span_mut.rs +++ b/crates/oxc_ast/src/generated/derive_get_span_mut.rs @@ -10,48 +10,6 @@ use crate::ast::jsx::*; use crate::ast::literal::*; use crate::ast::ts::*; -impl GetSpanMut for BooleanLiteral { - #[inline] - fn span_mut(&mut self) -> &mut Span { - &mut self.span - } -} - -impl GetSpanMut for NullLiteral { - #[inline] - fn span_mut(&mut self) -> &mut Span { - &mut self.span - } -} - -impl GetSpanMut for NumericLiteral<'_> { - #[inline] - fn span_mut(&mut self) -> &mut Span { - &mut self.span - } -} - -impl GetSpanMut for StringLiteral<'_> { - #[inline] - fn span_mut(&mut self) -> &mut Span { - &mut self.span - } -} - -impl GetSpanMut for BigIntLiteral<'_> { - #[inline] - fn span_mut(&mut self) -> &mut Span { - &mut self.span - } -} - -impl GetSpanMut for RegExpLiteral<'_> { - #[inline] - fn span_mut(&mut self) -> &mut Span { - &mut self.span - } -} - impl GetSpanMut for Program<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { @@ -1246,915 +1204,957 @@ impl GetSpanMut for ModuleExportName<'_> { } } -impl GetSpanMut for TSThisParameter<'_> { +impl GetSpanMut for BooleanLiteral { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSEnumDeclaration<'_> { +impl GetSpanMut for NullLiteral { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSEnumMember<'_> { +impl GetSpanMut for NumericLiteral<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSEnumMemberName<'_> { +impl GetSpanMut for StringLiteral<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), - Self::String(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for TSTypeAnnotation<'_> { +impl GetSpanMut for BigIntLiteral<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSLiteralType<'_> { +impl GetSpanMut for RegExpLiteral<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSLiteral<'_> { +impl GetSpanMut for JSXElement<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::BooleanLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::NullLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::NumericLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::BigIntLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::RegExpLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::StringLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::TemplateLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::UnaryExpression(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for TSType<'_> { +impl GetSpanMut for JSXOpeningElement<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::TSAnyKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSBigIntKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSBooleanKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSIntrinsicKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNeverKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNullKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNumberKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSObjectKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSStringKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSSymbolKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSUndefinedKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSUnknownKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSVoidKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSArrayType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSConditionalType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSConstructorType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSFunctionType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSImportType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSIndexedAccessType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSInferType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSIntersectionType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSLiteralType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSMappedType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNamedTupleMember(it) => GetSpanMut::span_mut(&mut **it), - Self::TSQualifiedName(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTemplateLiteralType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSThisType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTupleType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeOperatorType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypePredicate(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeQuery(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeReference(it) => GetSpanMut::span_mut(&mut **it), - Self::TSUnionType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSParenthesizedType(it) => GetSpanMut::span_mut(&mut **it), - Self::JSDocNullableType(it) => GetSpanMut::span_mut(&mut **it), - Self::JSDocNonNullableType(it) => GetSpanMut::span_mut(&mut **it), - Self::JSDocUnknownType(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for TSConditionalType<'_> { +impl GetSpanMut for JSXClosingElement<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSUnionType<'_> { +impl GetSpanMut for JSXFragment<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSIntersectionType<'_> { +impl GetSpanMut for JSXOpeningFragment { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSParenthesizedType<'_> { +impl GetSpanMut for JSXClosingFragment { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeOperator<'_> { - #[inline] +impl GetSpanMut for JSXElementName<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), + Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), + Self::NamespacedName(it) => GetSpanMut::span_mut(&mut **it), + Self::MemberExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ThisExpression(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for TSArrayType<'_> { +impl GetSpanMut for JSXNamespacedName<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSIndexedAccessType<'_> { +impl GetSpanMut for JSXMemberExpression<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTupleType<'_> { - #[inline] +impl GetSpanMut for JSXMemberExpressionObject<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), + Self::MemberExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ThisExpression(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for TSNamedTupleMember<'_> { +impl GetSpanMut for JSXExpressionContainer<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSOptionalType<'_> { - #[inline] +impl GetSpanMut for JSXExpression<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::EmptyExpression(it) => GetSpanMut::span_mut(it), + Self::BooleanLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::NullLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::NumericLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::BigIntLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::RegExpLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::StringLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::TemplateLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), + Self::MetaProperty(it) => GetSpanMut::span_mut(&mut **it), + Self::Super(it) => GetSpanMut::span_mut(&mut **it), + Self::ArrayExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ArrowFunctionExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::AssignmentExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::AwaitExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::BinaryExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::CallExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ChainExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ClassExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ConditionalExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::FunctionExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ImportExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::LogicalExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::NewExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ObjectExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ParenthesizedExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::SequenceExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::TaggedTemplateExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ThisExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::UnaryExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::UpdateExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::YieldExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::PrivateInExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::JSXElement(it) => GetSpanMut::span_mut(&mut **it), + Self::JSXFragment(it) => GetSpanMut::span_mut(&mut **it), + Self::TSAsExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::TSSatisfiesExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeAssertion(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNonNullExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::TSInstantiationExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::ComputedMemberExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::StaticMemberExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::PrivateFieldExpression(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for TSRestType<'_> { +impl GetSpanMut for JSXEmptyExpression { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTupleElement<'_> { +impl GetSpanMut for JSXAttributeItem<'_> { fn span_mut(&mut self) -> &mut Span { match self { - Self::TSOptionalType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSRestType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSAnyKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSBigIntKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSBooleanKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSIntrinsicKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNeverKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNullKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNumberKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSObjectKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSStringKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSSymbolKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSUndefinedKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSUnknownKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSVoidKeyword(it) => GetSpanMut::span_mut(&mut **it), - Self::TSArrayType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSConditionalType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSConstructorType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSFunctionType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSImportType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSIndexedAccessType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSInferType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSIntersectionType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSLiteralType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSMappedType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNamedTupleMember(it) => GetSpanMut::span_mut(&mut **it), - Self::TSQualifiedName(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTemplateLiteralType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSThisType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTupleType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeOperatorType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypePredicate(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeQuery(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeReference(it) => GetSpanMut::span_mut(&mut **it), - Self::TSUnionType(it) => GetSpanMut::span_mut(&mut **it), - Self::TSParenthesizedType(it) => GetSpanMut::span_mut(&mut **it), - Self::JSDocNullableType(it) => GetSpanMut::span_mut(&mut **it), - Self::JSDocNonNullableType(it) => GetSpanMut::span_mut(&mut **it), - Self::JSDocUnknownType(it) => GetSpanMut::span_mut(&mut **it), + Self::Attribute(it) => GetSpanMut::span_mut(&mut **it), + Self::SpreadAttribute(it) => GetSpanMut::span_mut(&mut **it), } } } -impl GetSpanMut for TSAnyKeyword { +impl GetSpanMut for JSXAttribute<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSStringKeyword { +impl GetSpanMut for JSXSpreadAttribute<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSBooleanKeyword { - #[inline] +impl GetSpanMut for JSXAttributeName<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span - } + match self { + Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), + Self::NamespacedName(it) => GetSpanMut::span_mut(&mut **it), + } + } } -impl GetSpanMut for TSNumberKeyword { - #[inline] +impl GetSpanMut for JSXAttributeValue<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::StringLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::ExpressionContainer(it) => GetSpanMut::span_mut(&mut **it), + Self::Element(it) => GetSpanMut::span_mut(&mut **it), + Self::Fragment(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for TSNeverKeyword { +impl GetSpanMut for JSXIdentifier<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSIntrinsicKeyword { - #[inline] +impl GetSpanMut for JSXChild<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::Text(it) => GetSpanMut::span_mut(&mut **it), + Self::Element(it) => GetSpanMut::span_mut(&mut **it), + Self::Fragment(it) => GetSpanMut::span_mut(&mut **it), + Self::ExpressionContainer(it) => GetSpanMut::span_mut(&mut **it), + Self::Spread(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for TSUnknownKeyword { +impl GetSpanMut for JSXSpreadChild<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSNullKeyword { +impl GetSpanMut for JSXText<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSUndefinedKeyword { +impl GetSpanMut for TSThisParameter<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSVoidKeyword { +impl GetSpanMut for TSEnumDeclaration<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSSymbolKeyword { +impl GetSpanMut for TSEnumMember<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSThisType { - #[inline] +impl GetSpanMut for TSEnumMemberName<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), + Self::String(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for TSObjectKeyword { +impl GetSpanMut for TSTypeAnnotation<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSBigIntKeyword { +impl GetSpanMut for TSLiteralType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeReference<'_> { - #[inline] +impl GetSpanMut for TSLiteral<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::BooleanLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::NullLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::NumericLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::BigIntLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::RegExpLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::StringLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::TemplateLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::UnaryExpression(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for TSTypeName<'_> { +impl GetSpanMut for TSType<'_> { fn span_mut(&mut self) -> &mut Span { match self { - Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), - Self::QualifiedName(it) => GetSpanMut::span_mut(&mut **it), + Self::TSAnyKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSBigIntKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSBooleanKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSIntrinsicKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNeverKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNullKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNumberKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSObjectKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSStringKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSSymbolKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSUndefinedKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSUnknownKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSVoidKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSArrayType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSConditionalType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSConstructorType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSFunctionType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSImportType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSIndexedAccessType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSInferType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSIntersectionType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSLiteralType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSMappedType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNamedTupleMember(it) => GetSpanMut::span_mut(&mut **it), + Self::TSQualifiedName(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTemplateLiteralType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSThisType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTupleType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeOperatorType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypePredicate(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeQuery(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeReference(it) => GetSpanMut::span_mut(&mut **it), + Self::TSUnionType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSParenthesizedType(it) => GetSpanMut::span_mut(&mut **it), + Self::JSDocNullableType(it) => GetSpanMut::span_mut(&mut **it), + Self::JSDocNonNullableType(it) => GetSpanMut::span_mut(&mut **it), + Self::JSDocUnknownType(it) => GetSpanMut::span_mut(&mut **it), } } } -impl GetSpanMut for TSQualifiedName<'_> { +impl GetSpanMut for TSConditionalType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeParameterInstantiation<'_> { +impl GetSpanMut for TSUnionType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeParameter<'_> { +impl GetSpanMut for TSIntersectionType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeParameterDeclaration<'_> { +impl GetSpanMut for TSParenthesizedType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeAliasDeclaration<'_> { +impl GetSpanMut for TSTypeOperator<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSClassImplements<'_> { +impl GetSpanMut for TSArrayType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSInterfaceDeclaration<'_> { +impl GetSpanMut for TSIndexedAccessType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSInterfaceBody<'_> { +impl GetSpanMut for TSTupleType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSPropertySignature<'_> { +impl GetSpanMut for TSNamedTupleMember<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSSignature<'_> { +impl GetSpanMut for TSOptionalType<'_> { + #[inline] + fn span_mut(&mut self) -> &mut Span { + &mut self.span + } +} + +impl GetSpanMut for TSRestType<'_> { + #[inline] + fn span_mut(&mut self) -> &mut Span { + &mut self.span + } +} + +impl GetSpanMut for TSTupleElement<'_> { fn span_mut(&mut self) -> &mut Span { match self { - Self::TSIndexSignature(it) => GetSpanMut::span_mut(&mut **it), - Self::TSPropertySignature(it) => GetSpanMut::span_mut(&mut **it), - Self::TSCallSignatureDeclaration(it) => GetSpanMut::span_mut(&mut **it), - Self::TSConstructSignatureDeclaration(it) => GetSpanMut::span_mut(&mut **it), - Self::TSMethodSignature(it) => GetSpanMut::span_mut(&mut **it), + Self::TSOptionalType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSRestType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSAnyKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSBigIntKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSBooleanKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSIntrinsicKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNeverKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNullKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNumberKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSObjectKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSStringKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSSymbolKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSUndefinedKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSUnknownKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSVoidKeyword(it) => GetSpanMut::span_mut(&mut **it), + Self::TSArrayType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSConditionalType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSConstructorType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSFunctionType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSImportType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSIndexedAccessType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSInferType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSIntersectionType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSLiteralType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSMappedType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSNamedTupleMember(it) => GetSpanMut::span_mut(&mut **it), + Self::TSQualifiedName(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTemplateLiteralType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSThisType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTupleType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeLiteral(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeOperatorType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypePredicate(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeQuery(it) => GetSpanMut::span_mut(&mut **it), + Self::TSTypeReference(it) => GetSpanMut::span_mut(&mut **it), + Self::TSUnionType(it) => GetSpanMut::span_mut(&mut **it), + Self::TSParenthesizedType(it) => GetSpanMut::span_mut(&mut **it), + Self::JSDocNullableType(it) => GetSpanMut::span_mut(&mut **it), + Self::JSDocNonNullableType(it) => GetSpanMut::span_mut(&mut **it), + Self::JSDocUnknownType(it) => GetSpanMut::span_mut(&mut **it), } } } -impl GetSpanMut for TSIndexSignature<'_> { +impl GetSpanMut for TSAnyKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSCallSignatureDeclaration<'_> { +impl GetSpanMut for TSStringKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSMethodSignature<'_> { +impl GetSpanMut for TSBooleanKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSConstructSignatureDeclaration<'_> { +impl GetSpanMut for TSNumberKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSIndexSignatureName<'_> { +impl GetSpanMut for TSNeverKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSInterfaceHeritage<'_> { +impl GetSpanMut for TSIntrinsicKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypePredicate<'_> { +impl GetSpanMut for TSUnknownKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypePredicateName<'_> { +impl GetSpanMut for TSNullKeyword { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), - Self::This(it) => GetSpanMut::span_mut(it), - } + &mut self.span } } -impl GetSpanMut for TSModuleDeclaration<'_> { +impl GetSpanMut for TSUndefinedKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSModuleDeclarationName<'_> { +impl GetSpanMut for TSVoidKeyword { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::Identifier(it) => GetSpanMut::span_mut(it), - Self::StringLiteral(it) => GetSpanMut::span_mut(it), - } + &mut self.span } } -impl GetSpanMut for TSModuleDeclarationBody<'_> { +impl GetSpanMut for TSSymbolKeyword { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::TSModuleDeclaration(it) => GetSpanMut::span_mut(&mut **it), - Self::TSModuleBlock(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for TSModuleBlock<'_> { +impl GetSpanMut for TSThisType { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeLiteral<'_> { +impl GetSpanMut for TSObjectKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSInferType<'_> { +impl GetSpanMut for TSBigIntKeyword { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeQuery<'_> { +impl GetSpanMut for TSTypeReference<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTypeQueryExprName<'_> { +impl GetSpanMut for TSTypeName<'_> { fn span_mut(&mut self) -> &mut Span { match self { - Self::TSImportType(it) => GetSpanMut::span_mut(&mut **it), Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), Self::QualifiedName(it) => GetSpanMut::span_mut(&mut **it), } } } -impl GetSpanMut for TSImportType<'_> { +impl GetSpanMut for TSQualifiedName<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSImportAttributes<'_> { +impl GetSpanMut for TSTypeParameterInstantiation<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSImportAttribute<'_> { +impl GetSpanMut for TSTypeParameter<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSImportAttributeName<'_> { +impl GetSpanMut for TSTypeParameterDeclaration<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::Identifier(it) => GetSpanMut::span_mut(it), - Self::StringLiteral(it) => GetSpanMut::span_mut(it), - } + &mut self.span } } -impl GetSpanMut for TSFunctionType<'_> { +impl GetSpanMut for TSTypeAliasDeclaration<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSConstructorType<'_> { +impl GetSpanMut for TSClassImplements<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSMappedType<'_> { +impl GetSpanMut for TSInterfaceDeclaration<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSTemplateLiteralType<'_> { +impl GetSpanMut for TSInterfaceBody<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSAsExpression<'_> { +impl GetSpanMut for TSPropertySignature<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSSatisfiesExpression<'_> { - #[inline] +impl GetSpanMut for TSSignature<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::TSIndexSignature(it) => GetSpanMut::span_mut(&mut **it), + Self::TSPropertySignature(it) => GetSpanMut::span_mut(&mut **it), + Self::TSCallSignatureDeclaration(it) => GetSpanMut::span_mut(&mut **it), + Self::TSConstructSignatureDeclaration(it) => GetSpanMut::span_mut(&mut **it), + Self::TSMethodSignature(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for TSTypeAssertion<'_> { +impl GetSpanMut for TSIndexSignature<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSImportEqualsDeclaration<'_> { +impl GetSpanMut for TSCallSignatureDeclaration<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSModuleReference<'_> { +impl GetSpanMut for TSMethodSignature<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::ExternalModuleReference(it) => GetSpanMut::span_mut(&mut **it), - Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), - Self::QualifiedName(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for TSExternalModuleReference<'_> { +impl GetSpanMut for TSConstructSignatureDeclaration<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSNonNullExpression<'_> { +impl GetSpanMut for TSIndexSignatureName<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for Decorator<'_> { +impl GetSpanMut for TSInterfaceHeritage<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSExportAssignment<'_> { +impl GetSpanMut for TSTypePredicate<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for TSNamespaceExportDeclaration<'_> { - #[inline] +impl GetSpanMut for TSTypePredicateName<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), + Self::This(it) => GetSpanMut::span_mut(it), + } } } -impl GetSpanMut for TSInstantiationExpression<'_> { +impl GetSpanMut for TSModuleDeclaration<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSDocNullableType<'_> { - #[inline] +impl GetSpanMut for TSModuleDeclarationName<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::Identifier(it) => GetSpanMut::span_mut(it), + Self::StringLiteral(it) => GetSpanMut::span_mut(it), + } } } -impl GetSpanMut for JSDocNonNullableType<'_> { - #[inline] +impl GetSpanMut for TSModuleDeclarationBody<'_> { fn span_mut(&mut self) -> &mut Span { - &mut self.span + match self { + Self::TSModuleDeclaration(it) => GetSpanMut::span_mut(&mut **it), + Self::TSModuleBlock(it) => GetSpanMut::span_mut(&mut **it), + } } } -impl GetSpanMut for JSDocUnknownType { +impl GetSpanMut for TSModuleBlock<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXElement<'_> { +impl GetSpanMut for TSTypeLiteral<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXOpeningElement<'_> { +impl GetSpanMut for TSInferType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXClosingElement<'_> { +impl GetSpanMut for TSTypeQuery<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXFragment<'_> { +impl GetSpanMut for TSTypeQueryExprName<'_> { + fn span_mut(&mut self) -> &mut Span { + match self { + Self::TSImportType(it) => GetSpanMut::span_mut(&mut **it), + Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), + Self::QualifiedName(it) => GetSpanMut::span_mut(&mut **it), + } + } +} + +impl GetSpanMut for TSImportType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXOpeningFragment { +impl GetSpanMut for TSImportAttributes<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXClosingFragment { +impl GetSpanMut for TSImportAttribute<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXElementName<'_> { +impl GetSpanMut for TSImportAttributeName<'_> { fn span_mut(&mut self) -> &mut Span { match self { - Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), - Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), - Self::NamespacedName(it) => GetSpanMut::span_mut(&mut **it), - Self::MemberExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ThisExpression(it) => GetSpanMut::span_mut(&mut **it), + Self::Identifier(it) => GetSpanMut::span_mut(it), + Self::StringLiteral(it) => GetSpanMut::span_mut(it), } } } -impl GetSpanMut for JSXNamespacedName<'_> { +impl GetSpanMut for TSFunctionType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXMemberExpression<'_> { +impl GetSpanMut for TSConstructorType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXMemberExpressionObject<'_> { +impl GetSpanMut for TSMappedType<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), - Self::MemberExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ThisExpression(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for JSXExpressionContainer<'_> { +impl GetSpanMut for TSTemplateLiteralType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXExpression<'_> { +impl GetSpanMut for TSAsExpression<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::EmptyExpression(it) => GetSpanMut::span_mut(it), - Self::BooleanLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::NullLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::NumericLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::BigIntLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::RegExpLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::StringLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::TemplateLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), - Self::MetaProperty(it) => GetSpanMut::span_mut(&mut **it), - Self::Super(it) => GetSpanMut::span_mut(&mut **it), - Self::ArrayExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ArrowFunctionExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::AssignmentExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::AwaitExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::BinaryExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::CallExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ChainExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ClassExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ConditionalExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::FunctionExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ImportExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::LogicalExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::NewExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ObjectExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ParenthesizedExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::SequenceExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::TaggedTemplateExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ThisExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::UnaryExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::UpdateExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::YieldExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::PrivateInExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::JSXElement(it) => GetSpanMut::span_mut(&mut **it), - Self::JSXFragment(it) => GetSpanMut::span_mut(&mut **it), - Self::TSAsExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::TSSatisfiesExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::TSTypeAssertion(it) => GetSpanMut::span_mut(&mut **it), - Self::TSNonNullExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::TSInstantiationExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::ComputedMemberExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::StaticMemberExpression(it) => GetSpanMut::span_mut(&mut **it), - Self::PrivateFieldExpression(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for JSXEmptyExpression { +impl GetSpanMut for TSSatisfiesExpression<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXAttributeItem<'_> { +impl GetSpanMut for TSTypeAssertion<'_> { + #[inline] + fn span_mut(&mut self) -> &mut Span { + &mut self.span + } +} + +impl GetSpanMut for TSImportEqualsDeclaration<'_> { + #[inline] + fn span_mut(&mut self) -> &mut Span { + &mut self.span + } +} + +impl GetSpanMut for TSModuleReference<'_> { fn span_mut(&mut self) -> &mut Span { match self { - Self::Attribute(it) => GetSpanMut::span_mut(&mut **it), - Self::SpreadAttribute(it) => GetSpanMut::span_mut(&mut **it), + Self::ExternalModuleReference(it) => GetSpanMut::span_mut(&mut **it), + Self::IdentifierReference(it) => GetSpanMut::span_mut(&mut **it), + Self::QualifiedName(it) => GetSpanMut::span_mut(&mut **it), } } } -impl GetSpanMut for JSXAttribute<'_> { +impl GetSpanMut for TSExternalModuleReference<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXSpreadAttribute<'_> { +impl GetSpanMut for TSNonNullExpression<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXAttributeName<'_> { +impl GetSpanMut for Decorator<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::Identifier(it) => GetSpanMut::span_mut(&mut **it), - Self::NamespacedName(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for JSXAttributeValue<'_> { +impl GetSpanMut for TSExportAssignment<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::StringLiteral(it) => GetSpanMut::span_mut(&mut **it), - Self::ExpressionContainer(it) => GetSpanMut::span_mut(&mut **it), - Self::Element(it) => GetSpanMut::span_mut(&mut **it), - Self::Fragment(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for JSXIdentifier<'_> { +impl GetSpanMut for TSNamespaceExportDeclaration<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXChild<'_> { +impl GetSpanMut for TSInstantiationExpression<'_> { + #[inline] fn span_mut(&mut self) -> &mut Span { - match self { - Self::Text(it) => GetSpanMut::span_mut(&mut **it), - Self::Element(it) => GetSpanMut::span_mut(&mut **it), - Self::Fragment(it) => GetSpanMut::span_mut(&mut **it), - Self::ExpressionContainer(it) => GetSpanMut::span_mut(&mut **it), - Self::Spread(it) => GetSpanMut::span_mut(&mut **it), - } + &mut self.span } } -impl GetSpanMut for JSXSpreadChild<'_> { +impl GetSpanMut for JSDocNullableType<'_> { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span } } -impl GetSpanMut for JSXText<'_> { +impl GetSpanMut for JSDocNonNullableType<'_> { + #[inline] + fn span_mut(&mut self) -> &mut Span { + &mut self.span + } +} + +impl GetSpanMut for JSDocUnknownType { #[inline] fn span_mut(&mut self) -> &mut Span { &mut self.span diff --git a/npm/oxc-types/types.d.ts b/npm/oxc-types/types.d.ts index acfb2b674580d..ccc51df4c8193 100644 --- a/npm/oxc-types/types.d.ts +++ b/npm/oxc-types/types.d.ts @@ -1,51 +1,6 @@ // Auto-generated code, DO NOT EDIT DIRECTLY! // To edit this generated file you have to edit `tasks/ast_tools/src/generators/typescript.rs` -export interface BooleanLiteral extends Span { - type: 'Literal'; - value: boolean; - raw: string | null; -} - -export interface NullLiteral extends Span { - type: 'Literal'; - value: null; - raw: 'null' | null; -} - -export interface NumericLiteral extends Span { - type: 'Literal'; - value: number; - raw: string | null; -} - -export interface StringLiteral extends Span { - type: 'Literal'; - value: string; - raw: string | null; -} - -export interface BigIntLiteral extends Span { - type: 'Literal'; - raw: string | null; - value: null; - bigint: string; -} - -export interface RegExpLiteral extends Span { - type: 'Literal'; - raw: string | null; - value: {} | null; - regex: { pattern: string; flags: string }; -} - -export interface RegExp { - pattern: RegExpPattern; - flags: RegExpFlags; -} - -export type RegExpPattern = string | string | Pattern; - export interface Program extends Span { type: 'Program'; sourceType: SourceType; @@ -1032,6 +987,186 @@ export type ExportDefaultDeclarationKind = export type ModuleExportName = IdentifierName | IdentifierReference | StringLiteral; +export interface BooleanLiteral extends Span { + type: 'Literal'; + value: boolean; + raw: string | null; +} + +export interface NullLiteral extends Span { + type: 'Literal'; + value: null; + raw: 'null' | null; +} + +export interface NumericLiteral extends Span { + type: 'Literal'; + value: number; + raw: string | null; +} + +export interface StringLiteral extends Span { + type: 'Literal'; + value: string; + raw: string | null; +} + +export interface BigIntLiteral extends Span { + type: 'Literal'; + raw: string | null; + value: null; + bigint: string; +} + +export interface RegExpLiteral extends Span { + type: 'Literal'; + raw: string | null; + value: {} | null; + regex: { pattern: string; flags: string }; +} + +export interface RegExp { + pattern: RegExpPattern; + flags: RegExpFlags; +} + +export type RegExpPattern = string | string | Pattern; + +export interface JSXElement extends Span { + type: 'JSXElement'; + openingElement: JSXOpeningElement; + closingElement: JSXClosingElement | null; + children: Array; +} + +export interface JSXOpeningElement extends Span { + type: 'JSXOpeningElement'; + selfClosing: boolean; + name: JSXElementName; + attributes: Array; + typeParameters: TSTypeParameterInstantiation | null; +} + +export interface JSXClosingElement extends Span { + type: 'JSXClosingElement'; + name: JSXElementName; +} + +export interface JSXFragment extends Span { + type: 'JSXFragment'; + openingFragment: JSXOpeningFragment; + closingFragment: JSXClosingFragment; + children: Array; +} + +export interface JSXOpeningFragment extends Span { + type: 'JSXOpeningFragment'; +} + +export interface JSXClosingFragment extends Span { + type: 'JSXClosingFragment'; +} + +export interface JSXNamespacedName extends Span { + type: 'JSXNamespacedName'; + namespace: JSXIdentifier; + property: JSXIdentifier; +} + +export interface JSXMemberExpression extends Span { + type: 'JSXMemberExpression'; + object: JSXMemberExpressionObject; + property: JSXIdentifier; +} + +export interface JSXExpressionContainer extends Span { + type: 'JSXExpressionContainer'; + expression: JSXExpression; +} + +export type JSXExpression = + | JSXEmptyExpression + | BooleanLiteral + | NullLiteral + | NumericLiteral + | BigIntLiteral + | RegExpLiteral + | StringLiteral + | TemplateLiteral + | IdentifierReference + | MetaProperty + | Super + | ArrayExpression + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | Class + | ConditionalExpression + | Function + | ImportExpression + | LogicalExpression + | NewExpression + | ObjectExpression + | ParenthesizedExpression + | SequenceExpression + | TaggedTemplateExpression + | ThisExpression + | UnaryExpression + | UpdateExpression + | YieldExpression + | PrivateInExpression + | JSXElement + | JSXFragment + | TSAsExpression + | TSSatisfiesExpression + | TSTypeAssertion + | TSNonNullExpression + | TSInstantiationExpression + | ComputedMemberExpression + | StaticMemberExpression + | PrivateFieldExpression; + +export interface JSXEmptyExpression extends Span { + type: 'JSXEmptyExpression'; +} + +export type JSXAttributeItem = JSXAttribute | JSXSpreadAttribute; + +export interface JSXAttribute extends Span { + type: 'JSXAttribute'; + name: JSXAttributeName; + value: JSXAttributeValue | null; +} + +export interface JSXSpreadAttribute extends Span { + type: 'JSXSpreadAttribute'; + argument: Expression; +} + +export type JSXAttributeName = JSXIdentifier | JSXNamespacedName; + +export type JSXAttributeValue = StringLiteral | JSXExpressionContainer | JSXElement | JSXFragment; + +export interface JSXIdentifier extends Span { + type: 'JSXIdentifier'; + name: string; +} + +export type JSXChild = JSXText | JSXElement | JSXFragment | JSXExpressionContainer | JSXSpreadChild; + +export interface JSXSpreadChild extends Span { + type: 'JSXSpreadChild'; + expression: Expression; +} + +export interface JSXText extends Span { + type: 'JSXText'; + value: string; +} + export interface TSThisParameter extends Span { type: 'TSThisParameter'; typeAnnotation: TSTypeAnnotation | null; @@ -1582,141 +1717,6 @@ export interface JSDocUnknownType extends Span { type: 'JSDocUnknownType'; } -export interface JSXElement extends Span { - type: 'JSXElement'; - openingElement: JSXOpeningElement; - closingElement: JSXClosingElement | null; - children: Array; -} - -export interface JSXOpeningElement extends Span { - type: 'JSXOpeningElement'; - selfClosing: boolean; - name: JSXElementName; - attributes: Array; - typeParameters: TSTypeParameterInstantiation | null; -} - -export interface JSXClosingElement extends Span { - type: 'JSXClosingElement'; - name: JSXElementName; -} - -export interface JSXFragment extends Span { - type: 'JSXFragment'; - openingFragment: JSXOpeningFragment; - closingFragment: JSXClosingFragment; - children: Array; -} - -export interface JSXOpeningFragment extends Span { - type: 'JSXOpeningFragment'; -} - -export interface JSXClosingFragment extends Span { - type: 'JSXClosingFragment'; -} - -export interface JSXNamespacedName extends Span { - type: 'JSXNamespacedName'; - namespace: JSXIdentifier; - property: JSXIdentifier; -} - -export interface JSXMemberExpression extends Span { - type: 'JSXMemberExpression'; - object: JSXMemberExpressionObject; - property: JSXIdentifier; -} - -export interface JSXExpressionContainer extends Span { - type: 'JSXExpressionContainer'; - expression: JSXExpression; -} - -export type JSXExpression = - | JSXEmptyExpression - | BooleanLiteral - | NullLiteral - | NumericLiteral - | BigIntLiteral - | RegExpLiteral - | StringLiteral - | TemplateLiteral - | IdentifierReference - | MetaProperty - | Super - | ArrayExpression - | ArrowFunctionExpression - | AssignmentExpression - | AwaitExpression - | BinaryExpression - | CallExpression - | ChainExpression - | Class - | ConditionalExpression - | Function - | ImportExpression - | LogicalExpression - | NewExpression - | ObjectExpression - | ParenthesizedExpression - | SequenceExpression - | TaggedTemplateExpression - | ThisExpression - | UnaryExpression - | UpdateExpression - | YieldExpression - | PrivateInExpression - | JSXElement - | JSXFragment - | TSAsExpression - | TSSatisfiesExpression - | TSTypeAssertion - | TSNonNullExpression - | TSInstantiationExpression - | ComputedMemberExpression - | StaticMemberExpression - | PrivateFieldExpression; - -export interface JSXEmptyExpression extends Span { - type: 'JSXEmptyExpression'; -} - -export type JSXAttributeItem = JSXAttribute | JSXSpreadAttribute; - -export interface JSXAttribute extends Span { - type: 'JSXAttribute'; - name: JSXAttributeName; - value: JSXAttributeValue | null; -} - -export interface JSXSpreadAttribute extends Span { - type: 'JSXSpreadAttribute'; - argument: Expression; -} - -export type JSXAttributeName = JSXIdentifier | JSXNamespacedName; - -export type JSXAttributeValue = StringLiteral | JSXExpressionContainer | JSXElement | JSXFragment; - -export interface JSXIdentifier extends Span { - type: 'JSXIdentifier'; - name: string; -} - -export type JSXChild = JSXText | JSXElement | JSXFragment | JSXExpressionContainer | JSXSpreadChild; - -export interface JSXSpreadChild extends Span { - type: 'JSXSpreadChild'; - expression: Expression; -} - -export interface JSXText extends Span { - type: 'JSXText'; - value: string; -} - export type AssignmentOperator = | '=' | '+=' diff --git a/tasks/ast_tools/src/main.rs b/tasks/ast_tools/src/main.rs index 6756670dcb669..51cdce141a77e 100644 --- a/tasks/ast_tools/src/main.rs +++ b/tasks/ast_tools/src/main.rs @@ -193,10 +193,10 @@ use schema::Schema; /// Paths to source files containing AST types static SOURCE_PATHS: &[&str] = &[ - "crates/oxc_ast/src/ast/literal.rs", "crates/oxc_ast/src/ast/js.rs", - "crates/oxc_ast/src/ast/ts.rs", + "crates/oxc_ast/src/ast/literal.rs", "crates/oxc_ast/src/ast/jsx.rs", + "crates/oxc_ast/src/ast/ts.rs", "crates/oxc_ast/src/ast/comment.rs", "crates/oxc_syntax/src/number.rs", "crates/oxc_syntax/src/operator.rs",