#![expect(
missing_docs, // TODO: document individual struct fields
clippy::enum_variant_names,
)]
use std::cell::Cell;
use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, UnstableAddress, Vec};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_span::{ContentEq, GetSpan, GetSpanMut, Span};
use oxc_str::Str;
use oxc_syntax::{node::NodeId, scope::ScopeId};
use super::{inherit_variants, js::*, literal::*};
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(
rename = "Identifier",
add_fields(decorators = EmptyArray, name = This, optional = False),
field_order(decorators, name, optional, type_annotation, span),
)]
pub struct TSThisParameter<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
#[estree(skip)]
pub this_span: Span,
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSEnumDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub id: BindingIdentifier<'a>,
pub body: TSEnumBody<'a>,
pub r#const: bool,
pub declare: bool,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSEnumBody<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub members: Vec<'a, TSEnumMember<'a>>,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(add_fields(computed = TSEnumMemberComputed))]
pub struct TSEnumMember<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub id: TSEnumMemberName<'a>,
pub initializer: Option<Expression<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSEnumMemberName<'a> {
Identifier(Box<'a, IdentifierName<'a>>) = 0,
String(Box<'a, StringLiteral<'a>>) = 1,
ComputedString(Box<'a, StringLiteral<'a>>) = 2,
ComputedTemplateString(Box<'a, TemplateLiteral<'a>>) = 3,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeAnnotation<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_annotation: TSType<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSLiteralType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub literal: TSLiteral<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSLiteral<'a> {
BooleanLiteral(Box<'a, BooleanLiteral>) = 0,
NumericLiteral(Box<'a, NumericLiteral<'a>>) = 1,
BigIntLiteral(Box<'a, BigIntLiteral<'a>>) = 2,
StringLiteral(Box<'a, StringLiteral<'a>>) = 3,
TemplateLiteral(Box<'a, TemplateLiteral<'a>>) = 4,
UnaryExpression(Box<'a, UnaryExpression<'a>>) = 5,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSType<'a> {
TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0,
TSBigIntKeyword(Box<'a, TSBigIntKeyword>) = 1,
TSBooleanKeyword(Box<'a, TSBooleanKeyword>) = 2,
TSIntrinsicKeyword(Box<'a, TSIntrinsicKeyword>) = 3,
TSNeverKeyword(Box<'a, TSNeverKeyword>) = 4,
TSNullKeyword(Box<'a, TSNullKeyword>) = 5,
TSNumberKeyword(Box<'a, TSNumberKeyword>) = 6,
TSObjectKeyword(Box<'a, TSObjectKeyword>) = 7,
TSStringKeyword(Box<'a, TSStringKeyword>) = 8,
TSSymbolKeyword(Box<'a, TSSymbolKeyword>) = 9,
TSUndefinedKeyword(Box<'a, TSUndefinedKeyword>) = 11,
TSUnknownKeyword(Box<'a, TSUnknownKeyword>) = 12,
TSVoidKeyword(Box<'a, TSVoidKeyword>) = 13,
TSArrayType(Box<'a, TSArrayType<'a>>) = 14,
TSConditionalType(Box<'a, TSConditionalType<'a>>) = 15,
TSConstructorType(Box<'a, TSConstructorType<'a>>) = 16,
TSFunctionType(Box<'a, TSFunctionType<'a>>) = 17,
TSImportType(Box<'a, TSImportType<'a>>) = 18,
TSIndexedAccessType(Box<'a, TSIndexedAccessType<'a>>) = 19,
TSInferType(Box<'a, TSInferType<'a>>) = 20,
TSIntersectionType(Box<'a, TSIntersectionType<'a>>) = 21,
TSLiteralType(Box<'a, TSLiteralType<'a>>) = 22,
TSMappedType(Box<'a, TSMappedType<'a>>) = 23,
TSNamedTupleMember(Box<'a, TSNamedTupleMember<'a>>) = 24,
TSTemplateLiteralType(Box<'a, TSTemplateLiteralType<'a>>) = 26,
TSThisType(Box<'a, TSThisType>) = 10,
TSTupleType(Box<'a, TSTupleType<'a>>) = 27,
TSTypeLiteral(Box<'a, TSTypeLiteral<'a>>) = 28,
TSTypeOperatorType(Box<'a, TSTypeOperator<'a>>) = 29,
TSTypePredicate(Box<'a, TSTypePredicate<'a>>) = 30,
TSTypeQuery(Box<'a, TSTypeQuery<'a>>) = 31,
TSTypeReference(Box<'a, TSTypeReference<'a>>) = 32,
TSUnionType(Box<'a, TSUnionType<'a>>) = 33,
TSParenthesizedType(Box<'a, TSParenthesizedType<'a>>) = 34,
JSDocNullableType(Box<'a, JSDocNullableType<'a>>) = 35,
JSDocNonNullableType(Box<'a, JSDocNonNullableType<'a>>) = 36,
JSDocUnknownType(Box<'a, JSDocUnknownType>) = 37,
}
#[macro_export]
macro_rules! match_ts_type {
($ty:ident) => {
$ty::TSAnyKeyword(_)
| $ty::TSBigIntKeyword(_)
| $ty::TSBooleanKeyword(_)
| $ty::TSIntrinsicKeyword(_)
| $ty::TSNeverKeyword(_)
| $ty::TSNullKeyword(_)
| $ty::TSNumberKeyword(_)
| $ty::TSObjectKeyword(_)
| $ty::TSStringKeyword(_)
| $ty::TSSymbolKeyword(_)
| $ty::TSThisType(_)
| $ty::TSUndefinedKeyword(_)
| $ty::TSUnknownKeyword(_)
| $ty::TSVoidKeyword(_)
| $ty::TSArrayType(_)
| $ty::TSConditionalType(_)
| $ty::TSConstructorType(_)
| $ty::TSFunctionType(_)
| $ty::TSImportType(_)
| $ty::TSIndexedAccessType(_)
| $ty::TSInferType(_)
| $ty::TSIntersectionType(_)
| $ty::TSLiteralType(_)
| $ty::TSMappedType(_)
| $ty::TSNamedTupleMember(_)
| $ty::TSTemplateLiteralType(_)
| $ty::TSTupleType(_)
| $ty::TSTypeLiteral(_)
| $ty::TSTypeOperatorType(_)
| $ty::TSTypePredicate(_)
| $ty::TSTypeQuery(_)
| $ty::TSTypeReference(_)
| $ty::TSUnionType(_)
| $ty::TSParenthesizedType(_)
| $ty::JSDocNullableType(_)
| $ty::JSDocNonNullableType(_)
| $ty::JSDocUnknownType(_)
};
}
pub use match_ts_type;
#[ast(visit)]
#[scope(flags = ScopeFlags::TsConditional)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSConditionalType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub check_type: TSType<'a>,
#[scope(enter_before)]
pub extends_type: TSType<'a>,
pub true_type: TSType<'a>,
#[scope(exit_before)]
pub false_type: TSType<'a>,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSUnionType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub types: Vec<'a, TSType<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSIntersectionType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub types: Vec<'a, TSType<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(via = TSParenthesizedTypeConverter)]
pub struct TSParenthesizedType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_annotation: TSType<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeOperator<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub operator: TSTypeOperatorOperator,
pub type_annotation: TSType<'a>,
}
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
pub enum TSTypeOperatorOperator {
Keyof = 0,
Unique = 1,
Readonly = 2,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSArrayType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub element_type: TSType<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSIndexedAccessType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub object_type: TSType<'a>,
pub index_type: TSType<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTupleType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub element_types: Vec<'a, TSTupleElement<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSNamedTupleMember<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub label: IdentifierName<'a>,
pub element_type: TSTupleElement<'a>,
pub optional: bool,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSOptionalType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_annotation: TSType<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSRestType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_annotation: TSType<'a>,
}
inherit_variants! {
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSTupleElement<'a> {
TSOptionalType(Box<'a, TSOptionalType<'a>>) = 64,
TSRestType(Box<'a, TSRestType<'a>>) = 65,
@inherit TSType
}
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSAnyKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSStringKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSBooleanKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSNumberKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSNeverKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSIntrinsicKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSUnknownKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSNullKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSUndefinedKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSVoidKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSSymbolKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSThisType {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSObjectKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSBigIntKeyword {
pub node_id: Cell<NodeId>,
pub span: Span,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeReference<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_name: TSTypeName<'a>,
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSTypeName<'a> {
IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0,
QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1,
ThisExpression(Box<'a, ThisExpression>) = 2,
}
#[macro_export]
macro_rules! match_ts_type_name {
($ty:ident) => {
$ty::IdentifierReference(_) | $ty::QualifiedName(_) | $ty::ThisExpression(_)
};
}
pub use match_ts_type_name;
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSQualifiedName<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub left: TSTypeName<'a>,
pub right: IdentifierName<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeParameterInstantiation<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub params: Vec<'a, TSType<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeParameter<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub name: BindingIdentifier<'a>,
pub constraint: Option<TSType<'a>>,
pub default: Option<TSType<'a>>,
pub r#in: bool,
pub out: bool,
pub r#const: bool,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeParameterDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub params: Vec<'a, TSTypeParameter<'a>>,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeAliasDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub id: BindingIdentifier<'a>,
#[scope(enter_before)]
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub type_annotation: TSType<'a>,
pub declare: bool,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
pub enum TSAccessibility {
Private = 0,
Protected = 1,
Public = 2,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[plural(TSClassImplementsList)]
pub struct TSClassImplements<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
#[estree(via = TSClassImplementsExpression)]
pub expression: TSTypeName<'a>,
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSInterfaceDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub id: BindingIdentifier<'a>,
#[scope(enter_before)]
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub extends: Vec<'a, TSInterfaceHeritage<'a>>,
pub body: Box<'a, TSInterfaceBody<'a>>,
pub declare: bool,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSInterfaceBody<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub body: Vec<'a, TSSignature<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(add_fields(accessibility = Null, r#static = False))]
pub struct TSPropertySignature<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub computed: bool,
pub optional: bool,
pub readonly: bool,
pub key: PropertyKey<'a>,
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSSignature<'a> {
TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0,
TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1,
TSCallSignatureDeclaration(Box<'a, TSCallSignatureDeclaration<'a>>) = 2,
TSConstructSignatureDeclaration(Box<'a, TSConstructSignatureDeclaration<'a>>) = 3,
TSMethodSignature(Box<'a, TSMethodSignature<'a>>) = 4,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(add_fields(accessibility = Null))]
pub struct TSIndexSignature<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub parameters: Vec<'a, TSIndexSignatureName<'a>>,
pub type_annotation: Box<'a, TSTypeAnnotation<'a>>,
pub readonly: bool,
pub r#static: bool,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSCallSignatureDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
#[estree(skip)]
pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
#[estree(via = TSCallSignatureDeclarationParams)]
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
pub enum TSMethodSignatureKind {
Method = 0,
Get = 1,
Set = 2,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(add_fields(accessibility = Null, readonly = False, r#static = False))]
pub struct TSMethodSignature<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub key: PropertyKey<'a>,
pub computed: bool,
pub optional: bool,
pub kind: TSMethodSignatureKind,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
#[estree(skip)]
pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
#[estree(via = TSMethodSignatureParams)]
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSConstructSignatureDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(
rename = "Identifier",
add_fields(decorators = EmptyArray, optional = False),
field_order(decorators, name, optional, type_annotation, span),
)]
pub struct TSIndexSignatureName<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
#[estree(json_safe)]
pub name: Str<'a>,
pub type_annotation: Box<'a, TSTypeAnnotation<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSInterfaceHeritage<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expression: Expression<'a>,
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypePredicate<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub parameter_name: TSTypePredicateName<'a>,
pub asserts: bool,
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub enum TSTypePredicateName<'a> {
Identifier(Box<'a, IdentifierName<'a>>) = 0,
This(TSThisType) = 1,
}
#[ast(visit)]
#[scope(
flags = ScopeFlags::TsModuleBlock,
strict_if = self.body.as_ref().is_some_and(TSModuleDeclarationBody::has_use_strict_directive),
)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(via = TSModuleDeclarationConverter, add_fields(global = False))]
pub struct TSModuleDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
#[estree(ts_type = "BindingIdentifier | StringLiteral | TSQualifiedName")]
pub id: TSModuleDeclarationName<'a>,
#[scope(enter_before)]
#[estree(ts_type = "TSModuleBlock | null")]
pub body: Option<TSModuleDeclarationBody<'a>>,
pub kind: TSModuleDeclarationKind,
pub declare: bool,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
pub enum TSModuleDeclarationKind {
Module = 0,
Namespace = 1,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[estree(no_ts_def)]
pub enum TSModuleDeclarationName<'a> {
Identifier(BindingIdentifier<'a>) = 0,
StringLiteral(StringLiteral<'a>) = 1,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
#[estree(no_ts_def)]
pub enum TSModuleDeclarationBody<'a> {
TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0,
TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1,
}
#[ast(visit)]
#[scope(flags = ScopeFlags::TsModuleBlock)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(
rename = "TSModuleDeclaration",
add_fields(id = TSGlobalDeclarationId, kind = Global, global = True),
field_order(id, body, kind, declare, global, span),
)]
pub struct TSGlobalDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
#[estree(skip)]
pub global_span: Span,
pub body: TSModuleBlock<'a>,
pub declare: bool,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSModuleBlock<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
#[estree(prepend_to = body)]
pub directives: Vec<'a, Directive<'a>>,
pub body: Vec<'a, Statement<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeLiteral<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub members: Vec<'a, TSSignature<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSInferType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_parameter: Box<'a, TSTypeParameter<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeQuery<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expr_name: TSTypeQueryExprName<'a>,
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
}
inherit_variants! {
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSTypeQueryExprName<'a> {
TSImportType(Box<'a, TSImportType<'a>>) = 3,
@inherit TSTypeName
}
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSImportType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub source: StringLiteral<'a>,
pub options: Option<Box<'a, ObjectExpression<'a>>>,
pub qualifier: Option<TSImportTypeQualifier<'a>>,
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSImportTypeQualifier<'a> {
Identifier(Box<'a, IdentifierName<'a>>) = 0,
QualifiedName(Box<'a, TSImportTypeQualifiedName<'a>>) = 1,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(rename = "TSQualifiedName")]
pub struct TSImportTypeQualifiedName<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub left: TSImportTypeQualifier<'a>,
pub right: IdentifierName<'a>,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSFunctionType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
#[estree(skip)]
pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
#[estree(via = TSFunctionTypeParams)]
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Box<'a, TSTypeAnnotation<'a>>,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSConstructorType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub r#abstract: bool,
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
pub params: Box<'a, FormalParameters<'a>>,
pub return_type: Box<'a, TSTypeAnnotation<'a>>,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast(visit)]
#[scope]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(field_order(key, constraint, name_type, type_annotation, optional, readonly, span))]
pub struct TSMappedType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub key: BindingIdentifier<'a>,
pub constraint: TSType<'a>,
pub name_type: Option<TSType<'a>>,
pub type_annotation: Option<TSType<'a>>,
#[estree(via = TSMappedTypeOptional)]
pub optional: Option<TSMappedTypeModifierOperator>,
pub readonly: Option<TSMappedTypeModifierOperator>,
pub scope_id: Cell<Option<ScopeId>>,
}
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
pub enum TSMappedTypeModifierOperator {
#[estree(via = True)]
True = 0,
#[estree(rename = "+")]
Plus = 1,
#[estree(rename = "-")]
Minus = 2,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTemplateLiteralType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub quasis: Vec<'a, TemplateElement<'a>>,
pub types: Vec<'a, TSType<'a>>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSAsExpression<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expression: Expression<'a>,
pub type_annotation: TSType<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSSatisfiesExpression<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expression: Expression<'a>,
pub type_annotation: TSType<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSTypeAssertion<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_annotation: TSType<'a>,
pub expression: Expression<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSImportEqualsDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub id: BindingIdentifier<'a>,
pub module_reference: TSModuleReference<'a>,
pub import_kind: ImportOrExportKind,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
pub enum TSModuleReference<'a> {
ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 0,
IdentifierReference(Box<'a, IdentifierReference<'a>>) = 1,
QualifiedName(Box<'a, TSQualifiedName<'a>>) = 2,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSExternalModuleReference<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expression: StringLiteral<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSNonNullExpression<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expression: Expression<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct Decorator<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expression: Expression<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSExportAssignment<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expression: Expression<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSNamespaceExportDeclaration<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub id: IdentifierName<'a>,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
pub struct TSInstantiationExpression<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub expression: Expression<'a>,
pub type_arguments: Box<'a, TSTypeParameterInstantiation<'a>>,
}
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
pub enum ImportOrExportKind {
Value = 0,
Type = 1,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(rename = "TSJSDocNullableType")]
pub struct JSDocNullableType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_annotation: TSType<'a>,
pub postfix: bool,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(rename = "TSJSDocNonNullableType")]
pub struct JSDocNonNullableType<'a> {
pub node_id: Cell<NodeId>,
pub span: Span,
pub type_annotation: TSType<'a>,
pub postfix: bool,
}
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree, UnstableAddress)]
#[estree(rename = "TSJSDocUnknownType")]
pub struct JSDocUnknownType {
pub node_id: Cell<NodeId>,
pub span: Span,
}