1#![expect(
14 missing_docs, clippy::enum_variant_names,
16)]
17
18use std::cell::Cell;
23
24use oxc_allocator::{Box, CloneIn, Dummy, GetAddress, TakeIn, Vec};
25use oxc_ast_macros::ast;
26use oxc_estree::ESTree;
27use oxc_span::{Atom, ContentEq, GetSpan, GetSpanMut, Span};
28use oxc_syntax::scope::ScopeId;
29
30use super::{inherit_variants, js::*, literal::*};
31
32#[ast(visit)]
43#[derive(Debug)]
44#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
45#[estree(
46 rename = "Identifier",
47 add_fields(decorators = EmptyArray, name = This, optional = False),
48 field_order(decorators, name, optional, type_annotation, span),
49)]
50pub struct TSThisParameter<'a> {
51 pub span: Span,
52 #[estree(skip)]
53 pub this_span: Span,
54 pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
56}
57
58#[ast(visit)]
79#[scope]
80#[derive(Debug)]
81#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
82pub struct TSEnumDeclaration<'a> {
83 pub span: Span,
84 pub id: BindingIdentifier<'a>,
85 #[scope(enter_before)]
86 pub body: TSEnumBody<'a>,
87 pub r#const: bool,
89 pub declare: bool,
90 pub scope_id: Cell<Option<ScopeId>>,
91}
92
93#[ast(visit)]
106#[derive(Debug)]
107#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
108pub struct TSEnumBody<'a> {
109 pub span: Span,
110 pub members: Vec<'a, TSEnumMember<'a>>,
111}
112
113#[ast(visit)]
131#[derive(Debug)]
132#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
133#[estree(add_fields(computed = TSEnumMemberComputed))]
134pub struct TSEnumMember<'a> {
135 pub span: Span,
136 pub id: TSEnumMemberName<'a>,
137 pub initializer: Option<Expression<'a>>,
138}
139
140#[ast(visit)]
155#[derive(Debug)]
156#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
157pub enum TSEnumMemberName<'a> {
158 Identifier(Box<'a, IdentifierName<'a>>) = 0,
159 String(Box<'a, StringLiteral<'a>>) = 1,
160 ComputedString(Box<'a, StringLiteral<'a>>) = 2,
161 ComputedTemplateString(Box<'a, TemplateLiteral<'a>>) = 3,
162}
163
164#[ast(visit)]
177#[derive(Debug)]
178#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
179pub struct TSTypeAnnotation<'a> {
180 pub span: Span,
182 pub type_annotation: TSType<'a>,
184}
185
186#[ast(visit)]
201#[derive(Debug)]
202#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
203pub struct TSLiteralType<'a> {
204 pub span: Span,
205 pub literal: TSLiteral<'a>,
206}
207
208#[ast(visit)]
210#[derive(Debug)]
211#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
212pub enum TSLiteral<'a> {
213 BooleanLiteral(Box<'a, BooleanLiteral>) = 0,
214 NumericLiteral(Box<'a, NumericLiteral<'a>>) = 1,
215 BigIntLiteral(Box<'a, BigIntLiteral<'a>>) = 2,
216 StringLiteral(Box<'a, StringLiteral<'a>>) = 3,
217 TemplateLiteral(Box<'a, TemplateLiteral<'a>>) = 4,
218 UnaryExpression(Box<'a, UnaryExpression<'a>>) = 5,
219}
220
221#[ast(visit)]
233#[derive(Debug)]
234#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
235pub enum TSType<'a> {
236 TSAnyKeyword(Box<'a, TSAnyKeyword>) = 0,
238 TSBigIntKeyword(Box<'a, TSBigIntKeyword>) = 1,
239 TSBooleanKeyword(Box<'a, TSBooleanKeyword>) = 2,
240 TSIntrinsicKeyword(Box<'a, TSIntrinsicKeyword>) = 3,
241 TSNeverKeyword(Box<'a, TSNeverKeyword>) = 4,
242 TSNullKeyword(Box<'a, TSNullKeyword>) = 5,
243 TSNumberKeyword(Box<'a, TSNumberKeyword>) = 6,
244 TSObjectKeyword(Box<'a, TSObjectKeyword>) = 7,
245 TSStringKeyword(Box<'a, TSStringKeyword>) = 8,
246 TSSymbolKeyword(Box<'a, TSSymbolKeyword>) = 9,
247 TSUndefinedKeyword(Box<'a, TSUndefinedKeyword>) = 11,
248 TSUnknownKeyword(Box<'a, TSUnknownKeyword>) = 12,
249 TSVoidKeyword(Box<'a, TSVoidKeyword>) = 13,
250 TSArrayType(Box<'a, TSArrayType<'a>>) = 14,
252 TSConditionalType(Box<'a, TSConditionalType<'a>>) = 15,
253 TSConstructorType(Box<'a, TSConstructorType<'a>>) = 16,
254 TSFunctionType(Box<'a, TSFunctionType<'a>>) = 17,
255 TSImportType(Box<'a, TSImportType<'a>>) = 18,
256 TSIndexedAccessType(Box<'a, TSIndexedAccessType<'a>>) = 19,
257 TSInferType(Box<'a, TSInferType<'a>>) = 20,
258 TSIntersectionType(Box<'a, TSIntersectionType<'a>>) = 21,
259 TSLiteralType(Box<'a, TSLiteralType<'a>>) = 22,
260 TSMappedType(Box<'a, TSMappedType<'a>>) = 23,
261 TSNamedTupleMember(Box<'a, TSNamedTupleMember<'a>>) = 24,
262 TSTemplateLiteralType(Box<'a, TSTemplateLiteralType<'a>>) = 26,
263 TSThisType(Box<'a, TSThisType>) = 10,
264 TSTupleType(Box<'a, TSTupleType<'a>>) = 27,
265 TSTypeLiteral(Box<'a, TSTypeLiteral<'a>>) = 28,
266 TSTypeOperatorType(Box<'a, TSTypeOperator<'a>>) = 29,
267 TSTypePredicate(Box<'a, TSTypePredicate<'a>>) = 30,
268 TSTypeQuery(Box<'a, TSTypeQuery<'a>>) = 31,
269 TSTypeReference(Box<'a, TSTypeReference<'a>>) = 32,
270 TSUnionType(Box<'a, TSUnionType<'a>>) = 33,
271 TSParenthesizedType(Box<'a, TSParenthesizedType<'a>>) = 34,
272 JSDocNullableType(Box<'a, JSDocNullableType<'a>>) = 35,
274 JSDocNonNullableType(Box<'a, JSDocNonNullableType<'a>>) = 36,
275 JSDocUnknownType(Box<'a, JSDocUnknownType>) = 37,
276}
277
278#[macro_export]
280macro_rules! match_ts_type {
281 ($ty:ident) => {
282 $ty::TSAnyKeyword(_)
283 | $ty::TSBigIntKeyword(_)
284 | $ty::TSBooleanKeyword(_)
285 | $ty::TSIntrinsicKeyword(_)
286 | $ty::TSNeverKeyword(_)
287 | $ty::TSNullKeyword(_)
288 | $ty::TSNumberKeyword(_)
289 | $ty::TSObjectKeyword(_)
290 | $ty::TSStringKeyword(_)
291 | $ty::TSSymbolKeyword(_)
292 | $ty::TSThisType(_)
293 | $ty::TSUndefinedKeyword(_)
294 | $ty::TSUnknownKeyword(_)
295 | $ty::TSVoidKeyword(_)
296 | $ty::TSArrayType(_)
297 | $ty::TSConditionalType(_)
298 | $ty::TSConstructorType(_)
299 | $ty::TSFunctionType(_)
300 | $ty::TSImportType(_)
301 | $ty::TSIndexedAccessType(_)
302 | $ty::TSInferType(_)
303 | $ty::TSIntersectionType(_)
304 | $ty::TSLiteralType(_)
305 | $ty::TSMappedType(_)
306 | $ty::TSNamedTupleMember(_)
307 | $ty::TSTemplateLiteralType(_)
308 | $ty::TSTupleType(_)
309 | $ty::TSTypeLiteral(_)
310 | $ty::TSTypeOperatorType(_)
311 | $ty::TSTypePredicate(_)
312 | $ty::TSTypeQuery(_)
313 | $ty::TSTypeReference(_)
314 | $ty::TSUnionType(_)
315 | $ty::TSParenthesizedType(_)
316 | $ty::JSDocNullableType(_)
317 | $ty::JSDocNonNullableType(_)
318 | $ty::JSDocUnknownType(_)
319 };
320}
321pub use match_ts_type;
322
323#[ast(visit)]
337#[scope(flags = ScopeFlags::TsConditional)]
338#[derive(Debug)]
339#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
340pub struct TSConditionalType<'a> {
341 pub span: Span,
342 pub check_type: TSType<'a>,
344 #[scope(enter_before)]
346 pub extends_type: TSType<'a>,
347 pub true_type: TSType<'a>,
349 #[scope(exit_before)]
351 pub false_type: TSType<'a>,
352 pub scope_id: Cell<Option<ScopeId>>,
353}
354
355#[ast(visit)]
365#[derive(Debug)]
366#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
367pub struct TSUnionType<'a> {
368 pub span: Span,
369 pub types: Vec<'a, TSType<'a>>,
371}
372
373#[ast(visit)]
387#[derive(Debug)]
388#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
389pub struct TSIntersectionType<'a> {
390 pub span: Span,
391 pub types: Vec<'a, TSType<'a>>,
392}
393
394#[ast(visit)]
404#[derive(Debug)]
405#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
406#[estree(via = TSParenthesizedTypeConverter)]
407pub struct TSParenthesizedType<'a> {
408 pub span: Span,
409 pub type_annotation: TSType<'a>,
410}
411
412#[ast(visit)]
422#[derive(Debug)]
423#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
424pub struct TSTypeOperator<'a> {
425 pub span: Span,
426 pub operator: TSTypeOperatorOperator,
427 pub type_annotation: TSType<'a>,
429}
430
431#[ast]
433#[derive(Debug, Clone, Copy, PartialEq, Eq)]
434#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
435pub enum TSTypeOperatorOperator {
436 Keyof = 0,
437 Unique = 1,
438 Readonly = 2,
439}
440
441#[ast(visit)]
453#[derive(Debug)]
454#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
455pub struct TSArrayType<'a> {
456 pub span: Span,
457 pub element_type: TSType<'a>,
458}
459
460#[ast(visit)]
472#[derive(Debug)]
473#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
474pub struct TSIndexedAccessType<'a> {
475 pub span: Span,
476 pub object_type: TSType<'a>,
477 pub index_type: TSType<'a>,
478}
479
480#[ast(visit)]
490#[derive(Debug)]
491#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
492pub struct TSTupleType<'a> {
493 pub span: Span,
494 pub element_types: Vec<'a, TSTupleElement<'a>>,
495}
496
497#[ast(visit)]
509#[derive(Debug)]
510#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
511pub struct TSNamedTupleMember<'a> {
512 pub span: Span,
513 pub label: IdentifierName<'a>,
514 pub element_type: TSTupleElement<'a>,
515 pub optional: bool,
516}
517
518#[ast(visit)]
528#[derive(Debug)]
529#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
530pub struct TSOptionalType<'a> {
531 pub span: Span,
532 pub type_annotation: TSType<'a>,
533}
534
535#[ast(visit)]
544#[derive(Debug)]
545#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
546pub struct TSRestType<'a> {
547 pub span: Span,
548 pub type_annotation: TSType<'a>,
549}
550
551inherit_variants! {
552#[ast(visit)]
560#[derive(Debug)]
561#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
562pub enum TSTupleElement<'a> {
563 TSOptionalType(Box<'a, TSOptionalType<'a>>) = 64,
566 TSRestType(Box<'a, TSRestType<'a>>) = 65,
567 @inherit TSType
569}
570}
571
572#[ast(visit)]
582#[derive(Debug)]
583#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
584pub struct TSAnyKeyword {
585 pub span: Span,
586}
587
588#[ast(visit)]
598#[derive(Debug)]
599#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
600pub struct TSStringKeyword {
601 pub span: Span,
602}
603
604#[ast(visit)]
614#[derive(Debug)]
615#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
616pub struct TSBooleanKeyword {
617 pub span: Span,
618}
619
620#[ast(visit)]
630#[derive(Debug)]
631#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
632pub struct TSNumberKeyword {
633 pub span: Span,
634}
635
636#[ast(visit)]
647#[derive(Debug)]
648#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
649pub struct TSNeverKeyword {
650 pub span: Span,
651}
652
653#[ast(visit)]
664#[derive(Debug)]
665#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
666pub struct TSIntrinsicKeyword {
667 pub span: Span,
668}
669
670#[ast(visit)]
682#[derive(Debug)]
683#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
684pub struct TSUnknownKeyword {
685 pub span: Span,
686}
687
688#[ast(visit)]
699#[derive(Debug)]
700#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
701pub struct TSNullKeyword {
702 pub span: Span,
703}
704
705#[ast(visit)]
718#[derive(Debug)]
719#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
720pub struct TSUndefinedKeyword {
721 pub span: Span,
722}
723
724#[ast(visit)]
725#[derive(Debug)]
726#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
727pub struct TSVoidKeyword {
728 pub span: Span,
729}
730
731#[ast(visit)]
732#[derive(Debug)]
733#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
734pub struct TSSymbolKeyword {
735 pub span: Span,
736}
737
738#[ast(visit)]
739#[derive(Debug)]
740#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
741pub struct TSThisType {
742 pub span: Span,
743}
744
745#[ast(visit)]
746#[derive(Debug)]
747#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
748pub struct TSObjectKeyword {
749 pub span: Span,
750}
751
752#[ast(visit)]
753#[derive(Debug)]
754#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
755pub struct TSBigIntKeyword {
756 pub span: Span,
757}
758
759#[ast(visit)]
771#[derive(Debug)]
772#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
773pub struct TSTypeReference<'a> {
774 pub span: Span,
775 pub type_name: TSTypeName<'a>,
776 pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
777}
778
779#[ast(visit)]
784#[derive(Debug)]
785#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
786pub enum TSTypeName<'a> {
787 IdentifierReference(Box<'a, IdentifierReference<'a>>) = 0,
788 QualifiedName(Box<'a, TSQualifiedName<'a>>) = 1,
789 ThisExpression(Box<'a, ThisExpression>) = 2,
790}
791
792#[macro_export]
794macro_rules! match_ts_type_name {
795 ($ty:ident) => {
796 $ty::IdentifierReference(_) | $ty::QualifiedName(_) | $ty::ThisExpression(_)
797 };
798}
799pub use match_ts_type_name;
800
801#[ast(visit)]
811#[derive(Debug)]
812#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
813pub struct TSQualifiedName<'a> {
814 pub span: Span,
815 pub left: TSTypeName<'a>,
816 pub right: IdentifierName<'a>,
817}
818
819#[ast(visit)]
820#[derive(Debug)]
821#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
822pub struct TSTypeParameterInstantiation<'a> {
823 pub span: Span,
824 pub params: Vec<'a, TSType<'a>>,
825}
826
827#[ast(visit)]
845#[derive(Debug)]
846#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
847pub struct TSTypeParameter<'a> {
848 pub span: Span,
849 pub name: BindingIdentifier<'a>,
851 pub constraint: Option<TSType<'a>>,
853 pub default: Option<TSType<'a>>,
855 pub r#in: bool,
857 pub out: bool,
859 pub r#const: bool,
861}
862
863#[ast(visit)]
864#[derive(Debug)]
865#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
866pub struct TSTypeParameterDeclaration<'a> {
867 pub span: Span,
868 pub params: Vec<'a, TSTypeParameter<'a>>,
869}
870
871#[ast(visit)]
880#[scope]
881#[derive(Debug)]
882#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
883pub struct TSTypeAliasDeclaration<'a> {
884 pub span: Span,
885 pub id: BindingIdentifier<'a>,
887 #[scope(enter_before)]
888 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
889 pub type_annotation: TSType<'a>,
890 pub declare: bool,
891 pub scope_id: Cell<Option<ScopeId>>,
892}
893
894#[ast]
895#[derive(Debug, Clone, Copy, PartialEq, Eq)]
896#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
897pub enum TSAccessibility {
898 Private = 0,
899 Protected = 1,
900 Public = 2,
901}
902
903#[ast(visit)]
914#[derive(Debug)]
915#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
916#[plural(TSClassImplementsList)]
917pub struct TSClassImplements<'a> {
918 pub span: Span,
919 #[estree(via = TSClassImplementsExpression)]
920 pub expression: TSTypeName<'a>,
921 pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
922}
923
924#[ast(visit)]
940#[scope]
941#[derive(Debug)]
942#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
943pub struct TSInterfaceDeclaration<'a> {
944 pub span: Span,
945 pub id: BindingIdentifier<'a>,
947 #[scope(enter_before)]
949 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
950 pub extends: Vec<'a, TSInterfaceHeritage<'a>>,
952 pub body: Box<'a, TSInterfaceBody<'a>>,
953 pub declare: bool,
955 pub scope_id: Cell<Option<ScopeId>>,
956}
957
958#[ast(visit)]
960#[derive(Debug)]
961#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
962pub struct TSInterfaceBody<'a> {
963 pub span: Span,
964 pub body: Vec<'a, TSSignature<'a>>,
965}
966
967#[ast(visit)]
983#[derive(Debug)]
984#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
985#[estree(add_fields(accessibility = Null, r#static = False))]
986pub struct TSPropertySignature<'a> {
987 pub span: Span,
988 pub computed: bool,
989 pub optional: bool,
990 pub readonly: bool,
991 pub key: PropertyKey<'a>,
992 pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
993}
994
995#[ast(visit)]
996#[derive(Debug)]
997#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
998pub enum TSSignature<'a> {
999 TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0,
1000 TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1,
1001 TSCallSignatureDeclaration(Box<'a, TSCallSignatureDeclaration<'a>>) = 2,
1002 TSConstructSignatureDeclaration(Box<'a, TSConstructSignatureDeclaration<'a>>) = 3,
1003 TSMethodSignature(Box<'a, TSMethodSignature<'a>>) = 4,
1004}
1005
1006#[ast(visit)]
1018#[derive(Debug)]
1019#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1020#[estree(add_fields(accessibility = Null))]
1021pub struct TSIndexSignature<'a> {
1022 pub span: Span,
1023 pub parameters: Vec<'a, TSIndexSignatureName<'a>>,
1024 pub type_annotation: Box<'a, TSTypeAnnotation<'a>>,
1025 pub readonly: bool,
1026 pub r#static: bool,
1027}
1028
1029#[ast(visit)]
1030#[derive(Debug)]
1031#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1032pub struct TSCallSignatureDeclaration<'a> {
1033 pub span: Span,
1034 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
1035 #[estree(skip)]
1036 pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
1037 #[estree(via = TSCallSignatureDeclarationParams)]
1038 pub params: Box<'a, FormalParameters<'a>>,
1039 pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
1040}
1041
1042#[ast]
1043#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1044#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
1045pub enum TSMethodSignatureKind {
1046 Method = 0,
1047 Get = 1,
1048 Set = 2,
1049}
1050
1051#[ast(visit)]
1063#[scope]
1064#[derive(Debug)]
1065#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1066#[estree(add_fields(accessibility = Null, readonly = False, r#static = False))]
1067pub struct TSMethodSignature<'a> {
1068 pub span: Span,
1069 pub key: PropertyKey<'a>,
1070 pub computed: bool,
1071 pub optional: bool,
1072 pub kind: TSMethodSignatureKind,
1073 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
1074 #[estree(skip)]
1075 pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
1076 #[estree(via = TSMethodSignatureParams)]
1077 pub params: Box<'a, FormalParameters<'a>>,
1078 pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
1079 pub scope_id: Cell<Option<ScopeId>>,
1080}
1081
1082#[ast(visit)]
1084#[scope]
1085#[derive(Debug)]
1086#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1087pub struct TSConstructSignatureDeclaration<'a> {
1088 pub span: Span,
1089 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
1090 pub params: Box<'a, FormalParameters<'a>>,
1091 pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
1092 pub scope_id: Cell<Option<ScopeId>>,
1093}
1094
1095#[ast(visit)]
1096#[derive(Debug)]
1097#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1098#[estree(
1099 rename = "Identifier",
1100 add_fields(decorators = EmptyArray, optional = False),
1101 field_order(decorators, name, optional, type_annotation, span),
1102)]
1103pub struct TSIndexSignatureName<'a> {
1104 pub span: Span,
1105 #[estree(json_safe)]
1106 pub name: Atom<'a>,
1107 pub type_annotation: Box<'a, TSTypeAnnotation<'a>>,
1108}
1109
1110#[ast(visit)]
1111#[derive(Debug)]
1112#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1113pub struct TSInterfaceHeritage<'a> {
1114 pub span: Span,
1115 pub expression: Expression<'a>,
1116 pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
1117}
1118
1119#[ast(visit)]
1140#[derive(Debug)]
1141#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1142pub struct TSTypePredicate<'a> {
1143 pub span: Span,
1144 pub parameter_name: TSTypePredicateName<'a>,
1146 pub asserts: bool,
1153 pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
1154}
1155
1156#[ast(visit)]
1157#[derive(Debug)]
1158#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1159pub enum TSTypePredicateName<'a> {
1160 Identifier(Box<'a, IdentifierName<'a>>) = 0,
1161 This(TSThisType) = 1,
1162}
1163
1164#[ast(visit)]
1191#[scope(
1192 flags = ScopeFlags::TsModuleBlock,
1193 strict_if = self.body.as_ref().is_some_and(TSModuleDeclarationBody::has_use_strict_directive),
1194)]
1195#[derive(Debug)]
1196#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1197#[estree(
1198 via = TSModuleDeclarationConverter,
1199 add_fields(global = TSModuleDeclarationGlobal),
1200)]
1201pub struct TSModuleDeclaration<'a> {
1202 pub span: Span,
1203 #[estree(ts_type = "BindingIdentifier | StringLiteral | TSQualifiedName")]
1207 pub id: TSModuleDeclarationName<'a>,
1208 #[scope(enter_before)]
1209 #[estree(ts_type = "TSModuleBlock | null")]
1210 pub body: Option<TSModuleDeclarationBody<'a>>,
1211 pub kind: TSModuleDeclarationKind,
1225 pub declare: bool,
1226 pub scope_id: Cell<Option<ScopeId>>,
1227}
1228
1229#[ast]
1230#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1231#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
1232pub enum TSModuleDeclarationKind {
1233 Global = 0,
1235 Module = 1,
1237 Namespace = 2,
1239}
1240
1241#[ast(visit)]
1262#[derive(Debug)]
1263#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1264#[estree(no_ts_def)]
1265pub enum TSModuleDeclarationName<'a> {
1266 Identifier(BindingIdentifier<'a>) = 0,
1267 StringLiteral(StringLiteral<'a>) = 1,
1268}
1269
1270#[ast(visit)]
1271#[derive(Debug)]
1272#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1273#[estree(no_ts_def)]
1274pub enum TSModuleDeclarationBody<'a> {
1275 TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0,
1276 TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1,
1277}
1278
1279#[ast(visit)]
1280#[derive(Debug)]
1281#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1282pub struct TSModuleBlock<'a> {
1283 pub span: Span,
1284 #[estree(prepend_to = body)]
1285 pub directives: Vec<'a, Directive<'a>>,
1286 pub body: Vec<'a, Statement<'a>>,
1287}
1288
1289#[ast(visit)]
1290#[derive(Debug)]
1291#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1292pub struct TSTypeLiteral<'a> {
1293 pub span: Span,
1294 pub members: Vec<'a, TSSignature<'a>>,
1295}
1296
1297#[ast(visit)]
1311#[derive(Debug)]
1312#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1313pub struct TSInferType<'a> {
1314 pub span: Span,
1315 pub type_parameter: Box<'a, TSTypeParameter<'a>>,
1317}
1318
1319#[ast(visit)]
1329#[derive(Debug)]
1330#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1331pub struct TSTypeQuery<'a> {
1332 pub span: Span,
1333 pub expr_name: TSTypeQueryExprName<'a>,
1334 pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
1335}
1336
1337inherit_variants! {
1338#[ast(visit)]
1344#[derive(Debug)]
1345#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1346pub enum TSTypeQueryExprName<'a> {
1347 TSImportType(Box<'a, TSImportType<'a>>) = 3,
1349 @inherit TSTypeName
1351}
1352}
1353
1354#[ast(visit)]
1365#[derive(Debug)]
1366#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1367pub struct TSImportType<'a> {
1368 pub span: Span,
1369 pub argument: TSType<'a>,
1370 pub options: Option<Box<'a, ObjectExpression<'a>>>,
1371 pub qualifier: Option<TSImportTypeQualifier<'a>>,
1372 pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
1373}
1374
1375#[ast(visit)]
1384#[derive(Debug)]
1385#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1386pub enum TSImportTypeQualifier<'a> {
1387 Identifier(Box<'a, IdentifierName<'a>>) = 0,
1388 QualifiedName(Box<'a, TSImportTypeQualifiedName<'a>>) = 1,
1389}
1390
1391#[ast(visit)]
1395#[derive(Debug)]
1396#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1397#[estree(rename = "TSQualifiedName")]
1398pub struct TSImportTypeQualifiedName<'a> {
1399 pub span: Span,
1400 pub left: TSImportTypeQualifier<'a>,
1401 pub right: IdentifierName<'a>,
1402}
1403
1404#[ast(visit)]
1413#[scope]
1414#[derive(Debug)]
1415#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1416pub struct TSFunctionType<'a> {
1417 pub span: Span,
1418 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
1425 #[estree(skip)]
1432 pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
1433 #[estree(via = TSFunctionTypeParams)]
1435 pub params: Box<'a, FormalParameters<'a>>,
1436 pub return_type: Box<'a, TSTypeAnnotation<'a>>,
1442
1443 pub scope_id: Cell<Option<ScopeId>>,
1444}
1445
1446#[ast(visit)]
1447#[derive(Debug)]
1448#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1449pub struct TSConstructorType<'a> {
1450 pub span: Span,
1451 pub r#abstract: bool,
1452 pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
1453 pub params: Box<'a, FormalParameters<'a>>,
1454 pub return_type: Box<'a, TSTypeAnnotation<'a>>,
1455}
1456
1457#[ast(visit)]
1479#[scope]
1480#[derive(Debug)]
1481#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1482#[estree(
1483 add_fields(key = TSMappedTypeKey, constraint = TSMappedTypeConstraint),
1484 field_order(key, constraint, name_type, type_annotation, optional, readonly, span),
1485)]
1486pub struct TSMappedType<'a> {
1487 pub span: Span,
1488 #[estree(skip)]
1490 pub type_parameter: Box<'a, TSTypeParameter<'a>>,
1491 pub name_type: Option<TSType<'a>>,
1492 pub type_annotation: Option<TSType<'a>>,
1493 #[estree(via = TSMappedTypeOptional)]
1507 pub optional: Option<TSMappedTypeModifierOperator>,
1508 pub readonly: Option<TSMappedTypeModifierOperator>,
1518 pub scope_id: Cell<Option<ScopeId>>,
1519}
1520
1521#[ast]
1522#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1523#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
1524pub enum TSMappedTypeModifierOperator {
1525 #[estree(via = True)]
1527 True = 0,
1528 #[estree(rename = "+")]
1530 Plus = 1,
1531 #[estree(rename = "-")]
1533 Minus = 2,
1534}
1535
1536#[ast(visit)]
1548#[derive(Debug)]
1549#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1550pub struct TSTemplateLiteralType<'a> {
1551 pub span: Span,
1552 pub quasis: Vec<'a, TemplateElement<'a>>,
1554 pub types: Vec<'a, TSType<'a>>,
1556}
1557
1558#[ast(visit)]
1559#[derive(Debug)]
1560#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1561pub struct TSAsExpression<'a> {
1562 pub span: Span,
1563 pub expression: Expression<'a>,
1564 pub type_annotation: TSType<'a>,
1565}
1566
1567#[ast(visit)]
1580#[derive(Debug)]
1581#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1582pub struct TSSatisfiesExpression<'a> {
1583 pub span: Span,
1584 pub expression: Expression<'a>,
1586 pub type_annotation: TSType<'a>,
1588}
1589
1590#[ast(visit)]
1599#[derive(Debug)]
1600#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1601pub struct TSTypeAssertion<'a> {
1602 pub span: Span,
1603 pub type_annotation: TSType<'a>,
1604 pub expression: Expression<'a>,
1605}
1606
1607#[ast(visit)]
1608#[derive(Debug)]
1609#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1610pub struct TSImportEqualsDeclaration<'a> {
1611 pub span: Span,
1612 pub id: BindingIdentifier<'a>,
1613 pub module_reference: TSModuleReference<'a>,
1614 pub import_kind: ImportOrExportKind,
1615}
1616
1617inherit_variants! {
1618#[ast(visit)]
1624#[derive(Debug)]
1625#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, GetAddress, ContentEq, ESTree)]
1626pub enum TSModuleReference<'a> {
1627 ExternalModuleReference(Box<'a, TSExternalModuleReference<'a>>) = 3,
1628 @inherit TSTypeName
1630}
1631}
1632
1633#[ast(visit)]
1634#[derive(Debug)]
1635#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1636pub struct TSExternalModuleReference<'a> {
1637 pub span: Span,
1638 pub expression: StringLiteral<'a>,
1639}
1640
1641#[ast(visit)]
1642#[derive(Debug)]
1643#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1644pub struct TSNonNullExpression<'a> {
1645 pub span: Span,
1646 pub expression: Expression<'a>,
1647}
1648
1649#[ast(visit)]
1674#[derive(Debug)]
1675#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1676pub struct Decorator<'a> {
1677 pub span: Span,
1678 pub expression: Expression<'a>,
1679}
1680
1681#[ast(visit)]
1685#[derive(Debug)]
1686#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1687pub struct TSExportAssignment<'a> {
1688 pub span: Span,
1689 pub expression: Expression<'a>,
1690}
1691
1692#[ast(visit)]
1696#[derive(Debug)]
1697#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1698pub struct TSNamespaceExportDeclaration<'a> {
1699 pub span: Span,
1700 pub id: IdentifierName<'a>,
1701}
1702
1703#[ast(visit)]
1704#[derive(Debug)]
1705#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1706pub struct TSInstantiationExpression<'a> {
1707 pub span: Span,
1708 pub expression: Expression<'a>,
1709 pub type_arguments: Box<'a, TSTypeParameterInstantiation<'a>>,
1710}
1711
1712#[ast]
1714#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1715#[generate_derive(CloneIn, Dummy, ContentEq, ESTree)]
1716pub enum ImportOrExportKind {
1717 Value = 0,
1719 Type = 1,
1721}
1722
1723#[ast(visit)]
1727#[derive(Debug)]
1728#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1729#[estree(rename = "TSJSDocNullableType")]
1730pub struct JSDocNullableType<'a> {
1731 pub span: Span,
1732 pub type_annotation: TSType<'a>,
1733 pub postfix: bool,
1735}
1736
1737#[ast(visit)]
1739#[derive(Debug)]
1740#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1741#[estree(rename = "TSJSDocNonNullableType")]
1742pub struct JSDocNonNullableType<'a> {
1743 pub span: Span,
1744 pub type_annotation: TSType<'a>,
1745 pub postfix: bool,
1746}
1747
1748#[ast(visit)]
1750#[derive(Debug)]
1751#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
1752#[estree(rename = "TSJSDocUnknownType")]
1753pub struct JSDocUnknownType {
1754 pub span: Span,
1755}