mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(ast): reduce #[cfg_attr] boilerplate in AST type defs (#4375)
Remove a ton of `#[cfg_attr(feature = "serialize", serde(...))]` boilerplate from AST type definitions. Before: `#[cfg_attr(feature = "serialize", serde(flatten))]` After: `#[serde(flatten)]` This is a reprise of #2669, which was later reverted, but this time doing it using our existing zero-cost `#[ast]` dummy macro attr, so no compile time penalty this time around. This makes no difference to either runtime or compile time behavior, purely removes the `cfg_attr` boilerplate and makes the code easier to read.
This commit is contained in:
parent
d345b84a72
commit
abfccbd941
5 changed files with 455 additions and 470 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -23,9 +23,9 @@ use super::{inherit_variants, js::*, literal::*, ts::*};
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct JSXElement<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub opening_element: Box<'a, JSXOpeningElement<'a>>,
|
||||
pub closing_element: Option<Box<'a, JSXClosingElement<'a>>>,
|
||||
|
|
@ -36,9 +36,9 @@ pub struct JSXElement<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct JSXOpeningElement<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub self_closing: bool,
|
||||
pub name: JSXElementName<'a>,
|
||||
|
|
@ -50,9 +50,9 @@ pub struct JSXOpeningElement<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXClosingElement<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub name: JSXElementName<'a>,
|
||||
}
|
||||
|
|
@ -61,9 +61,9 @@ pub struct JSXClosingElement<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct JSXFragment<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub opening_fragment: JSXOpeningFragment,
|
||||
pub closing_fragment: JSXClosingFragment,
|
||||
|
|
@ -73,18 +73,18 @@ pub struct JSXFragment<'a> {
|
|||
#[ast]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXOpeningFragment {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXClosingFragment {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ pub struct JSXClosingFragment {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum JSXElementName<'a> {
|
||||
/// `<Apple />`
|
||||
Identifier(Box<'a, JSXIdentifier<'a>>),
|
||||
|
|
@ -106,9 +106,9 @@ pub enum JSXElementName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXNamespacedName<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub namespace: JSXIdentifier<'a>,
|
||||
pub property: JSXIdentifier<'a>,
|
||||
|
|
@ -118,9 +118,9 @@ pub struct JSXNamespacedName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXMemberExpression<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub object: JSXMemberExpressionObject<'a>,
|
||||
pub property: JSXIdentifier<'a>,
|
||||
|
|
@ -129,7 +129,7 @@ pub struct JSXMemberExpression<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum JSXMemberExpressionObject<'a> {
|
||||
Identifier(Box<'a, JSXIdentifier<'a>>),
|
||||
MemberExpression(Box<'a, JSXMemberExpression<'a>>),
|
||||
|
|
@ -138,9 +138,9 @@ pub enum JSXMemberExpressionObject<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXExpressionContainer<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: JSXExpression<'a>,
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ inherit_variants! {
|
|||
#[repr(C, u8)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum JSXExpression<'a> {
|
||||
EmptyExpression(JSXEmptyExpression) = 64,
|
||||
// `Expression` variants added here by `inherit_variants!` macro
|
||||
|
|
@ -166,9 +166,9 @@ pub enum JSXExpression<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXEmptyExpression {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ pub struct JSXEmptyExpression {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum JSXAttributeItem<'a> {
|
||||
Attribute(Box<'a, JSXAttribute<'a>>),
|
||||
SpreadAttribute(Box<'a, JSXSpreadAttribute<'a>>),
|
||||
|
|
@ -188,9 +188,9 @@ pub enum JSXAttributeItem<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXAttribute<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub name: JSXAttributeName<'a>,
|
||||
pub value: Option<JSXAttributeValue<'a>>,
|
||||
|
|
@ -200,9 +200,9 @@ pub struct JSXAttribute<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXSpreadAttribute<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub argument: Expression<'a>,
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ pub struct JSXSpreadAttribute<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum JSXAttributeName<'a> {
|
||||
Identifier(Box<'a, JSXIdentifier<'a>>),
|
||||
NamespacedName(Box<'a, JSXNamespacedName<'a>>),
|
||||
|
|
@ -221,7 +221,7 @@ pub enum JSXAttributeName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum JSXAttributeValue<'a> {
|
||||
StringLiteral(Box<'a, StringLiteral<'a>>),
|
||||
ExpressionContainer(Box<'a, JSXExpressionContainer<'a>>),
|
||||
|
|
@ -232,9 +232,9 @@ pub enum JSXAttributeValue<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXIdentifier<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub name: Atom<'a>,
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@ pub struct JSXIdentifier<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum JSXChild<'a> {
|
||||
Text(Box<'a, JSXText<'a>>),
|
||||
Element(Box<'a, JSXElement<'a>>),
|
||||
|
|
@ -257,9 +257,9 @@ pub enum JSXChild<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXSpreadChild<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
}
|
||||
|
|
@ -267,9 +267,9 @@ pub struct JSXSpreadChild<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct JSXText<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub value: Atom<'a>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ use tsify::Tsify;
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct BooleanLiteral {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub value: bool,
|
||||
}
|
||||
|
|
@ -31,43 +31,43 @@ pub struct BooleanLiteral {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct NullLiteral {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct NumericLiteral<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub value: f64,
|
||||
pub raw: &'a str,
|
||||
#[cfg_attr(feature = "serialize", serde(skip))]
|
||||
#[serde(skip)]
|
||||
pub base: NumberBase,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct BigIntLiteral<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub raw: Atom<'a>,
|
||||
#[cfg_attr(feature = "serialize", serde(skip))]
|
||||
#[serde(skip)]
|
||||
pub base: BigintBase,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct RegExpLiteral<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
// valid regex is printed as {}
|
||||
// invalid regex is printed as null, which we can't implement yet
|
||||
|
|
@ -91,9 +91,9 @@ pub struct EmptyObject;
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Clone, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct StringLiteral<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub value: Atom<'a>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ export interface TSIndexSignatureName extends Span {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSThisParameter<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub this: IdentifierName<'a>,
|
||||
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
||||
|
|
@ -51,9 +51,9 @@ pub struct TSThisParameter<'a> {
|
|||
#[scope]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSEnumDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub id: BindingIdentifier<'a>,
|
||||
#[scope(enter_before)]
|
||||
|
|
@ -66,9 +66,9 @@ pub struct TSEnumDeclaration<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSEnumMember<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub id: TSEnumMemberName<'a>,
|
||||
pub initializer: Option<Expression<'a>>,
|
||||
|
|
@ -84,7 +84,7 @@ inherit_variants! {
|
|||
#[repr(C, u8)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum TSEnumMemberName<'a> {
|
||||
StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64,
|
||||
StaticStringLiteral(Box<'a, StringLiteral<'a>>) = 65,
|
||||
|
|
@ -99,9 +99,9 @@ pub enum TSEnumMemberName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeAnnotation<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_annotation: TSType<'a>,
|
||||
}
|
||||
|
|
@ -109,9 +109,9 @@ pub struct TSTypeAnnotation<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSLiteralType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub literal: TSLiteral<'a>,
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ pub struct TSLiteralType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))]
|
||||
#[serde(untagged, rename_all = "camelCase")]
|
||||
pub enum TSLiteral<'a> {
|
||||
BooleanLiteral(Box<'a, BooleanLiteral>),
|
||||
NullLiteral(Box<'a, NullLiteral>),
|
||||
|
|
@ -135,7 +135,7 @@ pub enum TSLiteral<'a> {
|
|||
#[repr(C, u8)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))]
|
||||
#[serde(untagged, rename_all = "camelCase")]
|
||||
pub enum TSType<'a> {
|
||||
// Keyword
|
||||
TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0,
|
||||
|
|
@ -233,9 +233,9 @@ pub use match_ts_type;
|
|||
#[scope]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSConditionalType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub check_type: TSType<'a>,
|
||||
pub extends_type: TSType<'a>,
|
||||
|
|
@ -250,9 +250,9 @@ pub struct TSConditionalType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSUnionType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub types: Vec<'a, TSType<'a>>,
|
||||
}
|
||||
|
|
@ -263,9 +263,9 @@ pub struct TSUnionType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSIntersectionType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub types: Vec<'a, TSType<'a>>,
|
||||
}
|
||||
|
|
@ -273,9 +273,9 @@ pub struct TSIntersectionType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSParenthesizedType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_annotation: TSType<'a>,
|
||||
}
|
||||
|
|
@ -286,9 +286,9 @@ pub struct TSParenthesizedType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeOperator<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub operator: TSTypeOperatorOperator,
|
||||
pub type_annotation: TSType<'a>,
|
||||
|
|
@ -297,7 +297,7 @@ pub struct TSTypeOperator<'a> {
|
|||
#[ast]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(rename_all = "lowercase"))]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TSTypeOperatorOperator {
|
||||
Keyof,
|
||||
Unique,
|
||||
|
|
@ -310,9 +310,9 @@ pub enum TSTypeOperatorOperator {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSArrayType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub element_type: TSType<'a>,
|
||||
}
|
||||
|
|
@ -323,9 +323,9 @@ pub struct TSArrayType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSIndexedAccessType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub object_type: TSType<'a>,
|
||||
pub index_type: TSType<'a>,
|
||||
|
|
@ -337,9 +337,9 @@ pub struct TSIndexedAccessType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTupleType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub element_types: Vec<'a, TSTupleElement<'a>>,
|
||||
}
|
||||
|
|
@ -347,9 +347,9 @@ pub struct TSTupleType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSNamedTupleMember<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub element_type: TSTupleElement<'a>,
|
||||
pub label: IdentifierName<'a>,
|
||||
|
|
@ -359,9 +359,9 @@ pub struct TSNamedTupleMember<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSOptionalType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_annotation: TSType<'a>,
|
||||
}
|
||||
|
|
@ -369,9 +369,9 @@ pub struct TSOptionalType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSRestType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_annotation: TSType<'a>,
|
||||
}
|
||||
|
|
@ -386,7 +386,7 @@ inherit_variants! {
|
|||
#[repr(C, u8)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))]
|
||||
#[serde(untagged, rename_all = "camelCase")]
|
||||
pub enum TSTupleElement<'a> {
|
||||
// Discriminants start at 64, so that `TSTupleElement::is_ts_type` is a single
|
||||
// bitwise AND operation on the discriminant (`discriminant & 63 != 0`).
|
||||
|
|
@ -400,45 +400,45 @@ pub enum TSTupleElement<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSAnyKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSStringKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSBooleanKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSNumberKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSNeverKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -446,81 +446,81 @@ pub struct TSNeverKeyword {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSIntrinsicKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSUnknownKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSNullKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSUndefinedKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSVoidKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSSymbolKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSThisType {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSObjectKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
#[serde(tag = "type")]
|
||||
pub struct TSBigIntKeyword {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -530,9 +530,9 @@ pub struct TSBigIntKeyword {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeReference<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_name: TSTypeName<'a>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
|
||||
|
|
@ -545,7 +545,7 @@ pub struct TSTypeReference<'a> {
|
|||
#[repr(C, u8)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum TSTypeName<'a> {
|
||||
IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0,
|
||||
QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1,
|
||||
|
|
@ -563,9 +563,9 @@ pub use match_ts_type_name;
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSQualifiedName<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub left: TSTypeName<'a>,
|
||||
pub right: IdentifierName<'a>,
|
||||
|
|
@ -574,9 +574,9 @@ pub struct TSQualifiedName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeParameterInstantiation<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub params: Vec<'a, TSType<'a>>,
|
||||
}
|
||||
|
|
@ -584,9 +584,9 @@ pub struct TSTypeParameterInstantiation<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeParameter<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub name: BindingIdentifier<'a>,
|
||||
pub constraint: Option<TSType<'a>>,
|
||||
|
|
@ -599,9 +599,9 @@ pub struct TSTypeParameter<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeParameterDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub params: Vec<'a, TSTypeParameter<'a>>,
|
||||
}
|
||||
|
|
@ -610,9 +610,9 @@ pub struct TSTypeParameterDeclaration<'a> {
|
|||
#[scope]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeAliasDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub id: BindingIdentifier<'a>,
|
||||
#[scope(enter_before)]
|
||||
|
|
@ -625,7 +625,7 @@ pub struct TSTypeAliasDeclaration<'a> {
|
|||
#[ast]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(rename_all = "lowercase"))]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TSAccessibility {
|
||||
Private,
|
||||
Protected,
|
||||
|
|
@ -635,9 +635,9 @@ pub enum TSAccessibility {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSClassImplements<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: TSTypeName<'a>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
|
||||
|
|
@ -650,9 +650,9 @@ pub struct TSClassImplements<'a> {
|
|||
#[scope]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSInterfaceDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub id: BindingIdentifier<'a>,
|
||||
#[scope(enter_before)]
|
||||
|
|
@ -666,9 +666,9 @@ pub struct TSInterfaceDeclaration<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSInterfaceBody<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub body: Vec<'a, TSSignature<'a>>,
|
||||
}
|
||||
|
|
@ -676,9 +676,9 @@ pub struct TSInterfaceBody<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSPropertySignature<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub computed: bool,
|
||||
pub optional: bool,
|
||||
|
|
@ -690,7 +690,7 @@ pub struct TSPropertySignature<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))]
|
||||
#[serde(untagged, rename_all = "camelCase")]
|
||||
pub enum TSSignature<'a> {
|
||||
TSIndexSignature(Box<'a, TSIndexSignature<'a>>),
|
||||
TSPropertySignature(Box<'a, TSPropertySignature<'a>>),
|
||||
|
|
@ -702,9 +702,9 @@ pub enum TSSignature<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSIndexSignature<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub parameters: Vec<'a, TSIndexSignatureName<'a>>,
|
||||
pub type_annotation: Box<'a, TSTypeAnnotation<'a>>,
|
||||
|
|
@ -714,9 +714,9 @@ pub struct TSIndexSignature<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSCallSignatureDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub this_param: Option<TSThisParameter<'a>>,
|
||||
pub params: Box<'a, FormalParameters<'a>>,
|
||||
|
|
@ -727,7 +727,7 @@ pub struct TSCallSignatureDeclaration<'a> {
|
|||
#[ast]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(rename_all = "lowercase"))]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TSMethodSignatureKind {
|
||||
Method,
|
||||
Get,
|
||||
|
|
@ -738,9 +738,9 @@ pub enum TSMethodSignatureKind {
|
|||
#[scope]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSMethodSignature<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub key: PropertyKey<'a>,
|
||||
pub computed: bool,
|
||||
|
|
@ -757,9 +757,9 @@ pub struct TSMethodSignature<'a> {
|
|||
#[scope]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSConstructSignatureDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub params: Box<'a, FormalParameters<'a>>,
|
||||
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
||||
|
|
@ -770,12 +770,9 @@ pub struct TSConstructSignatureDeclaration<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "serialize",
|
||||
serde(tag = "type", rename = "Identifier", rename_all = "camelCase")
|
||||
)]
|
||||
#[serde(tag = "type", rename = "Identifier", rename_all = "camelCase")]
|
||||
pub struct TSIndexSignatureName<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub name: Atom<'a>,
|
||||
pub type_annotation: Box<'a, TSTypeAnnotation<'a>>,
|
||||
|
|
@ -784,9 +781,9 @@ pub struct TSIndexSignatureName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSInterfaceHeritage<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
|
||||
|
|
@ -795,9 +792,9 @@ pub struct TSInterfaceHeritage<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypePredicate<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub parameter_name: TSTypePredicateName<'a>,
|
||||
pub asserts: bool,
|
||||
|
|
@ -807,7 +804,7 @@ pub struct TSTypePredicate<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))]
|
||||
#[serde(untagged, rename_all = "camelCase")]
|
||||
pub enum TSTypePredicateName<'a> {
|
||||
Identifier(Box<'a, IdentifierName<'a>>),
|
||||
This(TSThisType),
|
||||
|
|
@ -820,9 +817,9 @@ pub enum TSTypePredicateName<'a> {
|
|||
)]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSModuleDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub id: TSModuleDeclarationName<'a>,
|
||||
#[scope(enter_before)]
|
||||
|
|
@ -844,7 +841,7 @@ pub struct TSModuleDeclaration<'a> {
|
|||
#[ast]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(rename_all = "lowercase"))]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum TSModuleDeclarationKind {
|
||||
Global,
|
||||
Module,
|
||||
|
|
@ -860,7 +857,7 @@ impl TSModuleDeclarationKind {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum TSModuleDeclarationName<'a> {
|
||||
Identifier(IdentifierName<'a>),
|
||||
StringLiteral(StringLiteral<'a>),
|
||||
|
|
@ -869,7 +866,7 @@ pub enum TSModuleDeclarationName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum TSModuleDeclarationBody<'a> {
|
||||
TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>),
|
||||
TSModuleBlock(Box<'a, TSModuleBlock<'a>>),
|
||||
|
|
@ -879,11 +876,11 @@ pub enum TSModuleDeclarationBody<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSModuleBlock<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
#[cfg_attr(feature = "serialize", serde(skip))]
|
||||
#[serde(skip)]
|
||||
pub directives: Vec<'a, Directive<'a>>,
|
||||
pub body: Vec<'a, Statement<'a>>,
|
||||
}
|
||||
|
|
@ -891,9 +888,9 @@ pub struct TSModuleBlock<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeLiteral<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub members: Vec<'a, TSSignature<'a>>,
|
||||
}
|
||||
|
|
@ -901,9 +898,9 @@ pub struct TSTypeLiteral<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSInferType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_parameter: Box<'a, TSTypeParameter<'a>>,
|
||||
}
|
||||
|
|
@ -911,9 +908,9 @@ pub struct TSInferType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeQuery<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expr_name: TSTypeQueryExprName<'a>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
|
||||
|
|
@ -929,7 +926,7 @@ inherit_variants! {
|
|||
#[repr(C, u8)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum TSTypeQueryExprName<'a> {
|
||||
TSImportType(Box<'a, TSImportType<'a>>) = 2,
|
||||
// `TSTypeName` variants added here by `inherit_variants!` macro
|
||||
|
|
@ -940,9 +937,9 @@ pub enum TSTypeQueryExprName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSImportType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub is_type_of: bool, // `typeof import("foo")`
|
||||
pub parameter: TSType<'a>,
|
||||
|
|
@ -954,9 +951,9 @@ pub struct TSImportType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSImportAttributes<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub elements: Vec<'a, TSImportAttribute<'a>>,
|
||||
}
|
||||
|
|
@ -964,9 +961,9 @@ pub struct TSImportAttributes<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSImportAttribute<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub name: TSImportAttributeName<'a>,
|
||||
pub value: Expression<'a>,
|
||||
|
|
@ -975,7 +972,7 @@ pub struct TSImportAttribute<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged))]
|
||||
#[serde(untagged)]
|
||||
pub enum TSImportAttributeName<'a> {
|
||||
Identifier(IdentifierName<'a>),
|
||||
StringLiteral(StringLiteral<'a>),
|
||||
|
|
@ -984,9 +981,9 @@ pub enum TSImportAttributeName<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSFunctionType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub this_param: Option<TSThisParameter<'a>>,
|
||||
pub params: Box<'a, FormalParameters<'a>>,
|
||||
|
|
@ -997,9 +994,9 @@ pub struct TSFunctionType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSConstructorType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub r#abstract: bool,
|
||||
pub params: Box<'a, FormalParameters<'a>>,
|
||||
|
|
@ -1011,9 +1008,9 @@ pub struct TSConstructorType<'a> {
|
|||
#[scope]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSMappedType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_parameter: Box<'a, TSTypeParameter<'a>>,
|
||||
pub name_type: Option<TSType<'a>>,
|
||||
|
|
@ -1026,12 +1023,12 @@ pub struct TSMappedType<'a> {
|
|||
#[ast]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TSMappedTypeModifierOperator {
|
||||
True,
|
||||
#[cfg_attr(feature = "serialize", serde(rename = "+"))]
|
||||
#[serde(rename = "+")]
|
||||
Plus,
|
||||
#[cfg_attr(feature = "serialize", serde(rename = "-"))]
|
||||
#[serde(rename = "-")]
|
||||
Minus,
|
||||
None,
|
||||
}
|
||||
|
|
@ -1039,9 +1036,9 @@ pub enum TSMappedTypeModifierOperator {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTemplateLiteralType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub quasis: Vec<'a, TemplateElement<'a>>,
|
||||
pub types: Vec<'a, TSType<'a>>,
|
||||
|
|
@ -1050,9 +1047,9 @@ pub struct TSTemplateLiteralType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSAsExpression<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
pub type_annotation: TSType<'a>,
|
||||
|
|
@ -1061,9 +1058,9 @@ pub struct TSAsExpression<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSSatisfiesExpression<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
pub type_annotation: TSType<'a>,
|
||||
|
|
@ -1072,9 +1069,9 @@ pub struct TSSatisfiesExpression<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSTypeAssertion<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
pub type_annotation: TSType<'a>,
|
||||
|
|
@ -1083,9 +1080,9 @@ pub struct TSTypeAssertion<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSImportEqualsDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub id: BindingIdentifier<'a>,
|
||||
pub module_reference: TSModuleReference<'a>,
|
||||
|
|
@ -1102,7 +1099,7 @@ inherit_variants! {
|
|||
#[repr(C, u8)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(untagged, rename_all = "camelCase"))]
|
||||
#[serde(untagged, rename_all = "camelCase")]
|
||||
pub enum TSModuleReference<'a> {
|
||||
ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 2,
|
||||
// `TSTypeName` variants added here by `inherit_variants!` macro
|
||||
|
|
@ -1113,9 +1110,9 @@ pub enum TSModuleReference<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSExternalModuleReference<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: StringLiteral<'a>,
|
||||
}
|
||||
|
|
@ -1123,9 +1120,9 @@ pub struct TSExternalModuleReference<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSNonNullExpression<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
}
|
||||
|
|
@ -1133,9 +1130,9 @@ pub struct TSNonNullExpression<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct Decorator<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
}
|
||||
|
|
@ -1146,9 +1143,9 @@ pub struct Decorator<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSExportAssignment<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
}
|
||||
|
|
@ -1159,9 +1156,9 @@ pub struct TSExportAssignment<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSNamespaceExportDeclaration<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub id: IdentifierName<'a>,
|
||||
}
|
||||
|
|
@ -1169,9 +1166,9 @@ pub struct TSNamespaceExportDeclaration<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct TSInstantiationExpression<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub expression: Expression<'a>,
|
||||
pub type_parameters: Box<'a, TSTypeParameterInstantiation<'a>>,
|
||||
|
|
@ -1180,7 +1177,7 @@ pub struct TSInstantiationExpression<'a> {
|
|||
#[ast]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum ImportOrExportKind {
|
||||
Value,
|
||||
Type,
|
||||
|
|
@ -1192,9 +1189,9 @@ pub enum ImportOrExportKind {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct JSDocNullableType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_annotation: TSType<'a>,
|
||||
pub postfix: bool,
|
||||
|
|
@ -1204,9 +1201,9 @@ pub struct JSDocNullableType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct JSDocNonNullableType<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
pub type_annotation: TSType<'a>,
|
||||
pub postfix: bool,
|
||||
|
|
@ -1215,8 +1212,8 @@ pub struct JSDocNonNullableType<'a> {
|
|||
#[ast(visit)]
|
||||
#[derive(Debug, Hash)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub struct JSDocUnknownType {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
#[serde(flatten)]
|
||||
pub span: Span,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ use std::str::FromStr;
|
|||
|
||||
/// Attach to AST node type (struct or enum), to signal to codegen to create visitor for this type.
|
||||
///
|
||||
/// Macro does not generate any code - it's purely a means to communicate information to the codegen.
|
||||
/// Macro's role is not to generate code - it's purely a means to communicate information to the codegen.
|
||||
///
|
||||
/// Only thing macro does is add `#[derive(Ast)]` to the item.
|
||||
/// Deriving `Ast` does nothing, but supports the `#[scope]` attr on struct fields.
|
||||
/// Deriving `Ast` does nothing, but supports `#[scope]`, `#[visit]`, and other attrs on struct fields.
|
||||
/// These "helper" attributes are also signals to the codegen, and do nothing in themselves.
|
||||
///
|
||||
/// This is a workaround for Rust not supporting helper attributes for `proc_macro_attribute` macros,
|
||||
/// so we need to use a derive macro to get that support.
|
||||
///
|
||||
|
|
@ -21,8 +23,9 @@ pub fn ast(_args: TokenStream, input: TokenStream) -> TokenStream {
|
|||
|
||||
/// Dummy derive macro for a non-existent trait `Ast`.
|
||||
///
|
||||
/// Does not generate any code, only purpose is to allow using `#[scope]` attr in the type def.
|
||||
#[proc_macro_derive(Ast, attributes(span, scope, visit, visit_as, visit_args))]
|
||||
/// Does not generate any code.
|
||||
/// Only purpose is to allow using `#[scope]`, `#[visit]`, and other attrs in the AST node type defs.
|
||||
#[proc_macro_derive(Ast, attributes(span, scope, visit, visit_as, visit_args, serde, tsify))]
|
||||
pub fn ast_derive(_item: TokenStream) -> TokenStream {
|
||||
TokenStream::new()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue