swc_estree_ast/
typescript.rs

1use serde::{Deserialize, Serialize};
2use swc_atoms::Atom;
3use swc_common::ast_serde;
4
5use crate::{
6    class::ClassMethodKind,
7    common::{Access, BaseNode, Decorator, IdOrRest, IdOrString, Identifier, Noop, Param},
8    expr::Expression,
9    lit::{BigIntLiteral, BooleanLiteral, NumericLiteral, StringLiteral},
10    object::ObjectKey,
11    pat::AssignmentPattern,
12    stmt::Statement,
13};
14
15#[derive(Debug, Clone, PartialEq)]
16#[ast_serde]
17pub enum TSTypeElement {
18    #[tag("TSCallSignatureDeclaration")]
19    CallSignatureDecl(TSCallSignatureDeclaration),
20    #[tag("TSConstructSignatureDeclaration")]
21    ConstructSignatureDecl(TSConstructSignatureDeclaration),
22    #[tag("TSPropertySignature")]
23    PropSignature(TSPropertySignature),
24    #[tag("TSMethodSignature")]
25    MethodSignature(TSMethodSignature),
26    #[tag("TSIndexSignature")]
27    IndexSignature(TSIndexSignature),
28}
29
30#[derive(Debug, Clone, PartialEq)]
31#[ast_serde]
32pub enum TSType {
33    #[tag("TSAnyKeyword")]
34    AnyKeyword(TSAnyKeyword),
35    #[tag("TSBooleanKeyword")]
36    BooleanKeyword(TSBooleanKeyword),
37    #[tag("TSBigIntKeyword")]
38    BigIntKeyword(TSBigIntKeyword),
39    #[tag("TSIntrinsicKeyword")]
40    IntrinsicKeyword(TSIntrinsicKeyword),
41    #[tag("TSNeverKeyword")]
42    NeverKeyword(TSNeverKeyword),
43    #[tag("TSNullKeyword")]
44    NullKeyword(TSNullKeyword),
45    #[tag("TSNumberKeyword")]
46    NumberKeyword(TSNumberKeyword),
47    #[tag("TSObjectKeyword")]
48    ObjectKeyword(TSObjectKeyword),
49    #[tag("TSStringKeyword")]
50    StringKeyword(TSStringKeyword),
51    #[tag("TSSymbolKeyword")]
52    SymbolKeyword(TSSymbolKeyword),
53    #[tag("TSUndefinedKeyword")]
54    UndefinedKeyword(TSUndefinedKeyword),
55    #[tag("TSUnknownKeyword")]
56    UnknownKeyword(TSUnknownKeyword),
57    #[tag("TSVoidKeyword")]
58    VoidKeyword(TSVoidKeyword),
59    #[tag("TSThisType")]
60    This(TSThisType),
61    #[tag("TSFunctionType")]
62    Function(TSFunctionType),
63    #[tag("TSConstructorType")]
64    Constructor(TSConstructorType),
65    #[tag("TSTypeReference")]
66    TypeRef(TSTypeReference),
67    #[tag("TSTypePredicate")]
68    TypePredicate(TSTypePredicate),
69    #[tag("TSTypeQuery")]
70    TypeQuery(TSTypeQuery),
71    #[tag("TSTypeLiteral")]
72    TypeLiteral(TSTypeLiteral),
73    #[tag("TSArrayType")]
74    Array(TSArrayType),
75    #[tag("TSTupleType")]
76    Tuple(TSTupleType),
77    #[tag("TSOptionalType")]
78    Optional(TSOptionalType),
79    #[tag("TSRestType")]
80    Rest(TSRestType),
81    #[tag("TSUnionType")]
82    Union(TSUnionType),
83    #[tag("TSIntersectionType")]
84    Intersection(TSIntersectionType),
85    #[tag("TSConditionalType")]
86    Conditional(TSConditionalType),
87    #[tag("TSInferType")]
88    Infer(TSInferType),
89    #[tag("TSParenthesizedType")]
90    Parenthesized(TSParenthesizedType),
91    #[tag("TSTypeOperator")]
92    TypeOp(TSTypeOperator),
93    #[tag("TSIndexedAccessType")]
94    IndexedAccess(TSIndexedAccessType),
95    #[tag("TSMappedType")]
96    Mapped(TSMappedType),
97    #[tag("TSLiteralType")]
98    Literal(TSLiteralType),
99    #[tag("TSExpressionWithTypeArguments")]
100    ExprWithArgs(TSExpressionWithTypeArguments),
101    #[tag("TSImportType")]
102    Import(TSImportType),
103}
104
105#[derive(Debug, Clone, PartialEq)]
106#[ast_serde]
107pub enum TSBaseType {
108    #[tag("TSAnyKeyword")]
109    Any(TSAnyKeyword),
110    #[tag("TSBooleanKeyword")]
111    Boolean(TSBooleanKeyword),
112    #[tag("TSBigIntKeyword")]
113    BigInt(TSBigIntKeyword),
114    #[tag("TSIntrinsicKeyword")]
115    Intrinsic(TSIntrinsicKeyword),
116    #[tag("TSNeverKeyword")]
117    Never(TSNeverKeyword),
118    #[tag("TSNullKeyword")]
119    Null(TSNullKeyword),
120    #[tag("TSNumberKeyword")]
121    Number(TSNumberKeyword),
122    #[tag("TSObjectKeyword")]
123    Object(TSObjectKeyword),
124    #[tag("TSStringKeyword")]
125    String(TSStringKeyword),
126    #[tag("TSSymbolKeyword")]
127    Symbol(TSSymbolKeyword),
128    #[tag("TSUndefinedKeyword")]
129    Undefined(TSUndefinedKeyword),
130    #[tag("TSUnknownKeyword")]
131    Unknown(TSUnknownKeyword),
132    #[tag("TSVoidKeyword")]
133    Void(TSVoidKeyword),
134    #[tag("TSThisType")]
135    This(TSThisType),
136    #[tag("TSLiteralType")]
137    Literal(TSLiteralType),
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
141#[serde(rename_all = "camelCase")]
142#[serde(tag = "type")]
143pub struct TSTypeAnnotation {
144    #[serde(flatten)]
145    pub base: BaseNode,
146    pub type_annotation: TSType,
147}
148
149#[derive(Debug, Clone, PartialEq)]
150#[ast_serde]
151pub enum TSParamPropParam {
152    #[tag("Identifier")]
153    Id(Identifier),
154    #[tag("AssignmentPattern")]
155    Assignment(AssignmentPattern),
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
159#[serde(tag = "type")]
160pub struct TSParameterProperty {
161    #[serde(flatten)]
162    pub base: BaseNode,
163    pub parameter: TSParamPropParam,
164    #[serde(default)]
165    pub accessibility: Option<Access>,
166    #[serde(default)]
167    pub readonly: Option<bool>,
168}
169
170#[derive(Debug, Clone, PartialEq)]
171#[ast_serde]
172pub enum TSFuncDeclTypeParams {
173    #[tag("TSTypeParameterDeclaration")]
174    Type(TSTypeParameterDeclaration),
175    #[tag("Noop")]
176    Noop(Noop),
177}
178
179#[derive(Debug, Clone, PartialEq)]
180#[ast_serde]
181pub enum TSFuncDeclTypeAnnot {
182    #[tag("TSTypeAnnotation")]
183    Type(Box<TSTypeAnnotation>),
184    #[tag("Noop")]
185    Noop(Noop),
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
189#[serde(rename_all = "camelCase")]
190#[serde(tag = "type")]
191pub struct TSDeclareFunction {
192    #[serde(flatten)]
193    pub base: BaseNode,
194    #[serde(default)]
195    pub id: Option<Identifier>,
196    #[serde(default)]
197    pub type_parameters: Option<TSFuncDeclTypeParams>,
198    #[serde(default)]
199    pub params: Vec<Param>,
200    #[serde(default)]
201    pub return_type: Option<TSFuncDeclTypeAnnot>,
202    #[serde(default, rename = "async")]
203    pub is_async: Option<bool>,
204    #[serde(default)]
205    pub declare: Option<bool>,
206    #[serde(default)]
207    pub generator: Option<bool>,
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
211#[serde(rename_all = "camelCase")]
212#[serde(tag = "type")]
213pub struct TSDeclareMethod {
214    #[serde(flatten)]
215    pub base: BaseNode,
216    #[serde(default)]
217    pub decorators: Option<Vec<Decorator>>,
218    pub key: ObjectKey,
219    #[serde(default)]
220    pub type_parameters: Option<TSFuncDeclTypeParams>,
221    #[serde(default)]
222    pub params: Vec<Param>,
223    #[serde(default)]
224    pub return_type: Option<TSFuncDeclTypeAnnot>,
225    #[serde(default, rename = "abstract")]
226    pub is_abstract: Option<bool>,
227    #[serde(default)]
228    pub access: Option<Access>,
229    #[serde(default)]
230    pub accessibility: Option<Access>,
231    #[serde(default, rename = "async")]
232    pub is_async: Option<bool>,
233    #[serde(default)]
234    pub computed: Option<bool>,
235    #[serde(default)]
236    pub generator: Option<bool>,
237    #[serde(default)]
238    pub kind: Option<ClassMethodKind>,
239    #[serde(default)]
240    pub optional: Option<bool>,
241    #[serde(default, rename = "static")]
242    pub is_static: Option<bool>,
243}
244
245#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
246#[serde(tag = "type")]
247pub struct TSQualifiedName {
248    #[serde(flatten)]
249    pub base: BaseNode,
250    pub left: Box<TSEntityName>,
251    pub right: Identifier,
252}
253
254#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
255#[serde(rename_all = "camelCase")]
256#[serde(tag = "type")]
257pub struct TSCallSignatureDeclaration {
258    #[serde(flatten)]
259    pub base: BaseNode,
260    #[serde(default)]
261    pub type_parameters: Option<TSTypeParameterDeclaration>,
262    #[serde(default)]
263    pub parameters: Vec<IdOrRest>,
264    #[serde(default)]
265    pub type_annotation: Option<Box<TSTypeAnnotation>>,
266}
267
268#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
269#[serde(rename_all = "camelCase")]
270#[serde(tag = "type")]
271pub struct TSConstructSignatureDeclaration {
272    #[serde(flatten)]
273    pub base: BaseNode,
274    #[serde(default)]
275    pub type_parameters: Option<TSTypeParameterDeclaration>,
276    #[serde(default)]
277    pub parameters: Vec<IdOrRest>,
278    #[serde(default)]
279    pub type_annotation: Option<Box<TSTypeAnnotation>>,
280}
281
282#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
283#[serde(rename_all = "camelCase")]
284#[serde(tag = "type")]
285pub struct TSPropertySignature {
286    #[serde(flatten)]
287    pub base: BaseNode,
288    pub key: Box<Expression>,
289    #[serde(default)]
290    pub type_annotation: Option<Box<TSTypeAnnotation>>,
291    #[serde(default)]
292    pub computed: Option<bool>,
293    #[serde(default)]
294    pub optional: Option<bool>,
295    #[serde(default)]
296    pub readonly: Option<bool>,
297}
298
299#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
300#[serde(rename_all = "camelCase")]
301#[serde(tag = "type")]
302pub struct TSMethodSignature {
303    #[serde(flatten)]
304    pub base: BaseNode,
305    pub key: Box<Expression>,
306    #[serde(default)]
307    pub type_parameters: Option<TSTypeParameterDeclaration>,
308    #[serde(default)]
309    pub parameters: Vec<IdOrRest>,
310    #[serde(default)]
311    pub type_annotation: Option<Box<TSTypeAnnotation>>,
312    #[serde(default)]
313    pub computed: Option<bool>,
314    #[serde(default)]
315    pub optional: Option<bool>,
316}
317
318#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
319#[serde(rename_all = "camelCase")]
320#[serde(tag = "type")]
321pub struct TSIndexSignature {
322    #[serde(flatten)]
323    pub base: BaseNode,
324    #[serde(default)]
325    pub parameters: Vec<Identifier>,
326    #[serde(default)]
327    pub type_annotation: Option<Box<TSTypeAnnotation>>,
328    #[serde(default)]
329    pub readonly: Option<bool>,
330}
331
332#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
333#[serde(tag = "type")]
334pub struct TSAnyKeyword {
335    #[serde(flatten)]
336    pub base: BaseNode,
337}
338
339#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
340#[serde(tag = "type")]
341pub struct TSBooleanKeyword {
342    #[serde(flatten)]
343    pub base: BaseNode,
344}
345
346#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
347#[serde(tag = "type")]
348pub struct TSBigIntKeyword {
349    #[serde(flatten)]
350    pub base: BaseNode,
351}
352
353#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
354#[serde(tag = "type")]
355pub struct TSIntrinsicKeyword {
356    #[serde(flatten)]
357    pub base: BaseNode,
358}
359
360#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
361#[serde(tag = "type")]
362pub struct TSNeverKeyword {
363    #[serde(flatten)]
364    pub base: BaseNode,
365}
366
367#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
368#[serde(tag = "type")]
369pub struct TSNullKeyword {
370    #[serde(flatten)]
371    pub base: BaseNode,
372}
373
374#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
375#[serde(tag = "type")]
376pub struct TSNumberKeyword {
377    #[serde(flatten)]
378    pub base: BaseNode,
379}
380
381#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
382#[serde(tag = "type")]
383pub struct TSObjectKeyword {
384    #[serde(flatten)]
385    pub base: BaseNode,
386}
387
388#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
389#[serde(tag = "type")]
390pub struct TSStringKeyword {
391    #[serde(flatten)]
392    pub base: BaseNode,
393}
394
395#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
396#[serde(tag = "type")]
397pub struct TSSymbolKeyword {
398    #[serde(flatten)]
399    pub base: BaseNode,
400}
401
402#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
403#[serde(tag = "type")]
404pub struct TSUndefinedKeyword {
405    #[serde(flatten)]
406    pub base: BaseNode,
407}
408
409#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
410#[serde(tag = "type")]
411pub struct TSUnknownKeyword {
412    #[serde(flatten)]
413    pub base: BaseNode,
414}
415
416#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
417#[serde(tag = "type")]
418pub struct TSVoidKeyword {
419    #[serde(flatten)]
420    pub base: BaseNode,
421}
422
423#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
424#[serde(tag = "type")]
425pub struct TSThisType {
426    #[serde(flatten)]
427    pub base: BaseNode,
428}
429
430#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
431#[serde(tag = "type")]
432pub struct TSFunctionType {
433    #[serde(flatten)]
434    pub base: BaseNode,
435    #[serde(default)]
436    pub type_parameters: Option<TSTypeParameterDeclaration>,
437    #[serde(default)]
438    pub parameters: Vec<IdOrRest>,
439    #[serde(default)]
440    pub type_annotation: Option<Box<TSTypeAnnotation>>,
441}
442
443#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
444#[serde(rename_all = "camelCase")]
445#[serde(tag = "type")]
446pub struct TSConstructorType {
447    #[serde(flatten)]
448    pub base: BaseNode,
449    #[serde(default)]
450    pub type_parameters: Option<TSTypeParameterDeclaration>,
451    #[serde(default)]
452    pub parameters: Vec<IdOrRest>,
453    #[serde(default)]
454    pub type_annotation: Option<Box<TSTypeAnnotation>>,
455    #[serde(default, rename = "abstract")]
456    pub is_abstract: Option<bool>,
457}
458
459#[derive(Debug, Clone, PartialEq)]
460#[ast_serde]
461pub enum TSEntityName {
462    #[tag("Identifier")]
463    Id(Identifier),
464    #[tag("TSQualifiedName")]
465    Qualified(TSQualifiedName),
466}
467
468#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
469#[serde(rename_all = "camelCase")]
470#[serde(tag = "type")]
471pub struct TSTypeReference {
472    #[serde(flatten)]
473    pub base: BaseNode,
474    pub type_name: TSEntityName,
475    #[serde(default)]
476    pub type_parameters: Option<TSTypeParameterInstantiation>,
477}
478
479#[derive(Debug, Clone, PartialEq)]
480#[ast_serde]
481pub enum TSTypePredicateParamName {
482    #[tag("Identifier")]
483    Id(Identifier),
484    #[tag("TSThisType")]
485    This(TSThisType),
486}
487
488#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
489#[serde(rename_all = "camelCase")]
490#[serde(tag = "type")]
491pub struct TSTypePredicate {
492    #[serde(flatten)]
493    pub base: BaseNode,
494    pub parameter_name: TSTypePredicateParamName,
495    #[serde(default)]
496    pub type_annotation: Option<Box<TSTypeAnnotation>>,
497    #[serde(default)]
498    pub asserts: Option<bool>,
499}
500
501#[derive(Debug, Clone, PartialEq)]
502#[ast_serde]
503pub enum TSTypeQueryExprName {
504    #[tag("Identifier")]
505    #[tag("TSQualifiedName")]
506    EntityName(TSEntityName),
507    #[tag("TSImportType")]
508    ImportType(TSImportType),
509}
510
511#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
512#[serde(rename_all = "camelCase")]
513#[serde(tag = "type")]
514pub struct TSTypeQuery {
515    #[serde(flatten)]
516    pub base: BaseNode,
517    pub expr_name: TSTypeQueryExprName,
518}
519
520#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
521#[serde(tag = "type")]
522pub struct TSTypeLiteral {
523    #[serde(flatten)]
524    pub base: BaseNode,
525    #[serde(default)]
526    pub members: Vec<TSTypeElement>,
527}
528
529#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
530#[serde(rename_all = "camelCase")]
531#[serde(tag = "type")]
532pub struct TSArrayType {
533    #[serde(flatten)]
534    pub base: BaseNode,
535    pub element_type: Box<TSType>,
536}
537
538#[derive(Debug, Clone, PartialEq)]
539#[ast_serde]
540pub enum TSTupleTypeElType {
541    #[tag("TSNamedTupleMember")]
542    Member(TSNamedTupleMember),
543    #[tag("*")]
544    TSType(TSType),
545}
546
547#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
548#[serde(rename_all = "camelCase")]
549#[serde(tag = "type")]
550pub struct TSTupleType {
551    #[serde(flatten)]
552    pub base: BaseNode,
553    #[serde(default)]
554    pub element_types: Vec<TSTupleTypeElType>,
555}
556
557#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
558#[serde(rename_all = "camelCase")]
559#[serde(tag = "type")]
560pub struct TSOptionalType {
561    #[serde(flatten)]
562    pub base: BaseNode,
563    pub type_annotation: Box<TSType>,
564}
565
566#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
567#[serde(rename_all = "camelCase")]
568#[serde(tag = "type")]
569pub struct TSRestType {
570    #[serde(flatten)]
571    pub base: BaseNode,
572    pub type_annotation: Box<TSType>,
573}
574
575#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
576#[serde(rename_all = "camelCase")]
577#[serde(tag = "type")]
578pub struct TSNamedTupleMember {
579    #[serde(flatten)]
580    pub base: BaseNode,
581    pub label: Identifier,
582    pub element_type: TSType,
583    #[serde(default)]
584    pub optional: bool,
585}
586
587#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
588#[serde(tag = "type")]
589pub struct TSUnionType {
590    #[serde(flatten)]
591    pub base: BaseNode,
592    #[serde(default)]
593    pub types: Vec<TSType>,
594}
595
596#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
597#[serde(tag = "type")]
598pub struct TSIntersectionType {
599    #[serde(flatten)]
600    pub base: BaseNode,
601    #[serde(default)]
602    pub types: Vec<TSType>,
603}
604
605#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
606#[serde(rename_all = "camelCase")]
607#[serde(tag = "type")]
608pub struct TSConditionalType {
609    #[serde(flatten)]
610    pub base: BaseNode,
611    pub check_type: Box<TSType>,
612    pub extends_type: Box<TSType>,
613    pub true_type: Box<TSType>,
614    pub false_type: Box<TSType>,
615}
616
617#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
618#[serde(rename_all = "camelCase")]
619#[serde(tag = "type")]
620pub struct TSInferType {
621    #[serde(flatten)]
622    pub base: BaseNode,
623    pub type_parameter: Box<TSTypeParameter>,
624}
625
626#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
627#[serde(rename_all = "camelCase")]
628#[serde(tag = "type")]
629pub struct TSParenthesizedType {
630    #[serde(flatten)]
631    pub base: BaseNode,
632    pub type_annotation: Box<TSType>,
633}
634
635#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
636#[serde(rename_all = "camelCase")]
637#[serde(tag = "type")]
638pub struct TSTypeOperator {
639    #[serde(flatten)]
640    pub base: BaseNode,
641    pub type_annotation: Box<TSType>,
642    #[serde(default)]
643    pub operator: Atom,
644}
645
646#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
647#[serde(rename_all = "camelCase")]
648#[serde(tag = "type")]
649pub struct TSIndexedAccessType {
650    #[serde(flatten)]
651    pub base: BaseNode,
652    pub object_type: Box<TSType>,
653    pub index_type: Box<TSType>,
654}
655
656#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
657#[serde(rename_all = "camelCase")]
658#[serde(tag = "type")]
659pub struct TSMappedType {
660    #[serde(flatten)]
661    pub base: BaseNode,
662    pub type_parameter: Box<TSTypeParameter>,
663    #[serde(default)]
664    pub type_annotation: Option<Box<TSType>>,
665    #[serde(default)]
666    pub name_type: Option<Box<TSType>>,
667    #[serde(default)]
668    pub optional: Option<bool>,
669    #[serde(default)]
670    pub readonly: Option<bool>,
671}
672
673#[derive(Debug, Clone, PartialEq)]
674#[ast_serde]
675pub enum TSLiteralTypeLiteral {
676    #[tag("NumericLiteral")]
677    Numeric(NumericLiteral),
678    #[tag("StringLiteral")]
679    String(StringLiteral),
680    #[tag("BooleanLiteral")]
681    Boolean(BooleanLiteral),
682    #[tag("BigIntLiteral")]
683    BigInt(BigIntLiteral),
684}
685
686#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
687#[serde(tag = "type")]
688pub struct TSLiteralType {
689    #[serde(flatten)]
690    pub base: BaseNode,
691    pub literal: TSLiteralTypeLiteral,
692}
693
694#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
695#[serde(rename_all = "camelCase")]
696#[serde(tag = "type")]
697pub struct TSExpressionWithTypeArguments {
698    #[serde(flatten)]
699    pub base: BaseNode,
700    pub expression: TSEntityName,
701    #[serde(default)]
702    pub type_parameters: Option<TSTypeParameterInstantiation>,
703}
704
705#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
706#[serde(rename_all = "camelCase")]
707#[serde(tag = "type")]
708pub struct TSInterfaceDeclaration {
709    #[serde(flatten)]
710    pub base: BaseNode,
711    pub id: Identifier,
712    #[serde(default)]
713    pub type_parameters: Option<TSTypeParameterDeclaration>,
714    #[serde(default)]
715    pub extends: Option<TSExpressionWithTypeArguments>,
716    pub body: TSInterfaceBody,
717    #[serde(default)]
718    pub declare: Option<bool>,
719}
720
721#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
722#[serde(tag = "type")]
723pub struct TSInterfaceBody {
724    #[serde(flatten)]
725    pub base: BaseNode,
726    #[serde(default)]
727    pub body: Vec<TSTypeElement>,
728}
729
730#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
731#[serde(rename_all = "camelCase")]
732#[serde(tag = "type")]
733pub struct TSTypeAliasDeclaration {
734    #[serde(flatten)]
735    pub base: BaseNode,
736    pub id: Identifier,
737    #[serde(default)]
738    pub type_parameters: Option<TSTypeParameterDeclaration>,
739    pub type_annotation: TSType,
740    #[serde(default)]
741    pub declare: Option<bool>,
742}
743
744#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
745#[serde(rename_all = "camelCase")]
746#[serde(tag = "type")]
747pub struct TSAsExpression {
748    #[serde(flatten)]
749    pub base: BaseNode,
750    pub expression: Box<Expression>,
751    pub type_annotation: TSType,
752}
753
754#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
755#[serde(rename_all = "camelCase")]
756#[serde(tag = "type")]
757pub struct TSTypeAssertion {
758    #[serde(flatten)]
759    pub base: BaseNode,
760    pub type_annotation: TSType,
761    pub expression: Box<Expression>,
762}
763
764#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
765#[serde(tag = "type")]
766pub struct TSEnumDeclaration {
767    #[serde(flatten)]
768    pub base: BaseNode,
769    pub id: Identifier,
770    #[serde(default)]
771    pub members: Vec<TSEnumMember>,
772    #[serde(default, rename = "const")]
773    pub is_const: Option<bool>,
774    #[serde(default)]
775    pub declare: Option<bool>,
776    #[serde(default)]
777    pub initializer: Option<Box<Expression>>,
778}
779
780#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
781#[serde(tag = "type")]
782pub struct TSEnumMember {
783    #[serde(flatten)]
784    pub base: BaseNode,
785    pub id: IdOrString,
786    #[serde(default)]
787    pub initializer: Option<Box<Expression>>,
788}
789
790#[derive(Debug, Clone, PartialEq)]
791#[ast_serde]
792pub enum TSModuleDeclBody {
793    #[tag("TSModuleBlock")]
794    Block(TSModuleBlock),
795    #[tag("TSModuleDeclaration")]
796    Decl(TSModuleDeclaration),
797}
798
799#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
800#[serde(tag = "type")]
801pub struct TSModuleDeclaration {
802    #[serde(flatten)]
803    pub base: BaseNode,
804    pub id: IdOrString,
805    pub body: Box<TSModuleDeclBody>,
806    #[serde(default)]
807    pub declare: Option<bool>,
808    #[serde(default)]
809    pub global: Option<bool>,
810}
811
812#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
813#[serde(tag = "type")]
814pub struct TSModuleBlock {
815    #[serde(flatten)]
816    pub base: BaseNode,
817    #[serde(default)]
818    pub body: Vec<Statement>,
819}
820
821#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
822#[serde(rename_all = "camelCase")]
823#[serde(tag = "type")]
824pub struct TSImportType {
825    #[serde(flatten)]
826    pub base: BaseNode,
827    pub argument: StringLiteral,
828    #[serde(default)]
829    pub qualifier: Option<TSEntityName>,
830    #[serde(default)]
831    pub type_parameters: Option<TSTypeParameterInstantiation>,
832}
833
834#[derive(Debug, Clone, PartialEq)]
835#[ast_serde]
836pub enum TSImportEqualsDeclModuleRef {
837    #[tag("Identifier")]
838    #[tag("TSQualifiedName")]
839    Name(TSEntityName),
840    #[tag("TSExternalModuleReference")]
841    External(TSExternalModuleReference),
842}
843
844#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
845#[serde(rename_all = "camelCase")]
846#[serde(tag = "type")]
847pub struct TSImportEqualsDeclaration {
848    #[serde(flatten)]
849    pub base: BaseNode,
850    pub id: Identifier,
851    pub module_reference: TSImportEqualsDeclModuleRef,
852    #[serde(default)]
853    pub is_export: bool,
854}
855
856#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
857#[serde(tag = "type")]
858pub struct TSExternalModuleReference {
859    #[serde(flatten)]
860    pub base: BaseNode,
861    pub expression: StringLiteral,
862}
863
864#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
865#[serde(tag = "type")]
866pub struct TSNonNullExpression {
867    #[serde(flatten)]
868    pub base: BaseNode,
869    pub expression: Box<Expression>,
870}
871
872#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
873#[serde(tag = "type")]
874pub struct TSExportAssignment {
875    #[serde(flatten)]
876    pub base: BaseNode,
877    pub expression: Box<Expression>,
878}
879
880#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
881#[serde(tag = "type")]
882pub struct TSNamespaceExportDeclaration {
883    #[serde(flatten)]
884    pub base: BaseNode,
885    pub id: Identifier,
886}
887
888#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
889#[serde(tag = "type")]
890pub struct TSTypeParameterInstantiation {
891    #[serde(flatten)]
892    pub base: BaseNode,
893    #[serde(default)]
894    pub params: Vec<TSType>,
895}
896
897#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
898#[serde(tag = "type")]
899pub struct TSTypeParameterDeclaration {
900    #[serde(flatten)]
901    pub base: BaseNode,
902    pub params: Vec<TSTypeParameter>,
903}
904
905#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
906#[serde(tag = "type")]
907pub struct TSTypeParameter {
908    #[serde(flatten)]
909    pub base: BaseNode,
910    #[serde(default)]
911    pub constraint: Option<Box<TSType>>,
912    #[serde(default)]
913    pub default: Option<Box<TSType>>,
914    #[serde(default)]
915    pub name: Atom,
916
917    #[serde(default, rename = "in")]
918    pub is_in: bool,
919    #[serde(default, rename = "out")]
920    pub is_out: bool,
921    #[serde(default, rename = "const")]
922    pub is_const: bool,
923}