1#![expect(
14 missing_docs, clippy::enum_variant_names,
16 clippy::struct_field_names,
17)]
18
19use std::cell::Cell;
24
25use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, Vec};
26use oxc_ast_macros::ast;
27use oxc_estree::ESTree;
28use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, SourceType, Span};
29use oxc_syntax::{
30 operator::{
31 AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator,
32 },
33 reference::ReferenceId,
34 scope::ScopeId,
35 symbol::SymbolId,
36};
37
38use super::{macros::inherit_variants, *};
39
40#[ast(visit)]
43#[scope(
44 flags = ScopeFlags::Top,
45 strict_if = self.source_type.is_strict() || self.has_use_strict_directive(),
46)]
47#[derive(Debug)]
48#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
49#[estree(field_order(body, source_type, hashbang, span), via = ProgramConverter)]
50pub struct Program<'a> {
51 pub span: Span,
52 pub source_type: SourceType,
53 #[content_eq(skip)]
54 #[estree(skip)]
55 pub source_text: &'a str,
56 #[content_eq(skip)]
58 #[estree(skip)]
59 pub comments: Vec<'a, Comment>,
60 pub hashbang: Option<Hashbang<'a>>,
61 #[estree(prepend_to = body)]
62 pub directives: Vec<'a, Directive<'a>>,
63 pub body: Vec<'a, Statement<'a>>,
64 pub scope_id: Cell<Option<ScopeId>>,
65}
66
67inherit_variants! {
68#[ast(visit)]
74#[derive(Debug)]
75#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
76pub enum Expression<'a> {
77 BooleanLiteral(Box<'a, BooleanLiteral>) = 0,
79 NullLiteral(Box<'a, NullLiteral>) = 1,
81 NumericLiteral(Box<'a, NumericLiteral<'a>>) = 2,
83 BigIntLiteral(Box<'a, BigIntLiteral<'a>>) = 3,
85 RegExpLiteral(Box<'a, RegExpLiteral<'a>>) = 4,
87 StringLiteral(Box<'a, StringLiteral<'a>>) = 5,
89 TemplateLiteral(Box<'a, TemplateLiteral<'a>>) = 6,
91
92 Identifier(Box<'a, IdentifierReference<'a>>) = 7,
94
95 MetaProperty(Box<'a, MetaProperty<'a>>) = 8,
97 Super(Box<'a, Super>) = 9,
99
100 ArrayExpression(Box<'a, ArrayExpression<'a>>) = 10,
102 ArrowFunctionExpression(Box<'a, ArrowFunctionExpression<'a>>) = 11,
104 AssignmentExpression(Box<'a, AssignmentExpression<'a>>) = 12,
106 AwaitExpression(Box<'a, AwaitExpression<'a>>) = 13,
108 BinaryExpression(Box<'a, BinaryExpression<'a>>) = 14,
110 CallExpression(Box<'a, CallExpression<'a>>) = 15,
112 ChainExpression(Box<'a, ChainExpression<'a>>) = 16,
114 ClassExpression(Box<'a, Class<'a>>) = 17,
116 ConditionalExpression(Box<'a, ConditionalExpression<'a>>) = 18,
118 #[visit(args(flags = ScopeFlags::Function))]
120 FunctionExpression(Box<'a, Function<'a>>) = 19,
121 ImportExpression(Box<'a, ImportExpression<'a>>) = 20,
123 LogicalExpression(Box<'a, LogicalExpression<'a>>) = 21,
125 NewExpression(Box<'a, NewExpression<'a>>) = 22,
127 ObjectExpression(Box<'a, ObjectExpression<'a>>) = 23,
129 ParenthesizedExpression(Box<'a, ParenthesizedExpression<'a>>) = 24,
131 SequenceExpression(Box<'a, SequenceExpression<'a>>) = 25,
133 TaggedTemplateExpression(Box<'a, TaggedTemplateExpression<'a>>) = 26,
135 ThisExpression(Box<'a, ThisExpression>) = 27,
137 UnaryExpression(Box<'a, UnaryExpression<'a>>) = 28,
139 UpdateExpression(Box<'a, UpdateExpression<'a>>) = 29,
141 YieldExpression(Box<'a, YieldExpression<'a>>) = 30,
143 PrivateInExpression(Box<'a, PrivateInExpression<'a>>) = 31,
145
146 JSXElement(Box<'a, JSXElement<'a>>) = 32,
148 JSXFragment(Box<'a, JSXFragment<'a>>) = 33,
150
151 TSAsExpression(Box<'a, TSAsExpression<'a>>) = 34,
153 TSSatisfiesExpression(Box<'a, TSSatisfiesExpression<'a>>) = 35,
155 TSTypeAssertion(Box<'a, TSTypeAssertion<'a>>) = 36,
157 TSNonNullExpression(Box<'a, TSNonNullExpression<'a>>) = 37,
159 TSInstantiationExpression(Box<'a, TSInstantiationExpression<'a>>) = 38,
161 V8IntrinsicExpression(Box<'a, V8IntrinsicExpression<'a>>) = 39,
163
164 @inherit MemberExpression
166}
167}
168
169#[macro_export]
172macro_rules! match_expression {
173 ($ty:ident) => {
174 $ty::BooleanLiteral(_)
175 | $ty::NullLiteral(_)
176 | $ty::NumericLiteral(_)
177 | $ty::BigIntLiteral(_)
178 | $ty::RegExpLiteral(_)
179 | $ty::StringLiteral(_)
180 | $ty::TemplateLiteral(_)
181 | $ty::Identifier(_)
182 | $ty::MetaProperty(_)
183 | $ty::Super(_)
184 | $ty::ArrayExpression(_)
185 | $ty::ArrowFunctionExpression(_)
186 | $ty::AssignmentExpression(_)
187 | $ty::AwaitExpression(_)
188 | $ty::BinaryExpression(_)
189 | $ty::CallExpression(_)
190 | $ty::ChainExpression(_)
191 | $ty::ClassExpression(_)
192 | $ty::ConditionalExpression(_)
193 | $ty::FunctionExpression(_)
194 | $ty::ImportExpression(_)
195 | $ty::LogicalExpression(_)
196 | $ty::NewExpression(_)
197 | $ty::ObjectExpression(_)
198 | $ty::ParenthesizedExpression(_)
199 | $ty::SequenceExpression(_)
200 | $ty::TaggedTemplateExpression(_)
201 | $ty::ThisExpression(_)
202 | $ty::UnaryExpression(_)
203 | $ty::UpdateExpression(_)
204 | $ty::YieldExpression(_)
205 | $ty::PrivateInExpression(_)
206 | $ty::JSXElement(_)
207 | $ty::JSXFragment(_)
208 | $ty::TSAsExpression(_)
209 | $ty::TSSatisfiesExpression(_)
210 | $ty::TSTypeAssertion(_)
211 | $ty::TSNonNullExpression(_)
212 | $ty::TSInstantiationExpression(_)
213 | $ty::ComputedMemberExpression(_)
214 | $ty::StaticMemberExpression(_)
215 | $ty::PrivateFieldExpression(_)
216 | $ty::V8IntrinsicExpression(_)
217 };
218}
219pub use match_expression;
220
221#[ast(visit)]
227#[derive(Debug, Clone)]
228#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
229#[estree(
230 rename = "Identifier",
231 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
232 field_order(decorators, name, optional, typeAnnotation, span),
233)]
234pub struct IdentifierName<'a> {
235 pub span: Span,
236 #[estree(json_safe)]
237 pub name: Atom<'a>,
238}
239
240#[ast(visit)]
246#[derive(Debug, Clone)]
247#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
248#[estree(
249 rename = "Identifier",
250 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
251 field_order(decorators, name, optional, typeAnnotation, span),
252)]
253pub struct IdentifierReference<'a> {
254 pub span: Span,
255 #[estree(json_safe)]
257 pub name: Atom<'a>,
258 pub reference_id: Cell<Option<ReferenceId>>,
264}
265
266#[ast(visit)]
275#[derive(Debug, Clone)]
276#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
277#[estree(
278 rename = "Identifier",
279 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
280 field_order(decorators, name, optional, typeAnnotation, span),
281)]
282pub struct BindingIdentifier<'a> {
283 pub span: Span,
284 #[estree(json_safe)]
286 pub name: Atom<'a>,
287 pub symbol_id: Cell<Option<SymbolId>>,
294}
295
296#[ast(visit)]
302#[derive(Debug, Clone)]
303#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
304#[estree(
305 rename = "Identifier",
306 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
307 field_order(decorators, name, optional, typeAnnotation, span),
308)]
309pub struct LabelIdentifier<'a> {
310 pub span: Span,
311 #[estree(json_safe)]
312 pub name: Atom<'a>,
313}
314
315#[ast(visit)]
319#[derive(Debug)]
320#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
321pub struct ThisExpression {
322 pub span: Span,
323}
324
325#[ast(visit)]
329#[derive(Debug)]
330#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
331pub struct ArrayExpression<'a> {
332 pub span: Span,
333 pub elements: Vec<'a, ArrayExpressionElement<'a>>,
334}
335
336inherit_variants! {
337#[ast(visit)]
343#[derive(Debug)]
344#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
345pub enum ArrayExpressionElement<'a> {
346 SpreadElement(Box<'a, SpreadElement<'a>>) = 64,
348 Elision(Elision) = 65,
353 @inherit Expression
355}
356}
357
358#[ast(visit)]
362#[derive(Debug, Clone)]
363#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
364#[estree(via = Null)]
365pub struct Elision {
366 pub span: Span,
367}
368
369#[ast(visit)]
374#[derive(Debug)]
375#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
376pub struct ObjectExpression<'a> {
377 pub span: Span,
378 pub properties: Vec<'a, ObjectPropertyKind<'a>>,
380}
381
382#[ast(visit)]
384#[derive(Debug)]
385#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
386pub enum ObjectPropertyKind<'a> {
387 ObjectProperty(Box<'a, ObjectProperty<'a>>) = 0,
389 SpreadProperty(Box<'a, SpreadElement<'a>>) = 1,
391}
392
393#[ast(visit)]
397#[derive(Debug)]
398#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
399#[estree(rename = "Property", add_fields(optional = TsFalse))]
400pub struct ObjectProperty<'a> {
401 pub span: Span,
402 pub kind: PropertyKind,
403 pub key: PropertyKey<'a>,
404 pub value: Expression<'a>,
405 pub method: bool,
406 pub shorthand: bool,
407 pub computed: bool,
408}
409
410inherit_variants! {
411#[ast(visit)]
417#[derive(Debug)]
418#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
419pub enum PropertyKey<'a> {
420 StaticIdentifier(Box<'a, IdentifierName<'a>>) = 64,
422 PrivateIdentifier(Box<'a, PrivateIdentifier<'a>>) = 65,
424 @inherit Expression
426}
427}
428
429#[ast]
431#[derive(Debug, Clone, Copy, PartialEq, Eq)]
432#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
433pub enum PropertyKind {
434 Init = 0,
436 Get = 1,
438 Set = 2,
440}
441
442#[ast(visit)]
446#[derive(Debug)]
447#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
448pub struct TemplateLiteral<'a> {
449 pub span: Span,
450 pub quasis: Vec<'a, TemplateElement<'a>>,
451 pub expressions: Vec<'a, Expression<'a>>,
452}
453
454#[ast(visit)]
461#[derive(Debug)]
462#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
463pub struct TaggedTemplateExpression<'a> {
464 pub span: Span,
465 pub tag: Expression<'a>,
466 #[ts]
467 pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
468 pub quasi: TemplateLiteral<'a>,
469}
470
471#[ast(visit)]
475#[derive(Debug, Clone)]
476#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
477#[estree(via = TemplateElementConverter)]
478pub struct TemplateElement<'a> {
479 pub span: Span,
480 pub value: TemplateElementValue<'a>,
481 pub tail: bool,
482 #[builder(default)]
488 #[estree(skip)]
489 pub lone_surrogates: bool,
490}
491
492#[ast]
494#[derive(Debug, Clone)]
495#[generate_derive(CloneIn, Dummy, TakeIn, ContentEq, ESTree)]
496#[estree(no_type)]
497pub struct TemplateElementValue<'a> {
498 pub raw: Atom<'a>,
502 pub cooked: Option<Atom<'a>>,
507}
508
509#[ast(visit)]
514#[derive(Debug)]
515#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
516pub enum MemberExpression<'a> {
517 ComputedMemberExpression(Box<'a, ComputedMemberExpression<'a>>) = 48,
519 StaticMemberExpression(Box<'a, StaticMemberExpression<'a>>) = 49,
521 PrivateFieldExpression(Box<'a, PrivateFieldExpression<'a>>) = 50,
523}
524
525#[macro_export]
527macro_rules! match_member_expression {
528 ($ty:ident) => {
529 $ty::ComputedMemberExpression(_)
530 | $ty::StaticMemberExpression(_)
531 | $ty::PrivateFieldExpression(_)
532 };
533}
534pub use match_member_expression;
535
536#[ast(visit)]
540#[derive(Debug)]
541#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
542#[estree(rename = "MemberExpression", add_fields(computed = True))]
543pub struct ComputedMemberExpression<'a> {
544 pub span: Span,
545 pub object: Expression<'a>,
546 #[estree(rename = "property")]
547 pub expression: Expression<'a>,
548 pub optional: bool, }
550
551#[ast(visit)]
555#[derive(Debug)]
556#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
557#[estree(rename = "MemberExpression", add_fields(computed = False))]
558pub struct StaticMemberExpression<'a> {
559 pub span: Span,
560 pub object: Expression<'a>,
561 pub property: IdentifierName<'a>,
562 pub optional: bool, }
564
565#[ast(visit)]
569#[derive(Debug)]
570#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
571#[estree(rename = "MemberExpression", add_fields(computed = False))]
572pub struct PrivateFieldExpression<'a> {
573 pub span: Span,
574 pub object: Expression<'a>,
575 #[estree(rename = "property")]
576 pub field: PrivateIdentifier<'a>,
577 pub optional: bool, }
579
580#[ast(visit)]
597#[derive(Debug)]
598#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
599pub struct CallExpression<'a> {
600 pub span: Span,
601 pub callee: Expression<'a>,
602 #[ts]
603 pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
604 pub arguments: Vec<'a, Argument<'a>>,
605 pub optional: bool, #[builder(default)]
608 #[estree(skip)]
609 pub pure: bool,
610}
611
612#[ast(visit)]
625#[derive(Debug)]
626#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
627pub struct NewExpression<'a> {
628 pub span: Span,
629 pub callee: Expression<'a>,
630 #[ts]
631 pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
632 pub arguments: Vec<'a, Argument<'a>>,
634 #[builder(default)]
635 #[estree(skip)]
636 pub pure: bool,
637}
638
639#[ast(visit)]
643#[derive(Debug)]
644#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
645pub struct MetaProperty<'a> {
646 pub span: Span,
647 pub meta: IdentifierName<'a>,
648 pub property: IdentifierName<'a>,
649}
650
651#[ast(visit)]
655#[derive(Debug)]
656#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
657pub struct SpreadElement<'a> {
658 pub span: Span,
659 pub argument: Expression<'a>,
661}
662
663inherit_variants! {
664#[ast(visit)]
670#[derive(Debug)]
671#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
672pub enum Argument<'a> {
673 SpreadElement(Box<'a, SpreadElement<'a>>) = 64,
675 @inherit Expression
677}
678}
679
680#[ast(visit)]
685#[derive(Debug)]
686#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
687pub struct UpdateExpression<'a> {
688 pub span: Span,
689 pub operator: UpdateOperator,
690 pub prefix: bool,
691 pub argument: SimpleAssignmentTarget<'a>,
692}
693
694#[ast(visit)]
699#[derive(Debug)]
700#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
701#[estree(add_fields(prefix = True))]
702pub struct UnaryExpression<'a> {
703 pub span: Span,
704 pub operator: UnaryOperator,
705 pub argument: Expression<'a>,
706}
707
708#[ast(visit)]
712#[derive(Debug)]
713#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
714pub struct BinaryExpression<'a> {
715 pub span: Span,
716 pub left: Expression<'a>,
717 pub operator: BinaryOperator,
718 pub right: Expression<'a>,
719}
720
721#[ast(visit)]
723#[derive(Debug)]
724#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
725#[estree(rename = "BinaryExpression", add_fields(operator = In), field_order(left, operator, right, span))]
726pub struct PrivateInExpression<'a> {
727 pub span: Span,
728 pub left: PrivateIdentifier<'a>,
729 pub right: Expression<'a>,
730}
731
732#[ast(visit)]
737#[derive(Debug)]
738#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
739pub struct LogicalExpression<'a> {
740 pub span: Span,
741 pub left: Expression<'a>,
742 pub operator: LogicalOperator,
743 pub right: Expression<'a>,
744}
745
746#[ast(visit)]
750#[derive(Debug)]
751#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
752pub struct ConditionalExpression<'a> {
753 pub span: Span,
754 pub test: Expression<'a>,
755 pub consequent: Expression<'a>,
756 pub alternate: Expression<'a>,
757}
758
759#[ast(visit)]
763#[derive(Debug)]
764#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
765pub struct AssignmentExpression<'a> {
766 pub span: Span,
767 pub operator: AssignmentOperator,
768 pub left: AssignmentTarget<'a>,
769 pub right: Expression<'a>,
770}
771
772inherit_variants! {
773#[ast(visit)]
780#[derive(Debug)]
781#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
782pub enum AssignmentTarget<'a> {
783 @inherit SimpleAssignmentTarget
785 @inherit AssignmentTargetPattern
787}
788}
789
790inherit_variants! {
791#[ast(visit)]
797#[derive(Debug)]
798#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
799pub enum SimpleAssignmentTarget<'a> {
800 AssignmentTargetIdentifier(Box<'a, IdentifierReference<'a>>) = 0,
801 TSAsExpression(Box<'a, TSAsExpression<'a>>) = 1,
802 TSSatisfiesExpression(Box<'a, TSSatisfiesExpression<'a>>) = 2,
803 TSNonNullExpression(Box<'a, TSNonNullExpression<'a>>) = 3,
804 TSTypeAssertion(Box<'a, TSTypeAssertion<'a>>) = 4,
805 @inherit MemberExpression
807}
808}
809
810#[macro_export]
813macro_rules! match_assignment_target {
814 ($ty:ident) => {
815 $ty::AssignmentTargetIdentifier(_)
816 | $ty::ComputedMemberExpression(_)
817 | $ty::StaticMemberExpression(_)
818 | $ty::PrivateFieldExpression(_)
819 | $ty::TSAsExpression(_)
820 | $ty::TSSatisfiesExpression(_)
821 | $ty::TSNonNullExpression(_)
822 | $ty::TSTypeAssertion(_)
823 | $ty::ArrayAssignmentTarget(_)
824 | $ty::ObjectAssignmentTarget(_)
825 };
826}
827pub use match_assignment_target;
828
829#[macro_export]
832macro_rules! match_simple_assignment_target {
833 ($ty:ident) => {
834 $ty::AssignmentTargetIdentifier(_)
835 | $ty::ComputedMemberExpression(_)
836 | $ty::StaticMemberExpression(_)
837 | $ty::PrivateFieldExpression(_)
838 | $ty::TSAsExpression(_)
839 | $ty::TSSatisfiesExpression(_)
840 | $ty::TSNonNullExpression(_)
841 | $ty::TSTypeAssertion(_)
842 };
843}
844pub use match_simple_assignment_target;
845
846#[ast(visit)]
847#[derive(Debug)]
848#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
849pub enum AssignmentTargetPattern<'a> {
850 ArrayAssignmentTarget(Box<'a, ArrayAssignmentTarget<'a>>) = 8,
851 ObjectAssignmentTarget(Box<'a, ObjectAssignmentTarget<'a>>) = 9,
852}
853
854#[macro_export]
856macro_rules! match_assignment_target_pattern {
857 ($ty:ident) => {
858 $ty::ArrayAssignmentTarget(_) | $ty::ObjectAssignmentTarget(_)
859 };
860}
861pub use match_assignment_target_pattern;
862
863#[ast(visit)]
867#[derive(Debug)]
868#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
869#[estree(
870 rename = "ArrayPattern",
871 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
872 field_order(decorators, elements, optional, typeAnnotation, span),
873)]
874pub struct ArrayAssignmentTarget<'a> {
875 pub span: Span,
876 pub elements: Vec<'a, Option<AssignmentTargetMaybeDefault<'a>>>,
877 #[estree(append_to = elements)]
878 pub rest: Option<Box<'a, AssignmentTargetRest<'a>>>,
879}
880
881#[ast(visit)]
885#[derive(Debug)]
886#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
887#[estree(
888 rename = "ObjectPattern",
889 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
890 field_order(decorators, properties, optional, typeAnnotation, span),
891)]
892pub struct ObjectAssignmentTarget<'a> {
893 pub span: Span,
894 pub properties: Vec<'a, AssignmentTargetProperty<'a>>,
895 #[estree(append_to = properties)]
896 pub rest: Option<Box<'a, AssignmentTargetRest<'a>>>,
897}
898
899#[ast(visit)]
903#[derive(Debug)]
904#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
905#[estree(
906 rename = "RestElement",
907 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull, value = TsNull),
908 field_order(decorators, target, optional, typeAnnotation, value, span),
909)]
910pub struct AssignmentTargetRest<'a> {
911 pub span: Span,
912 #[estree(rename = "argument")]
913 pub target: AssignmentTarget<'a>,
914}
915
916inherit_variants! {
917#[ast(visit)]
923#[derive(Debug)]
924#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
925pub enum AssignmentTargetMaybeDefault<'a> {
926 AssignmentTargetWithDefault(Box<'a, AssignmentTargetWithDefault<'a>>) = 16,
927 @inherit AssignmentTarget
929}
930}
931
932#[ast(visit)]
933#[derive(Debug)]
934#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
935#[estree(
936 rename = "AssignmentPattern",
937 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
938 field_order(decorators, binding, init, optional, typeAnnotation, span),
939)]
940pub struct AssignmentTargetWithDefault<'a> {
941 pub span: Span,
942 #[estree(rename = "left")]
943 pub binding: AssignmentTarget<'a>,
944 #[estree(rename = "right")]
945 pub init: Expression<'a>,
946}
947
948#[ast(visit)]
949#[derive(Debug)]
950#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
951pub enum AssignmentTargetProperty<'a> {
952 AssignmentTargetPropertyIdentifier(Box<'a, AssignmentTargetPropertyIdentifier<'a>>) = 0,
953 AssignmentTargetPropertyProperty(Box<'a, AssignmentTargetPropertyProperty<'a>>) = 1,
954}
955
956#[ast(visit)]
961#[derive(Debug)]
962#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
963#[estree(
964 rename = "Property",
965 add_fields(kind = Init, method = False, shorthand = True, computed = False, optional = TsFalse),
966 field_order(kind, binding, init, method, shorthand, computed, optional, span),
967)]
968pub struct AssignmentTargetPropertyIdentifier<'a> {
969 pub span: Span,
970 #[estree(rename = "key")]
971 pub binding: IdentifierReference<'a>,
972 #[estree(rename = "value", via = AssignmentTargetPropertyIdentifierInit)]
973 pub init: Option<Expression<'a>>,
974}
975
976#[ast(visit)]
980#[derive(Debug)]
981#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
982#[estree(
983 rename = "Property",
984 add_fields(kind = Init, method = False, shorthand = False, optional = TsFalse),
985 field_order(kind, name, binding, method, shorthand, computed, optional, span),
986)]
987pub struct AssignmentTargetPropertyProperty<'a> {
988 pub span: Span,
989 #[estree(rename = "key")]
995 pub name: PropertyKey<'a>,
996 #[estree(rename = "value")]
1002 pub binding: AssignmentTargetMaybeDefault<'a>,
1003 pub computed: bool,
1005}
1006
1007#[ast(visit)]
1011#[derive(Debug)]
1012#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1013pub struct SequenceExpression<'a> {
1014 pub span: Span,
1015 pub expressions: Vec<'a, Expression<'a>>,
1016}
1017
1018#[ast(visit)]
1022#[derive(Debug)]
1023#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1024pub struct Super {
1025 pub span: Span,
1026}
1027
1028#[ast(visit)]
1032#[derive(Debug)]
1033#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1034pub struct AwaitExpression<'a> {
1035 pub span: Span,
1036 pub argument: Expression<'a>,
1037}
1038
1039#[ast(visit)]
1043#[derive(Debug)]
1044#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1045pub struct ChainExpression<'a> {
1046 pub span: Span,
1047 pub expression: ChainElement<'a>,
1048}
1049
1050inherit_variants! {
1051#[ast(visit)]
1057#[derive(Debug)]
1058#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1059pub enum ChainElement<'a> {
1060 CallExpression(Box<'a, CallExpression<'a>>) = 0,
1061 TSNonNullExpression(Box<'a, TSNonNullExpression<'a>>) = 1,
1063 @inherit MemberExpression
1065}
1066}
1067
1068#[ast(visit)]
1072#[derive(Debug)]
1073#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1074#[estree(via = ParenthesizedExpressionConverter)]
1075pub struct ParenthesizedExpression<'a> {
1076 pub span: Span,
1077 pub expression: Expression<'a>,
1078}
1079
1080inherit_variants! {
1081#[ast(visit)]
1088#[derive(Debug)]
1089#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1090pub enum Statement<'a> {
1091 BlockStatement(Box<'a, BlockStatement<'a>>) = 0,
1093 BreakStatement(Box<'a, BreakStatement<'a>>) = 1,
1094 ContinueStatement(Box<'a, ContinueStatement<'a>>) = 2,
1095 DebuggerStatement(Box<'a, DebuggerStatement>) = 3,
1096 DoWhileStatement(Box<'a, DoWhileStatement<'a>>) = 4,
1097 EmptyStatement(Box<'a, EmptyStatement>) = 5,
1098 ExpressionStatement(Box<'a, ExpressionStatement<'a>>) = 6,
1099 ForInStatement(Box<'a, ForInStatement<'a>>) = 7,
1100 ForOfStatement(Box<'a, ForOfStatement<'a>>) = 8,
1101 ForStatement(Box<'a, ForStatement<'a>>) = 9,
1102 IfStatement(Box<'a, IfStatement<'a>>) = 10,
1103 LabeledStatement(Box<'a, LabeledStatement<'a>>) = 11,
1104 ReturnStatement(Box<'a, ReturnStatement<'a>>) = 12,
1105 SwitchStatement(Box<'a, SwitchStatement<'a>>) = 13,
1106 ThrowStatement(Box<'a, ThrowStatement<'a>>) = 14,
1107 TryStatement(Box<'a, TryStatement<'a>>) = 15,
1108 WhileStatement(Box<'a, WhileStatement<'a>>) = 16,
1109 WithStatement(Box<'a, WithStatement<'a>>) = 17,
1110 @inherit Declaration
1112 @inherit ModuleDeclaration
1114}
1115}
1116
1117#[ast(visit)]
1121#[derive(Debug)]
1122#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1123#[estree(rename = "ExpressionStatement")]
1124pub struct Directive<'a> {
1125 pub span: Span,
1126 pub expression: StringLiteral<'a>,
1128 pub directive: Atom<'a>,
1130}
1131
1132#[ast(visit)]
1136#[derive(Debug)]
1137#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1138pub struct Hashbang<'a> {
1139 pub span: Span,
1140 pub value: Atom<'a>,
1141}
1142
1143#[ast(visit)]
1147#[scope]
1148#[derive(Debug)]
1149#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1150pub struct BlockStatement<'a> {
1151 pub span: Span,
1152 pub body: Vec<'a, Statement<'a>>,
1153 pub scope_id: Cell<Option<ScopeId>>,
1154}
1155
1156#[ast(visit)]
1158#[derive(Debug)]
1159#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1160pub enum Declaration<'a> {
1161 VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 32,
1162 #[visit(args(flags = ScopeFlags::Function))]
1163 FunctionDeclaration(Box<'a, Function<'a>>) = 33,
1164 ClassDeclaration(Box<'a, Class<'a>>) = 34,
1165
1166 TSTypeAliasDeclaration(Box<'a, TSTypeAliasDeclaration<'a>>) = 35,
1167 TSInterfaceDeclaration(Box<'a, TSInterfaceDeclaration<'a>>) = 36,
1168 TSEnumDeclaration(Box<'a, TSEnumDeclaration<'a>>) = 37,
1169 TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 38,
1170 TSImportEqualsDeclaration(Box<'a, TSImportEqualsDeclaration<'a>>) = 39,
1171}
1172
1173#[macro_export]
1175macro_rules! match_declaration {
1176 ($ty:ident) => {
1177 $ty::VariableDeclaration(_)
1178 | $ty::FunctionDeclaration(_)
1179 | $ty::ClassDeclaration(_)
1180 | $ty::TSTypeAliasDeclaration(_)
1181 | $ty::TSInterfaceDeclaration(_)
1182 | $ty::TSEnumDeclaration(_)
1183 | $ty::TSModuleDeclaration(_)
1184 | $ty::TSImportEqualsDeclaration(_)
1185 };
1186}
1187pub use match_declaration;
1188
1189#[ast(visit)]
1193#[derive(Debug)]
1194#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1195pub struct VariableDeclaration<'a> {
1196 pub span: Span,
1197 pub kind: VariableDeclarationKind,
1198 pub declarations: Vec<'a, VariableDeclarator<'a>>,
1199 #[ts]
1200 pub declare: bool,
1201}
1202
1203#[ast]
1204#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1205#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
1206pub enum VariableDeclarationKind {
1207 Var = 0,
1208 Let = 1,
1209 Const = 2,
1210 Using = 3,
1211 #[estree(rename = "await using")]
1212 AwaitUsing = 4,
1213}
1214
1215#[ast(visit)]
1224#[derive(Debug)]
1225#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1226pub struct VariableDeclarator<'a> {
1227 pub span: Span,
1228 #[estree(skip)]
1229 pub kind: VariableDeclarationKind,
1230 pub id: BindingPattern<'a>,
1231 pub init: Option<Expression<'a>>,
1232 #[ts]
1233 pub definite: bool,
1234}
1235
1236#[ast(visit)]
1238#[derive(Debug)]
1239#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1240pub struct EmptyStatement {
1241 pub span: Span,
1242}
1243
1244#[ast(visit)]
1246#[derive(Debug)]
1247#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1248#[estree(add_fields(directive = ExpressionStatementDirective))] pub struct ExpressionStatement<'a> {
1250 pub span: Span,
1251 pub expression: Expression<'a>,
1252}
1253
1254#[ast(visit)]
1256#[derive(Debug)]
1257#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1258pub struct IfStatement<'a> {
1259 pub span: Span,
1260 pub test: Expression<'a>,
1261 pub consequent: Statement<'a>,
1262 pub alternate: Option<Statement<'a>>,
1263}
1264
1265#[ast(visit)]
1267#[derive(Debug)]
1268#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1269pub struct DoWhileStatement<'a> {
1270 pub span: Span,
1271 pub body: Statement<'a>,
1272 pub test: Expression<'a>,
1273}
1274
1275#[ast(visit)]
1277#[derive(Debug)]
1278#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1279pub struct WhileStatement<'a> {
1280 pub span: Span,
1281 pub test: Expression<'a>,
1282 pub body: Statement<'a>,
1283}
1284
1285#[ast(visit)]
1287#[scope]
1288#[derive(Debug)]
1289#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1290pub struct ForStatement<'a> {
1291 pub span: Span,
1292 pub init: Option<ForStatementInit<'a>>,
1293 pub test: Option<Expression<'a>>,
1294 pub update: Option<Expression<'a>>,
1295 pub body: Statement<'a>,
1296 pub scope_id: Cell<Option<ScopeId>>,
1297}
1298
1299inherit_variants! {
1300#[ast(visit)]
1306#[derive(Debug)]
1307#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1308pub enum ForStatementInit<'a> {
1309 VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 64,
1310 @inherit Expression
1312}
1313}
1314
1315#[ast(visit)]
1317#[scope]
1318#[derive(Debug)]
1319#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1320pub struct ForInStatement<'a> {
1321 pub span: Span,
1322 pub left: ForStatementLeft<'a>,
1323 pub right: Expression<'a>,
1324 pub body: Statement<'a>,
1325 pub scope_id: Cell<Option<ScopeId>>,
1326}
1327
1328inherit_variants! {
1329#[ast(visit)]
1335#[derive(Debug)]
1336#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1337pub enum ForStatementLeft<'a> {
1338 VariableDeclaration(Box<'a, VariableDeclaration<'a>>) = 16,
1339 @inherit AssignmentTarget
1341}
1342}
1343
1344#[ast(visit)]
1346#[scope]
1347#[derive(Debug)]
1348#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1349pub struct ForOfStatement<'a> {
1350 pub span: Span,
1351 pub r#await: bool,
1352 pub left: ForStatementLeft<'a>,
1353 pub right: Expression<'a>,
1354 pub body: Statement<'a>,
1355 pub scope_id: Cell<Option<ScopeId>>,
1356}
1357
1358#[ast(visit)]
1360#[derive(Debug)]
1361#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1362pub struct ContinueStatement<'a> {
1363 pub span: Span,
1364 pub label: Option<LabelIdentifier<'a>>,
1365}
1366
1367#[ast(visit)]
1369#[derive(Debug)]
1370#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1371pub struct BreakStatement<'a> {
1372 pub span: Span,
1373 pub label: Option<LabelIdentifier<'a>>,
1374}
1375
1376#[ast(visit)]
1378#[derive(Debug)]
1379#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1380pub struct ReturnStatement<'a> {
1381 pub span: Span,
1382 pub argument: Option<Expression<'a>>,
1383}
1384
1385#[ast(visit)]
1387#[derive(Debug)]
1388#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1389pub struct WithStatement<'a> {
1390 pub span: Span,
1391 pub object: Expression<'a>,
1392 pub body: Statement<'a>,
1393}
1394
1395#[ast(visit)]
1397#[scope]
1398#[derive(Debug)]
1399#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1400pub struct SwitchStatement<'a> {
1401 pub span: Span,
1402 pub discriminant: Expression<'a>,
1403 #[scope(enter_before)]
1404 pub cases: Vec<'a, SwitchCase<'a>>,
1405 pub scope_id: Cell<Option<ScopeId>>,
1406}
1407
1408#[ast(visit)]
1409#[derive(Debug)]
1410#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1411pub struct SwitchCase<'a> {
1412 pub span: Span,
1413 pub test: Option<Expression<'a>>,
1414 pub consequent: Vec<'a, Statement<'a>>,
1415}
1416
1417#[ast(visit)]
1419#[derive(Debug)]
1420#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1421pub struct LabeledStatement<'a> {
1422 pub span: Span,
1423 pub label: LabelIdentifier<'a>,
1424 pub body: Statement<'a>,
1425}
1426
1427#[ast(visit)]
1435#[derive(Debug)]
1436#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1437pub struct ThrowStatement<'a> {
1438 pub span: Span,
1439 pub argument: Expression<'a>,
1441}
1442
1443#[ast(visit)]
1459#[derive(Debug)]
1460#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1461pub struct TryStatement<'a> {
1462 pub span: Span,
1463 pub block: Box<'a, BlockStatement<'a>>,
1465 pub handler: Option<Box<'a, CatchClause<'a>>>,
1467 pub finalizer: Option<Box<'a, BlockStatement<'a>>>,
1469}
1470
1471#[ast(visit)]
1484#[scope(flags = ScopeFlags::CatchClause)]
1485#[derive(Debug)]
1486#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1487pub struct CatchClause<'a> {
1488 pub span: Span,
1489 pub param: Option<CatchParameter<'a>>,
1491 pub body: Box<'a, BlockStatement<'a>>,
1493 pub scope_id: Cell<Option<ScopeId>>,
1494}
1495
1496#[ast(visit)]
1510#[derive(Debug)]
1511#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1512#[estree(no_type, via = CatchParameterConverter)]
1513pub struct CatchParameter<'a> {
1514 #[estree(skip)]
1515 pub span: Span,
1516 #[estree(flatten)]
1518 pub pattern: BindingPattern<'a>,
1519}
1520
1521#[ast(visit)]
1529#[derive(Debug)]
1530#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1531pub struct DebuggerStatement {
1532 pub span: Span,
1533}
1534
1535#[ast(visit)]
1544#[derive(Debug)]
1545#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1546#[estree(no_type, via = BindingPatternConverter, field_order(kind, optional, type_annotation))]
1547pub struct BindingPattern<'a> {
1548 #[estree(
1550 flatten,
1551 ts_type = "(BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern)"
1552 )]
1553 #[span]
1554 pub kind: BindingPatternKind<'a>,
1555 #[ts]
1556 pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
1557 #[ts]
1558 pub optional: bool,
1559}
1560
1561#[ast(visit)]
1562#[derive(Debug)]
1563#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1564pub enum BindingPatternKind<'a> {
1565 BindingIdentifier(Box<'a, BindingIdentifier<'a>>) = 0,
1575 ObjectPattern(Box<'a, ObjectPattern<'a>>) = 1,
1585 ArrayPattern(Box<'a, ArrayPattern<'a>>) = 2,
1595 AssignmentPattern(Box<'a, AssignmentPattern<'a>>) = 3,
1611}
1612
1613#[ast(visit)]
1617#[derive(Debug)]
1618#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1619#[estree(
1620 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
1621 field_order(decorators, left, right, optional, typeAnnotation, span),
1622)]
1623pub struct AssignmentPattern<'a> {
1624 pub span: Span,
1625 pub left: BindingPattern<'a>,
1626 pub right: Expression<'a>,
1627}
1628
1629#[ast(visit)]
1633#[derive(Debug)]
1634#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1635#[estree(
1636 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
1637 field_order(decorators, properties, optional, typeAnnotation, span),
1638)]
1639pub struct ObjectPattern<'a> {
1640 pub span: Span,
1641 pub properties: Vec<'a, BindingProperty<'a>>,
1642 #[estree(append_to = properties)]
1643 pub rest: Option<Box<'a, BindingRestElement<'a>>>,
1644}
1645
1646#[ast(visit)]
1647#[derive(Debug)]
1648#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1649#[estree(
1650 rename = "Property",
1651 add_fields(kind = Init, method = False, optional = TsFalse),
1652 field_order(kind, key, value, method, shorthand, computed, optional, span),
1653)]
1654pub struct BindingProperty<'a> {
1655 pub span: Span,
1656 pub key: PropertyKey<'a>,
1657 pub value: BindingPattern<'a>,
1658 pub shorthand: bool,
1659 pub computed: bool,
1660}
1661
1662#[ast(visit)]
1666#[derive(Debug)]
1667#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1668#[estree(
1669 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull),
1670 field_order(decorators, elements, optional, typeAnnotation, span),
1671)]
1672pub struct ArrayPattern<'a> {
1673 pub span: Span,
1674 pub elements: Vec<'a, Option<BindingPattern<'a>>>,
1675 #[estree(append_to = elements)]
1676 pub rest: Option<Box<'a, BindingRestElement<'a>>>,
1677}
1678
1679#[ast(visit)]
1689#[derive(Debug)]
1690#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1691#[estree(
1692 rename = "RestElement",
1693 add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull, value = TsNull),
1694 field_order(decorators, argument, optional, typeAnnotation, value, span),
1695)]
1696pub struct BindingRestElement<'a> {
1697 pub span: Span,
1698 pub argument: BindingPattern<'a>,
1699}
1700
1701#[ast(visit)]
1737#[visit(args(flags = ScopeFlags))]
1738#[scope(
1739 flags = flags,
1741 strict_if = self.has_use_strict_directive(),
1742)]
1743#[derive(Debug)]
1744#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1745#[estree(
1748 add_ts_def = "type ParamPattern = FormalParameter | TSParameterProperty | FormalParameterRest",
1749 add_fields(expression = False),
1750)]
1751pub struct Function<'a> {
1752 pub span: Span,
1753 pub r#type: FunctionType,
1754 pub id: Option<BindingIdentifier<'a>>,
1756 pub generator: bool,
1763 pub r#async: bool,
1764 #[ts]
1765 pub declare: bool,
1766 #[ts]
1767 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
1768 #[ts]
1785 #[estree(skip)]
1786 pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
1787 #[estree(via = FunctionParams)]
1791 pub params: Box<'a, FormalParameters<'a>>,
1792 #[ts]
1794 pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
1795 pub body: Option<Box<'a, FunctionBody<'a>>>,
1808 pub scope_id: Cell<Option<ScopeId>>,
1809 #[builder(default)]
1811 #[estree(skip)]
1812 pub pure: bool,
1813 #[builder(default)]
1814 #[estree(skip)]
1815 pub pife: bool,
1823}
1824
1825#[ast]
1826#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1827#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
1828#[estree(no_rename_variants)]
1829pub enum FunctionType {
1830 FunctionDeclaration = 0,
1831 FunctionExpression = 1,
1832 TSDeclareFunction = 2,
1833 TSEmptyBodyFunctionExpression = 3,
1835}
1836
1837#[ast(visit)]
1839#[derive(Debug)]
1840#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1841#[estree(
1842 via = FormalParametersConverter,
1843 add_ts_def = "
1844 interface FormalParameterRest extends Span {
1845 type: 'RestElement';
1846 argument: BindingPatternKind;
1847 decorators?: [],
1848 optional?: boolean;
1849 typeAnnotation?: TSTypeAnnotation | null;
1850 value?: null;
1851 }
1852 "
1853)]
1854pub struct FormalParameters<'a> {
1855 pub span: Span,
1856 pub kind: FormalParameterKind,
1857 #[estree(ts_type = "Array<FormalParameter | TSParameterProperty | FormalParameterRest>")]
1858 pub items: Vec<'a, FormalParameter<'a>>,
1859 #[estree(skip)]
1860 pub rest: Option<Box<'a, BindingRestElement<'a>>>,
1861}
1862
1863#[ast(visit)]
1864#[derive(Debug)]
1865#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1866#[plural(FormalParameterList)]
1868#[estree(
1869 no_type,
1870 via = FormalParameterConverter,
1871 add_ts_def = "
1872 type FormalParameter =
1873 & ({
1874 decorators?: Array<Decorator>;
1875 })
1876 & BindingPattern;
1877
1878 export interface TSParameterProperty extends Span {
1879 type: 'TSParameterProperty';
1880 accessibility: TSAccessibility | null;
1881 decorators: Array<Decorator>;
1882 override: boolean;
1883 parameter: FormalParameter;
1884 readonly: boolean;
1885 static: boolean;
1886 }
1887 "
1888)]
1889pub struct FormalParameter<'a> {
1890 #[estree(skip)]
1891 pub span: Span,
1892 #[ts]
1893 pub decorators: Vec<'a, Decorator<'a>>,
1894 #[estree(flatten)]
1895 pub pattern: BindingPattern<'a>,
1896 #[ts]
1897 #[estree(skip)]
1898 pub accessibility: Option<TSAccessibility>,
1899 #[ts]
1900 #[estree(skip)]
1901 pub readonly: bool,
1902 #[ts]
1903 #[estree(skip)]
1904 pub r#override: bool,
1905}
1906
1907#[ast]
1908#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1909#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
1910#[estree(no_rename_variants, no_ts_def)]
1911pub enum FormalParameterKind {
1912 FormalParameter = 0,
1914 UniqueFormalParameters = 1,
1916 ArrowFormalParameters = 2,
1918 Signature = 3,
1920}
1921
1922#[ast(visit)]
1924#[derive(Debug)]
1925#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1926#[estree(rename = "BlockStatement")]
1927pub struct FunctionBody<'a> {
1928 pub span: Span,
1929 #[estree(prepend_to = statements)]
1930 pub directives: Vec<'a, Directive<'a>>,
1931 #[estree(rename = "body")]
1932 pub statements: Vec<'a, Statement<'a>>,
1933}
1934
1935#[ast(visit)]
1937#[scope(
1938 flags = ScopeFlags::Function | ScopeFlags::Arrow,
1939 strict_if = self.has_use_strict_directive(),
1940)]
1941#[derive(Debug)]
1942#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1943#[estree(add_fields(id = Null, generator = False))]
1944pub struct ArrowFunctionExpression<'a> {
1945 pub span: Span,
1946 pub expression: bool,
1948 pub r#async: bool,
1949 #[ts]
1950 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
1951 pub params: Box<'a, FormalParameters<'a>>,
1952 #[ts]
1953 pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
1954 #[estree(via = ArrowFunctionExpressionBody)]
1957 pub body: Box<'a, FunctionBody<'a>>,
1958 pub scope_id: Cell<Option<ScopeId>>,
1959 #[builder(default)]
1961 #[estree(skip)]
1962 pub pure: bool,
1963 #[builder(default)]
1964 #[estree(skip)]
1965 pub pife: bool,
1971}
1972
1973#[ast(visit)]
1975#[derive(Debug)]
1976#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1977pub struct YieldExpression<'a> {
1978 pub span: Span,
1979 pub delegate: bool,
1980 pub argument: Option<Expression<'a>>,
1981}
1982
1983#[ast(visit)]
1985#[scope(flags = ScopeFlags::StrictMode)]
1986#[derive(Debug)]
1987#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1988pub struct Class<'a> {
1989 pub span: Span,
1990 pub r#type: ClassType,
1991 pub decorators: Vec<'a, Decorator<'a>>,
2002 pub id: Option<BindingIdentifier<'a>>,
2004 #[scope(enter_before)]
2005 #[ts]
2006 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
2007 pub super_class: Option<Expression<'a>>,
2015 #[ts]
2023 pub super_type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
2024 #[ts]
2033 pub implements: Vec<'a, TSClassImplements<'a>>,
2034 pub body: Box<'a, ClassBody<'a>>,
2035 #[ts]
2043 pub r#abstract: bool,
2044 #[ts]
2051 pub declare: bool,
2052 pub scope_id: Cell<Option<ScopeId>>,
2055}
2056
2057#[ast]
2058#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2059#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
2060#[estree(no_rename_variants)]
2061pub enum ClassType {
2062 ClassDeclaration = 0,
2067 ClassExpression = 1,
2073}
2074
2075#[ast(visit)]
2076#[derive(Debug)]
2077#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2078pub struct ClassBody<'a> {
2079 pub span: Span,
2080 pub body: Vec<'a, ClassElement<'a>>,
2081}
2082
2083#[ast(visit)]
2102#[derive(Debug)]
2103#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
2104pub enum ClassElement<'a> {
2105 StaticBlock(Box<'a, StaticBlock<'a>>) = 0,
2106 MethodDefinition(Box<'a, MethodDefinition<'a>>) = 1,
2110 PropertyDefinition(Box<'a, PropertyDefinition<'a>>) = 2,
2111 AccessorProperty(Box<'a, AccessorProperty<'a>>) = 3,
2112 TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 4,
2121}
2122
2123#[ast(visit)]
2124#[derive(Debug)]
2125#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2126pub struct MethodDefinition<'a> {
2127 pub span: Span,
2128 pub r#type: MethodDefinitionType,
2132 pub decorators: Vec<'a, Decorator<'a>>,
2133 pub key: PropertyKey<'a>,
2134 #[visit(args(flags = match self.kind {
2135 MethodDefinitionKind::Get => ScopeFlags::Function | ScopeFlags::GetAccessor,
2136 MethodDefinitionKind::Set => ScopeFlags::Function | ScopeFlags::SetAccessor,
2137 MethodDefinitionKind::Constructor => ScopeFlags::Function | ScopeFlags::Constructor,
2138 MethodDefinitionKind::Method => ScopeFlags::Function,
2139 }))]
2140 pub value: Box<'a, Function<'a>>, pub kind: MethodDefinitionKind,
2142 pub computed: bool,
2143 pub r#static: bool,
2144 #[ts]
2145 pub r#override: bool,
2146 #[ts]
2147 pub optional: bool,
2148 #[ts]
2149 pub accessibility: Option<TSAccessibility>,
2150}
2151
2152#[ast]
2153#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2154#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
2155#[estree(no_rename_variants)]
2156pub enum MethodDefinitionType {
2157 MethodDefinition = 0,
2158 TSAbstractMethodDefinition = 1,
2159}
2160
2161#[ast(visit)]
2162#[derive(Debug)]
2163#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2164pub struct PropertyDefinition<'a> {
2165 pub span: Span,
2166 pub r#type: PropertyDefinitionType,
2167 pub decorators: Vec<'a, Decorator<'a>>,
2171 pub key: PropertyKey<'a>,
2173 #[ts]
2179 pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
2180 pub value: Option<Expression<'a>>,
2195 pub computed: bool,
2205 pub r#static: bool,
2207 #[ts]
2221 pub declare: bool,
2222 #[ts]
2223 pub r#override: bool,
2224 #[ts]
2226 pub optional: bool,
2227 #[ts]
2228 pub definite: bool,
2229 #[ts]
2231 pub readonly: bool,
2232 #[ts]
2247 pub accessibility: Option<TSAccessibility>,
2248}
2249
2250#[ast]
2251#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2252#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
2253#[estree(no_rename_variants)]
2254pub enum PropertyDefinitionType {
2255 PropertyDefinition = 0,
2256 TSAbstractPropertyDefinition = 1,
2257}
2258
2259#[ast]
2260#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2261#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
2262pub enum MethodDefinitionKind {
2263 Constructor = 0,
2265 Method = 1,
2267 Get = 2,
2269 Set = 3,
2271}
2272
2273#[ast(visit)]
2277#[derive(Debug, Clone)]
2278#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2279pub struct PrivateIdentifier<'a> {
2280 pub span: Span,
2281 pub name: Atom<'a>,
2282}
2283
2284#[ast(visit)]
2298#[scope(flags = ScopeFlags::ClassStaticBlock)]
2299#[derive(Debug)]
2300#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2301pub struct StaticBlock<'a> {
2302 pub span: Span,
2303 pub body: Vec<'a, Statement<'a>>,
2304 pub scope_id: Cell<Option<ScopeId>>,
2305}
2306
2307#[ast(visit)]
2331#[derive(Debug)]
2332#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
2333pub enum ModuleDeclaration<'a> {
2334 ImportDeclaration(Box<'a, ImportDeclaration<'a>>) = 64,
2337 ExportAllDeclaration(Box<'a, ExportAllDeclaration<'a>>) = 65,
2339 ExportDefaultDeclaration(Box<'a, ExportDefaultDeclaration<'a>>) = 66,
2341 ExportNamedDeclaration(Box<'a, ExportNamedDeclaration<'a>>) = 67,
2344
2345 TSExportAssignment(Box<'a, TSExportAssignment<'a>>) = 68,
2347 TSNamespaceExportDeclaration(Box<'a, TSNamespaceExportDeclaration<'a>>) = 69,
2349}
2350
2351#[macro_export]
2353macro_rules! match_module_declaration {
2354 ($ty:ident) => {
2355 $ty::ImportDeclaration(_)
2356 | $ty::ExportAllDeclaration(_)
2357 | $ty::ExportDefaultDeclaration(_)
2358 | $ty::ExportNamedDeclaration(_)
2359 | $ty::TSExportAssignment(_)
2360 | $ty::TSNamespaceExportDeclaration(_)
2361 };
2362}
2363pub use match_module_declaration;
2364
2365#[ast]
2366#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2367#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
2368#[estree(no_rename_variants)]
2369pub enum AccessorPropertyType {
2370 AccessorProperty = 0,
2371 TSAbstractAccessorProperty = 1,
2372}
2373
2374#[ast(visit)]
2383#[derive(Debug)]
2384#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2385#[estree(add_fields(declare = TsFalse, optional = TsFalse, readonly = TsFalse))]
2386pub struct AccessorProperty<'a> {
2387 pub span: Span,
2388 pub r#type: AccessorPropertyType,
2389 pub decorators: Vec<'a, Decorator<'a>>,
2393 pub key: PropertyKey<'a>,
2395 #[ts]
2399 pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
2400 pub value: Option<Expression<'a>>,
2402 pub computed: bool,
2404 pub r#static: bool,
2406 #[ts]
2408 pub r#override: bool,
2409 #[ts]
2411 pub definite: bool,
2412 #[ts]
2427 pub accessibility: Option<TSAccessibility>,
2428}
2429
2430#[ast(visit)]
2431#[derive(Debug)]
2432#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2433pub struct ImportExpression<'a> {
2434 pub span: Span,
2435 pub source: Expression<'a>,
2436 pub options: Option<Expression<'a>>,
2437 pub phase: Option<ImportPhase>,
2438}
2439
2440#[ast(visit)]
2441#[derive(Debug)]
2442#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2443pub struct ImportDeclaration<'a> {
2444 pub span: Span,
2445 #[estree(via = ImportDeclarationSpecifiers)]
2447 pub specifiers: Option<Vec<'a, ImportDeclarationSpecifier<'a>>>,
2448 pub source: StringLiteral<'a>,
2449 pub phase: Option<ImportPhase>,
2450 #[estree(rename = "attributes", via = ImportDeclarationWithClause)]
2452 pub with_clause: Option<Box<'a, WithClause<'a>>>,
2453 #[ts]
2455 pub import_kind: ImportOrExportKind,
2456}
2457
2458#[ast]
2464#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2465#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
2466pub enum ImportPhase {
2467 Source = 0,
2468 Defer = 1,
2469}
2470
2471#[ast(visit)]
2472#[derive(Debug)]
2473#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
2474pub enum ImportDeclarationSpecifier<'a> {
2475 ImportSpecifier(Box<'a, ImportSpecifier<'a>>) = 0,
2478 ImportDefaultSpecifier(Box<'a, ImportDefaultSpecifier<'a>>) = 1,
2480 ImportNamespaceSpecifier(Box<'a, ImportNamespaceSpecifier<'a>>) = 2,
2482}
2483
2484#[ast(visit)]
2498#[derive(Debug)]
2499#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2500pub struct ImportSpecifier<'a> {
2501 pub span: Span,
2502 pub imported: ModuleExportName<'a>,
2505 pub local: BindingIdentifier<'a>,
2507 #[ts]
2511 pub import_kind: ImportOrExportKind,
2512}
2513
2514#[ast(visit)]
2522#[derive(Debug)]
2523#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2524pub struct ImportDefaultSpecifier<'a> {
2525 pub span: Span,
2526 pub local: BindingIdentifier<'a>,
2528}
2529
2530#[ast(visit)]
2537#[derive(Debug)]
2538#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2539pub struct ImportNamespaceSpecifier<'a> {
2540 pub span: Span,
2541 pub local: BindingIdentifier<'a>,
2542}
2543
2544#[ast(visit)]
2545#[derive(Debug)]
2546#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2547#[estree(no_type, no_ts_def)]
2548pub struct WithClause<'a> {
2549 #[estree(skip)]
2550 pub span: Span,
2551 #[estree(skip)]
2552 pub keyword: WithClauseKeyword,
2553 #[estree(rename = "attributes")]
2554 pub with_entries: Vec<'a, ImportAttribute<'a>>,
2555}
2556
2557#[ast]
2558#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2559#[generate_derive(CloneIn, Dummy, ContentEq)]
2560#[estree(no_ts_def)]
2561pub enum WithClauseKeyword {
2562 With = 0,
2563 Assert = 1,
2564}
2565
2566#[ast(visit)]
2567#[derive(Debug)]
2568#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2569pub struct ImportAttribute<'a> {
2570 pub span: Span,
2571 pub key: ImportAttributeKey<'a>,
2572 pub value: StringLiteral<'a>,
2573}
2574
2575#[ast(visit)]
2576#[derive(Debug)]
2577#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2578pub enum ImportAttributeKey<'a> {
2579 Identifier(IdentifierName<'a>) = 0,
2580 StringLiteral(StringLiteral<'a>) = 1,
2581}
2582
2583#[ast(visit)]
2595#[derive(Debug)]
2596#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2597pub struct ExportNamedDeclaration<'a> {
2598 pub span: Span,
2599 pub declaration: Option<Declaration<'a>>,
2600 pub specifiers: Vec<'a, ExportSpecifier<'a>>,
2601 pub source: Option<StringLiteral<'a>>,
2602 #[ts]
2604 pub export_kind: ImportOrExportKind,
2605 #[estree(rename = "attributes", via = ExportNamedDeclarationWithClause)]
2607 pub with_clause: Option<Box<'a, WithClause<'a>>>,
2608}
2609
2610#[ast(visit)]
2620#[derive(Debug)]
2621#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2622#[estree(add_fields(exportKind = TsValue))]
2623pub struct ExportDefaultDeclaration<'a> {
2624 pub span: Span,
2625 pub declaration: ExportDefaultDeclarationKind<'a>,
2626}
2627
2628#[ast(visit)]
2638#[derive(Debug)]
2639#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2640pub struct ExportAllDeclaration<'a> {
2641 pub span: Span,
2642 pub exported: Option<ModuleExportName<'a>>,
2644 pub source: StringLiteral<'a>,
2645 #[estree(rename = "attributes", via = ExportAllDeclarationWithClause)]
2647 pub with_clause: Option<Box<'a, WithClause<'a>>>, #[ts]
2649 pub export_kind: ImportOrExportKind, }
2651
2652#[ast(visit)]
2668#[derive(Debug)]
2669#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2670pub struct ExportSpecifier<'a> {
2671 pub span: Span,
2672 pub local: ModuleExportName<'a>,
2673 pub exported: ModuleExportName<'a>,
2674 #[ts]
2675 pub export_kind: ImportOrExportKind, }
2677
2678inherit_variants! {
2679#[ast(visit)]
2685#[derive(Debug)]
2686#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
2687pub enum ExportDefaultDeclarationKind<'a> {
2688 #[visit(args(flags = ScopeFlags::Function))]
2689 FunctionDeclaration(Box<'a, Function<'a>>) = 64,
2690 ClassDeclaration(Box<'a, Class<'a>>) = 65,
2691
2692 TSInterfaceDeclaration(Box<'a, TSInterfaceDeclaration<'a>>) = 66,
2693
2694 @inherit Expression
2696}
2697}
2698
2699#[ast(visit)]
2707#[derive(Debug, Clone)]
2708#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2709pub enum ModuleExportName<'a> {
2710 IdentifierName(IdentifierName<'a>) = 0,
2711 IdentifierReference(IdentifierReference<'a>) = 1,
2713 StringLiteral(StringLiteral<'a>) = 2,
2714}
2715
2716#[ast(visit)]
2719#[derive(Debug)]
2720#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
2721pub struct V8IntrinsicExpression<'a> {
2722 pub span: Span,
2723 pub name: IdentifierName<'a>,
2724 pub arguments: Vec<'a, Argument<'a>>,
2725}