1#![allow(clippy::vec_box)]
2#![allow(missing_copy_implementations)]
3
4#[cfg(feature = "serde-impl")]
5use std::fmt;
6
7use is_macro::Is;
8#[cfg(feature = "serde-impl")]
9use serde::{
10    de::{self, Unexpected, Visitor},
11    Deserialize, Deserializer, Serialize,
12};
13use string_enum::StringEnum;
14use swc_common::{ast_node, EqIgnoreSpan, Span};
15
16use crate::{
17    class::Decorator,
18    expr::{Expr, ObjectLit},
19    ident::Ident,
20    lit::{Bool, Number, Str},
21    module::ModuleItem,
22    pat::{ArrayPat, AssignPat, ObjectPat, Pat, RestPat},
23    BigInt, BindingIdent, IdentName, TplElement,
24};
25
26#[ast_node("TsTypeAnnotation")]
27#[derive(Eq, Hash, EqIgnoreSpan)]
28#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
29#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
30pub struct TsTypeAnn {
31    pub span: Span,
32    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
33    pub type_ann: Box<TsType>,
34}
35
36#[ast_node("TsTypeParameterDeclaration")]
37#[derive(Eq, Hash, EqIgnoreSpan)]
38#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
39#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
40pub struct TsTypeParamDecl {
41    pub span: Span,
42    #[cfg_attr(feature = "serde-impl", serde(rename = "parameters"))]
43    pub params: Vec<TsTypeParam>,
44}
45
46#[ast_node("TsTypeParameter")]
47#[derive(Eq, Hash, EqIgnoreSpan)]
48#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
49#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
50pub struct TsTypeParam {
51    pub span: Span,
52    pub name: Ident,
53
54    #[cfg_attr(feature = "serde-impl", serde(default, rename = "in"))]
55    pub is_in: bool,
56
57    #[cfg_attr(feature = "serde-impl", serde(default, rename = "out"))]
58    pub is_out: bool,
59
60    #[cfg_attr(feature = "serde-impl", serde(default, rename = "const"))]
61    pub is_const: bool,
62
63    #[cfg_attr(feature = "serde-impl", serde(default))]
64    #[cfg_attr(
65        feature = "encoding-impl",
66        encoding(with = "cbor4ii::core::types::Maybe")
67    )]
68    pub constraint: Option<Box<TsType>>,
69
70    #[cfg_attr(feature = "serde-impl", serde(default))]
71    #[cfg_attr(
72        feature = "encoding-impl",
73        encoding(with = "cbor4ii::core::types::Maybe")
74    )]
75    pub default: Option<Box<TsType>>,
76}
77
78#[ast_node("TsTypeParameterInstantiation")]
79#[derive(Eq, Hash, EqIgnoreSpan)]
80#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
81#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
82pub struct TsTypeParamInstantiation {
83    pub span: Span,
84    pub params: Vec<Box<TsType>>,
85}
86
87#[ast_node("TsParameterProperty")]
88#[derive(Eq, Hash, EqIgnoreSpan)]
89#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
90#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
91pub struct TsParamProp {
92    pub span: Span,
93    #[cfg_attr(feature = "serde-impl", serde(default))]
94    pub decorators: Vec<Decorator>,
95    #[cfg_attr(feature = "serde-impl", serde(default))]
97    #[cfg_attr(
98        feature = "encoding-impl",
99        encoding(with = "cbor4ii::core::types::Maybe")
100    )]
101    pub accessibility: Option<Accessibility>,
102    #[cfg_attr(feature = "serde-impl", serde(rename = "override"))]
103    pub is_override: bool,
104    pub readonly: bool,
105    pub param: TsParamPropParam,
106}
107
108#[ast_node]
109#[derive(Eq, Hash, Is, EqIgnoreSpan)]
110#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
111#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
112pub enum TsParamPropParam {
113    #[tag("Identifier")]
114    Ident(BindingIdent),
115
116    #[tag("AssignmentPattern")]
117    Assign(AssignPat),
118}
119
120#[ast_node("TsQualifiedName")]
121#[derive(Eq, Hash, EqIgnoreSpan)]
122#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
123#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
124pub struct TsQualifiedName {
125    pub span: Span,
126    pub left: TsEntityName,
127    pub right: IdentName,
128}
129
130#[ast_node]
131#[derive(Eq, Hash, Is, EqIgnoreSpan)]
132#[allow(variant_size_differences)]
133#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
134#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
135pub enum TsEntityName {
136    #[tag("TsQualifiedName")]
137    TsQualifiedName(Box<TsQualifiedName>),
138
139    #[tag("Identifier")]
140    Ident(Ident),
141}
142
143#[ast_node]
148#[derive(Eq, Hash, Is, EqIgnoreSpan)]
149#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
150#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
151pub enum TsTypeElement {
152    #[tag("TsCallSignatureDeclaration")]
153    TsCallSignatureDecl(TsCallSignatureDecl),
154
155    #[tag("TsConstructSignatureDeclaration")]
156    TsConstructSignatureDecl(TsConstructSignatureDecl),
157
158    #[tag("TsPropertySignature")]
159    TsPropertySignature(TsPropertySignature),
160
161    #[tag("TsGetterSignature")]
162    TsGetterSignature(TsGetterSignature),
163
164    #[tag("TsSetterSignature")]
165    TsSetterSignature(TsSetterSignature),
166
167    #[tag("TsMethodSignature")]
168    TsMethodSignature(TsMethodSignature),
169
170    #[tag("TsIndexSignature")]
171    TsIndexSignature(TsIndexSignature),
172}
173
174#[ast_node("TsCallSignatureDeclaration")]
175#[derive(Eq, Hash, EqIgnoreSpan)]
176#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
177#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
178pub struct TsCallSignatureDecl {
179    pub span: Span,
180    pub params: Vec<TsFnParam>,
181    #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
182    #[cfg_attr(
183        feature = "encoding-impl",
184        encoding(with = "cbor4ii::core::types::Maybe")
185    )]
186    pub type_ann: Option<Box<TsTypeAnn>>,
187    #[cfg_attr(feature = "serde-impl", serde(default))]
188    #[cfg_attr(
189        feature = "encoding-impl",
190        encoding(with = "cbor4ii::core::types::Maybe")
191    )]
192    pub type_params: Option<Box<TsTypeParamDecl>>,
193}
194
195#[ast_node("TsConstructSignatureDeclaration")]
196#[derive(Eq, Hash, EqIgnoreSpan)]
197#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
198#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
199pub struct TsConstructSignatureDecl {
200    pub span: Span,
201    pub params: Vec<TsFnParam>,
202    #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
203    #[cfg_attr(
204        feature = "encoding-impl",
205        encoding(with = "cbor4ii::core::types::Maybe")
206    )]
207    pub type_ann: Option<Box<TsTypeAnn>>,
208    #[cfg_attr(feature = "serde-impl", serde(default))]
209    #[cfg_attr(
210        feature = "encoding-impl",
211        encoding(with = "cbor4ii::core::types::Maybe")
212    )]
213    pub type_params: Option<Box<TsTypeParamDecl>>,
214}
215
216#[ast_node("TsPropertySignature")]
217#[derive(Eq, Hash, EqIgnoreSpan)]
218#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
219#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
220pub struct TsPropertySignature {
221    pub span: Span,
222    pub readonly: bool,
223    pub key: Box<Expr>,
224    pub computed: bool,
225    pub optional: bool,
226    #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
227    #[cfg_attr(
228        feature = "encoding-impl",
229        encoding(with = "cbor4ii::core::types::Maybe")
230    )]
231    pub type_ann: Option<Box<TsTypeAnn>>,
232}
233
234#[ast_node("TsGetterSignature")]
235#[derive(Eq, Hash, EqIgnoreSpan)]
236#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
237#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
238pub struct TsGetterSignature {
239    pub span: Span,
240    pub key: Box<Expr>,
241    pub computed: bool,
242    #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
243    #[cfg_attr(
244        feature = "encoding-impl",
245        encoding(with = "cbor4ii::core::types::Maybe")
246    )]
247    pub type_ann: Option<Box<TsTypeAnn>>,
248}
249
250#[ast_node("TsSetterSignature")]
251#[derive(Eq, Hash, EqIgnoreSpan)]
252#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
253#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
254pub struct TsSetterSignature {
255    pub span: Span,
256    pub key: Box<Expr>,
257    pub computed: bool,
258    pub param: TsFnParam,
259}
260
261#[ast_node("TsMethodSignature")]
262#[derive(Eq, Hash, EqIgnoreSpan)]
263#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
264#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
265pub struct TsMethodSignature {
266    pub span: Span,
267    pub key: Box<Expr>,
268    pub computed: bool,
269    pub optional: bool,
270    pub params: Vec<TsFnParam>,
271    #[cfg_attr(feature = "serde-impl", serde(default))]
272    #[cfg_attr(
273        feature = "encoding-impl",
274        encoding(with = "cbor4ii::core::types::Maybe")
275    )]
276    pub type_ann: Option<Box<TsTypeAnn>>,
277    #[cfg_attr(feature = "serde-impl", serde(default))]
278    #[cfg_attr(
279        feature = "encoding-impl",
280        encoding(with = "cbor4ii::core::types::Maybe")
281    )]
282    pub type_params: Option<Box<TsTypeParamDecl>>,
283}
284
285#[ast_node("TsIndexSignature")]
286#[derive(Eq, Hash, EqIgnoreSpan)]
287#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
288#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
289pub struct TsIndexSignature {
290    pub params: Vec<TsFnParam>,
291    #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
292    #[cfg_attr(
293        feature = "encoding-impl",
294        encoding(with = "cbor4ii::core::types::Maybe")
295    )]
296    pub type_ann: Option<Box<TsTypeAnn>>,
297
298    pub readonly: bool,
299    #[cfg_attr(feature = "serde-impl", serde(rename = "static"))]
300    pub is_static: bool,
301    pub span: Span,
302}
303
304#[ast_node(no_clone)]
309#[derive(Eq, Hash, Is, EqIgnoreSpan)]
310#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
311#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
312pub enum TsType {
313    #[tag("TsKeywordType")]
314    TsKeywordType(TsKeywordType),
315
316    #[tag("TsThisType")]
317    TsThisType(TsThisType),
318
319    #[tag("TsFunctionType")]
320    #[tag("TsConstructorType")]
321    TsFnOrConstructorType(TsFnOrConstructorType),
322
323    #[tag("TsTypeReference")]
324    TsTypeRef(TsTypeRef),
325
326    #[tag("TsTypeQuery")]
327    TsTypeQuery(TsTypeQuery),
328
329    #[tag("TsTypeLiteral")]
330    TsTypeLit(TsTypeLit),
331
332    #[tag("TsArrayType")]
333    TsArrayType(TsArrayType),
334
335    #[tag("TsTupleType")]
336    TsTupleType(TsTupleType),
337
338    #[tag("TsOptionalType")]
339    TsOptionalType(TsOptionalType),
340
341    #[tag("TsRestType")]
342    TsRestType(TsRestType),
343
344    #[tag("TsUnionType")]
345    #[tag("TsIntersectionType")]
346    TsUnionOrIntersectionType(TsUnionOrIntersectionType),
347
348    #[tag("TsConditionalType")]
349    TsConditionalType(TsConditionalType),
350
351    #[tag("TsInferType")]
352    TsInferType(TsInferType),
353
354    #[tag("TsParenthesizedType")]
355    TsParenthesizedType(TsParenthesizedType),
356
357    #[tag("TsTypeOperator")]
358    TsTypeOperator(TsTypeOperator),
359
360    #[tag("TsIndexedAccessType")]
361    TsIndexedAccessType(TsIndexedAccessType),
362
363    #[tag("TsMappedType")]
364    TsMappedType(TsMappedType),
365
366    #[tag("TsLiteralType")]
367    TsLitType(TsLitType),
368
369    #[tag("TsTypePredicate")]
370    TsTypePredicate(TsTypePredicate),
371
372    #[tag("TsImportType")]
373    TsImportType(TsImportType),
374}
375
376impl Clone for TsType {
379    fn clone(&self) -> Self {
380        use TsType::*;
381        match self {
382            #[cfg(all(swc_ast_unknown, feature = "encoding-impl"))]
383            Unknown(tag, v) => Unknown(*tag, v.clone()),
384            TsKeywordType(t) => TsKeywordType(t.clone()),
385            TsThisType(t) => TsThisType(t.clone()),
386            TsFnOrConstructorType(t) => TsFnOrConstructorType(t.clone()),
387            TsTypeRef(t) => TsTypeRef(t.clone()),
388            TsTypeQuery(t) => TsTypeQuery(t.clone()),
389            TsTypeLit(t) => TsTypeLit(t.clone()),
390            TsArrayType(t) => TsArrayType(t.clone()),
391            TsTupleType(t) => TsTupleType(t.clone()),
392            TsOptionalType(t) => TsOptionalType(t.clone()),
393            TsRestType(t) => TsRestType(t.clone()),
394            TsUnionOrIntersectionType(t) => TsUnionOrIntersectionType(t.clone()),
395            TsConditionalType(t) => TsConditionalType(t.clone()),
396            TsInferType(t) => TsInferType(t.clone()),
397            TsParenthesizedType(t) => TsParenthesizedType(t.clone()),
398            TsTypeOperator(t) => TsTypeOperator(t.clone()),
399            TsIndexedAccessType(t) => TsIndexedAccessType(t.clone()),
400            TsMappedType(t) => TsMappedType(t.clone()),
401            TsLitType(t) => TsLitType(t.clone()),
402            TsTypePredicate(t) => TsTypePredicate(t.clone()),
403            TsImportType(t) => TsImportType(t.clone()),
404        }
405    }
406}
407
408#[ast_node]
409#[derive(Eq, Hash, Is, EqIgnoreSpan)]
410#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
411#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
412pub enum TsFnOrConstructorType {
413    #[tag("TsFunctionType")]
414    TsFnType(TsFnType),
415    #[tag("TsConstructorType")]
416    TsConstructorType(TsConstructorType),
417}
418
419impl From<TsFnType> for TsType {
420    fn from(t: TsFnType) -> Self {
421        TsFnOrConstructorType::TsFnType(t).into()
422    }
423}
424
425impl From<TsConstructorType> for TsType {
426    fn from(t: TsConstructorType) -> Self {
427        TsFnOrConstructorType::TsConstructorType(t).into()
428    }
429}
430
431impl From<TsUnionType> for TsType {
432    fn from(t: TsUnionType) -> Self {
433        TsUnionOrIntersectionType::TsUnionType(t).into()
434    }
435}
436
437impl From<TsIntersectionType> for TsType {
438    fn from(t: TsIntersectionType) -> Self {
439        TsUnionOrIntersectionType::TsIntersectionType(t).into()
440    }
441}
442
443#[ast_node("TsKeywordType")]
444#[derive(Eq, Hash, EqIgnoreSpan)]
445#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
446#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
447pub struct TsKeywordType {
448    pub span: Span,
449    pub kind: TsKeywordTypeKind,
450}
451
452#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EqIgnoreSpan)]
453#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
454#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
455#[cfg_attr(
456    any(feature = "rkyv-impl"),
457    derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
458)]
459#[cfg_attr(feature = "rkyv-impl", derive(bytecheck::CheckBytes))]
460#[cfg_attr(feature = "rkyv-impl", repr(u32))]
461#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
462#[cfg_attr(
463    feature = "encoding-impl",
464    derive(::swc_common::Encode, ::swc_common::Decode)
465)]
466#[cfg_attr(swc_ast_unknown, non_exhaustive)]
467pub enum TsKeywordTypeKind {
468    #[cfg_attr(feature = "serde-impl", serde(rename = "any"))]
469    TsAnyKeyword,
470
471    #[cfg_attr(feature = "serde-impl", serde(rename = "unknown"))]
472    TsUnknownKeyword,
473
474    #[cfg_attr(feature = "serde-impl", serde(rename = "number"))]
475    TsNumberKeyword,
476
477    #[cfg_attr(feature = "serde-impl", serde(rename = "object"))]
478    TsObjectKeyword,
479
480    #[cfg_attr(feature = "serde-impl", serde(rename = "boolean"))]
481    TsBooleanKeyword,
482
483    #[cfg_attr(feature = "serde-impl", serde(rename = "bigint"))]
484    TsBigIntKeyword,
485
486    #[cfg_attr(feature = "serde-impl", serde(rename = "string"))]
487    TsStringKeyword,
488
489    #[cfg_attr(feature = "serde-impl", serde(rename = "symbol"))]
490    TsSymbolKeyword,
491
492    #[cfg_attr(feature = "serde-impl", serde(rename = "void"))]
493    TsVoidKeyword,
494
495    #[cfg_attr(feature = "serde-impl", serde(rename = "undefined"))]
496    TsUndefinedKeyword,
497
498    #[cfg_attr(feature = "serde-impl", serde(rename = "null"))]
499    TsNullKeyword,
500
501    #[cfg_attr(feature = "serde-impl", serde(rename = "never"))]
502    TsNeverKeyword,
503
504    #[cfg_attr(feature = "serde-impl", serde(rename = "intrinsic"))]
505    TsIntrinsicKeyword,
506}
507
508#[ast_node("TsThisType")]
509#[derive(Copy, Eq, Hash, EqIgnoreSpan)]
510#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
511#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
512pub struct TsThisType {
513    pub span: Span,
514}
515
516#[ast_node]
517#[derive(Eq, Hash, Is, EqIgnoreSpan)]
518#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
519#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
520pub enum TsFnParam {
521    #[tag("Identifier")]
522    Ident(BindingIdent),
523
524    #[tag("ArrayPattern")]
525    Array(ArrayPat),
526
527    #[tag("RestElement")]
528    Rest(RestPat),
529
530    #[tag("ObjectPattern")]
531    Object(ObjectPat),
532}
533
534#[ast_node("TsFunctionType")]
535#[derive(Eq, Hash, EqIgnoreSpan)]
536#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
537#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
538pub struct TsFnType {
539    pub span: Span,
540    pub params: Vec<TsFnParam>,
541
542    #[cfg_attr(feature = "serde-impl", serde(default))]
543    #[cfg_attr(
544        feature = "encoding-impl",
545        encoding(with = "cbor4ii::core::types::Maybe")
546    )]
547    pub type_params: Option<Box<TsTypeParamDecl>>,
548    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
549    pub type_ann: Box<TsTypeAnn>,
550}
551
552#[ast_node("TsConstructorType")]
553#[derive(Eq, Hash, EqIgnoreSpan)]
554#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
555#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
556pub struct TsConstructorType {
557    pub span: Span,
558    pub params: Vec<TsFnParam>,
559    #[cfg_attr(feature = "serde-impl", serde(default))]
560    #[cfg_attr(
561        feature = "encoding-impl",
562        encoding(with = "cbor4ii::core::types::Maybe")
563    )]
564    pub type_params: Option<Box<TsTypeParamDecl>>,
565    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
566    pub type_ann: Box<TsTypeAnn>,
567    pub is_abstract: bool,
568}
569
570#[ast_node("TsTypeReference")]
571#[derive(Eq, Hash, EqIgnoreSpan)]
572#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
573#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
574pub struct TsTypeRef {
575    pub span: Span,
576    pub type_name: TsEntityName,
577    #[cfg_attr(feature = "serde-impl", serde(default))]
578    #[cfg_attr(
579        feature = "encoding-impl",
580        encoding(with = "cbor4ii::core::types::Maybe")
581    )]
582    pub type_params: Option<Box<TsTypeParamInstantiation>>,
583}
584
585#[ast_node("TsTypePredicate")]
586#[derive(Eq, Hash, EqIgnoreSpan)]
587#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
588#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
589pub struct TsTypePredicate {
590    pub span: Span,
591    pub asserts: bool,
592    pub param_name: TsThisTypeOrIdent,
593    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
594    #[cfg_attr(
595        feature = "encoding-impl",
596        encoding(with = "cbor4ii::core::types::Maybe")
597    )]
598    pub type_ann: Option<Box<TsTypeAnn>>,
599}
600
601#[ast_node]
602#[derive(Eq, Hash, Is, EqIgnoreSpan)]
603#[allow(variant_size_differences)]
604#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
605#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
606pub enum TsThisTypeOrIdent {
607    #[tag("TsThisType")]
608    TsThisType(TsThisType),
609
610    #[tag("Identifier")]
611    Ident(Ident),
612}
613
614#[ast_node("TsTypeQuery")]
616#[derive(Eq, Hash, EqIgnoreSpan)]
617#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
618#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
619pub struct TsTypeQuery {
620    pub span: Span,
621    pub expr_name: TsTypeQueryExpr,
622    #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeArguments"))]
623    #[cfg_attr(
624        feature = "encoding-impl",
625        encoding(with = "cbor4ii::core::types::Maybe")
626    )]
627    pub type_args: Option<Box<TsTypeParamInstantiation>>,
628}
629
630#[ast_node]
631#[derive(Eq, Hash, Is, EqIgnoreSpan)]
632#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
633#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
634pub enum TsTypeQueryExpr {
635    #[tag("TsQualifiedName")]
636    #[tag("Identifier")]
637    TsEntityName(TsEntityName),
638    #[tag("TsImportType")]
639    Import(TsImportType),
640}
641
642#[ast_node("TsImportCallOptions")]
643#[derive(Eq, Hash, EqIgnoreSpan)]
644#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
645#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
646pub struct TsImportCallOptions {
647    pub span: Span,
648    #[cfg_attr(feature = "serde-impl", serde(default))]
649    pub with: Box<ObjectLit>,
650}
651
652#[ast_node("TsImportType")]
653#[derive(Eq, Hash, EqIgnoreSpan)]
654#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
655#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
656pub struct TsImportType {
657    pub span: Span,
658    #[cfg_attr(feature = "serde-impl", serde(rename = "argument"))]
659    pub arg: Str,
660    #[cfg_attr(
661        feature = "encoding-impl",
662        encoding(with = "cbor4ii::core::types::Maybe")
663    )]
664    pub qualifier: Option<TsEntityName>,
665    #[cfg_attr(feature = "serde-impl", serde(rename = "typeArguments"))]
666    #[cfg_attr(
667        feature = "encoding-impl",
668        encoding(with = "cbor4ii::core::types::Maybe")
669    )]
670    pub type_args: Option<Box<TsTypeParamInstantiation>>,
671    #[cfg_attr(feature = "serde-impl", serde(default))]
672    #[cfg_attr(
673        feature = "encoding-impl",
674        encoding(with = "cbor4ii::core::types::Maybe")
675    )]
676    pub attributes: Option<TsImportCallOptions>,
677}
678
679#[ast_node("TsTypeLiteral")]
680#[derive(Eq, Hash, EqIgnoreSpan)]
681#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
682#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
683pub struct TsTypeLit {
684    pub span: Span,
685    pub members: Vec<TsTypeElement>,
686}
687
688#[ast_node("TsArrayType")]
689#[derive(Eq, Hash, EqIgnoreSpan)]
690#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
691#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
692pub struct TsArrayType {
693    pub span: Span,
694    pub elem_type: Box<TsType>,
695}
696
697#[ast_node("TsTupleType")]
698#[derive(Eq, Hash, EqIgnoreSpan)]
699#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
700#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
701pub struct TsTupleType {
702    pub span: Span,
703    pub elem_types: Vec<TsTupleElement>,
704}
705
706#[ast_node("TsTupleElement")]
707#[derive(Eq, Hash, EqIgnoreSpan)]
708#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
709#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
710pub struct TsTupleElement {
711    pub span: Span,
712    #[cfg_attr(
714        feature = "encoding-impl",
715        encoding(with = "cbor4ii::core::types::Maybe")
716    )]
717    pub label: Option<Pat>,
718    pub ty: Box<TsType>,
719}
720
721#[ast_node("TsOptionalType")]
722#[derive(Eq, Hash, EqIgnoreSpan)]
723#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
724#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
725pub struct TsOptionalType {
726    pub span: Span,
727    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
728    pub type_ann: Box<TsType>,
729}
730
731#[ast_node("TsRestType")]
732#[derive(Eq, Hash, EqIgnoreSpan)]
733#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
734#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
735pub struct TsRestType {
736    pub span: Span,
737    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
738    pub type_ann: Box<TsType>,
739}
740
741#[ast_node]
742#[derive(Eq, Hash, Is, EqIgnoreSpan)]
743#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
744#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
745pub enum TsUnionOrIntersectionType {
746    #[tag("TsUnionType")]
747    TsUnionType(TsUnionType),
748
749    #[tag("TsIntersectionType")]
750    TsIntersectionType(TsIntersectionType),
751}
752
753#[ast_node("TsUnionType")]
754#[derive(Eq, Hash, EqIgnoreSpan)]
755#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
756#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
757pub struct TsUnionType {
758    pub span: Span,
759    pub types: Vec<Box<TsType>>,
760}
761
762#[ast_node("TsIntersectionType")]
763#[derive(Eq, Hash, EqIgnoreSpan)]
764#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
765#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
766pub struct TsIntersectionType {
767    pub span: Span,
768    pub types: Vec<Box<TsType>>,
769}
770
771#[ast_node("TsConditionalType")]
772#[derive(Eq, Hash, EqIgnoreSpan)]
773#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
774#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
775pub struct TsConditionalType {
776    pub span: Span,
777    pub check_type: Box<TsType>,
778    pub extends_type: Box<TsType>,
779    pub true_type: Box<TsType>,
780    pub false_type: Box<TsType>,
781}
782
783#[ast_node("TsInferType")]
784#[derive(Eq, Hash, EqIgnoreSpan)]
785#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
786#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
787pub struct TsInferType {
788    pub span: Span,
789    pub type_param: TsTypeParam,
790}
791
792#[ast_node("TsParenthesizedType")]
793#[derive(Eq, Hash, EqIgnoreSpan)]
794#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
795#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
796pub struct TsParenthesizedType {
797    pub span: Span,
798    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
799    pub type_ann: Box<TsType>,
800}
801
802#[ast_node("TsTypeOperator")]
803#[derive(Eq, Hash, EqIgnoreSpan)]
804#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
805#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
806pub struct TsTypeOperator {
807    pub span: Span,
808    pub op: TsTypeOperatorOp,
809    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
810    pub type_ann: Box<TsType>,
811}
812
813#[derive(StringEnum, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)]
814#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
815#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
816#[cfg_attr(
817    any(feature = "rkyv-impl"),
818    derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
819)]
820#[cfg_attr(feature = "rkyv-impl", derive(bytecheck::CheckBytes))]
821#[cfg_attr(feature = "rkyv-impl", repr(u32))]
822#[cfg_attr(
823    feature = "encoding-impl",
824    derive(::swc_common::Encode, ::swc_common::Decode)
825)]
826#[cfg_attr(swc_ast_unknown, non_exhaustive)]
827pub enum TsTypeOperatorOp {
828    KeyOf,
830    Unique,
832    ReadOnly,
834}
835
836#[ast_node("TsIndexedAccessType")]
837#[derive(Eq, Hash, EqIgnoreSpan)]
838#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
839#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
840pub struct TsIndexedAccessType {
841    pub span: Span,
842    pub readonly: bool,
843    #[cfg_attr(feature = "serde-impl", serde(rename = "objectType"))]
844    pub obj_type: Box<TsType>,
845    pub index_type: Box<TsType>,
846}
847
848#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)]
849#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
850#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
851#[cfg_attr(
852    any(feature = "rkyv-impl"),
853    derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
854)]
855#[cfg_attr(feature = "rkyv-impl", derive(bytecheck::CheckBytes))]
856#[cfg_attr(feature = "rkyv-impl", repr(u32))]
857#[cfg_attr(
858    feature = "encoding-impl",
859    derive(::swc_common::Encode, ::swc_common::Decode)
860)]
861#[cfg_attr(swc_ast_unknown, non_exhaustive)]
862pub enum TruePlusMinus {
863    True,
864    Plus,
865    Minus,
866}
867
868#[cfg(feature = "serde-impl")]
869impl Serialize for TruePlusMinus {
870    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
871    where
872        S: ::serde::Serializer,
873    {
874        match *self {
875            TruePlusMinus::True => serializer.serialize_bool(true),
876            TruePlusMinus::Plus => serializer.serialize_str("+"),
877            TruePlusMinus::Minus => serializer.serialize_str("-"),
878        }
879    }
880}
881
882#[cfg(feature = "serde-impl")]
883impl<'de> Deserialize<'de> for TruePlusMinus {
884    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
885    where
886        D: Deserializer<'de>,
887    {
888        struct TruePlusMinusVisitor;
889
890        impl Visitor<'_> for TruePlusMinusVisitor {
891            type Value = TruePlusMinus;
892
893            fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
894                formatter.write_str("one of '+', '-', true")
895            }
896
897            fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
898            where
899                E: de::Error,
900            {
901                match value {
902                    "+" => Ok(TruePlusMinus::Plus),
903                    "-" => Ok(TruePlusMinus::Minus),
904                    "true" => Ok(TruePlusMinus::True),
905                    _ => Err(de::Error::invalid_value(Unexpected::Str(value), &self)),
906                }
907            }
908
909            fn visit_bool<E>(self, value: bool) -> Result<Self::Value, E>
910            where
911                E: de::Error,
912            {
913                if value {
914                    Ok(TruePlusMinus::True)
915                } else {
916                    Err(de::Error::invalid_value(Unexpected::Bool(value), &self))
917                }
918            }
919        }
920
921        deserializer.deserialize_any(TruePlusMinusVisitor)
922    }
923}
924
925#[ast_node("TsMappedType")]
926#[derive(Eq, Hash, EqIgnoreSpan)]
927#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
928#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
929pub struct TsMappedType {
930    pub span: Span,
931    #[cfg_attr(feature = "serde-impl", serde(default))]
932    #[cfg_attr(
933        feature = "encoding-impl",
934        encoding(with = "cbor4ii::core::types::Maybe")
935    )]
936    pub readonly: Option<TruePlusMinus>,
937    pub type_param: TsTypeParam,
938    #[cfg_attr(feature = "serde-impl", serde(default, rename = "nameType"))]
939    #[cfg_attr(
940        feature = "encoding-impl",
941        encoding(with = "cbor4ii::core::types::Maybe")
942    )]
943    pub name_type: Option<Box<TsType>>,
944    #[cfg_attr(feature = "serde-impl", serde(default))]
945    #[cfg_attr(
946        feature = "encoding-impl",
947        encoding(with = "cbor4ii::core::types::Maybe")
948    )]
949    pub optional: Option<TruePlusMinus>,
950    #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
951    #[cfg_attr(
952        feature = "encoding-impl",
953        encoding(with = "cbor4ii::core::types::Maybe")
954    )]
955    pub type_ann: Option<Box<TsType>>,
956}
957
958#[ast_node("TsLiteralType")]
959#[derive(Eq, Hash, EqIgnoreSpan)]
960#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
961#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
962pub struct TsLitType {
963    pub span: Span,
964    #[cfg_attr(feature = "serde-impl", serde(rename = "literal"))]
965    pub lit: TsLit,
966}
967
968#[ast_node]
969#[derive(Eq, Hash, Is, EqIgnoreSpan)]
970#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
971#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
972pub enum TsLit {
973    #[tag("NumericLiteral")]
974    Number(Number),
975
976    #[tag("StringLiteral")]
977    Str(Str),
978
979    #[tag("BooleanLiteral")]
980    Bool(Bool),
981
982    #[tag("BigIntLiteral")]
983    BigInt(BigInt),
984
985    #[tag("TemplateLiteral")]
986    Tpl(TsTplLitType),
987}
988
989#[ast_node("TemplateLiteral")]
990#[derive(Eq, Hash, EqIgnoreSpan)]
991#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
992#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
993pub struct TsTplLitType {
994    pub span: Span,
995
996    pub types: Vec<Box<TsType>>,
997
998    pub quasis: Vec<TplElement>,
999}
1000
1001#[ast_node("TsInterfaceDeclaration")]
1006#[derive(Eq, Hash, EqIgnoreSpan)]
1007#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1008#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1009pub struct TsInterfaceDecl {
1010    pub span: Span,
1011    pub id: Ident,
1012    pub declare: bool,
1013    #[cfg_attr(feature = "serde-impl", serde(default))]
1014    #[cfg_attr(
1015        feature = "encoding-impl",
1016        encoding(with = "cbor4ii::core::types::Maybe")
1017    )]
1018    pub type_params: Option<Box<TsTypeParamDecl>>,
1019    pub extends: Vec<TsExprWithTypeArgs>,
1020    pub body: TsInterfaceBody,
1021}
1022
1023#[ast_node("TsInterfaceBody")]
1024#[derive(Eq, Hash, EqIgnoreSpan)]
1025#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1026#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1027pub struct TsInterfaceBody {
1028    pub span: Span,
1029    pub body: Vec<TsTypeElement>,
1030}
1031
1032#[ast_node("TsExpressionWithTypeArguments")]
1033#[derive(Eq, Hash, EqIgnoreSpan)]
1034#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1035#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1036pub struct TsExprWithTypeArgs {
1037    pub span: Span,
1038    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1039    pub expr: Box<Expr>,
1040    #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeArguments"))]
1041    #[cfg_attr(
1042        feature = "encoding-impl",
1043        encoding(with = "cbor4ii::core::types::Maybe")
1044    )]
1045    pub type_args: Option<Box<TsTypeParamInstantiation>>,
1046}
1047
1048#[ast_node("TsTypeAliasDeclaration")]
1049#[derive(Eq, Hash, EqIgnoreSpan)]
1050#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1051#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1052pub struct TsTypeAliasDecl {
1053    pub span: Span,
1054    pub declare: bool,
1055    pub id: Ident,
1056    #[cfg_attr(feature = "serde-impl", serde(default))]
1057    #[cfg_attr(
1058        feature = "encoding-impl",
1059        encoding(with = "cbor4ii::core::types::Maybe")
1060    )]
1061    pub type_params: Option<Box<TsTypeParamDecl>>,
1062    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
1063    pub type_ann: Box<TsType>,
1064}
1065
1066#[ast_node("TsEnumDeclaration")]
1067#[derive(Eq, Hash, EqIgnoreSpan)]
1068#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1069#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1070pub struct TsEnumDecl {
1071    pub span: Span,
1072    pub declare: bool,
1073    pub is_const: bool,
1074    pub id: Ident,
1075    pub members: Vec<TsEnumMember>,
1076}
1077
1078#[ast_node("TsEnumMember")]
1079#[derive(Eq, Hash, EqIgnoreSpan)]
1080#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1081#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1082pub struct TsEnumMember {
1083    pub span: Span,
1084    pub id: TsEnumMemberId,
1085    #[cfg_attr(feature = "serde-impl", serde(default))]
1086    #[cfg_attr(
1087        feature = "encoding-impl",
1088        encoding(with = "cbor4ii::core::types::Maybe")
1089    )]
1090    pub init: Option<Box<Expr>>,
1091}
1092
1093#[ast_node]
1096#[derive(Eq, Hash, Is, EqIgnoreSpan)]
1097#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1098#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1099pub enum TsEnumMemberId {
1100    #[tag("Identifier")]
1101    Ident(Ident),
1102
1103    #[tag("StringLiteral")]
1104    Str(Str),
1105}
1106
1107#[ast_node("TsModuleDeclaration")]
1108#[derive(Eq, Hash, EqIgnoreSpan)]
1109#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1110#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1111pub struct TsModuleDecl {
1112    pub span: Span,
1113    pub declare: bool,
1114    pub global: bool,
1116    pub namespace: bool,
1117
1118    pub id: TsModuleName,
1119    #[cfg_attr(feature = "serde-impl", serde(default))]
1120    #[cfg_attr(
1121        feature = "encoding-impl",
1122        encoding(with = "cbor4ii::core::types::Maybe")
1123    )]
1124    pub body: Option<TsNamespaceBody>,
1125}
1126
1127#[ast_node]
1130#[derive(Eq, Hash, Is, EqIgnoreSpan)]
1131#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1132#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1133pub enum TsNamespaceBody {
1134    #[tag("TsModuleBlock")]
1135    TsModuleBlock(TsModuleBlock),
1136
1137    #[tag("TsNamespaceDeclaration")]
1138    TsNamespaceDecl(TsNamespaceDecl),
1139}
1140
1141#[ast_node("TsModuleBlock")]
1142#[derive(Eq, Hash, EqIgnoreSpan)]
1143#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1144#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1145pub struct TsModuleBlock {
1146    pub span: Span,
1147    pub body: Vec<ModuleItem>,
1148}
1149
1150#[ast_node("TsNamespaceDeclaration")]
1151#[derive(Eq, Hash, EqIgnoreSpan)]
1152#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1153#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1154pub struct TsNamespaceDecl {
1155    pub span: Span,
1156    pub declare: bool,
1157    pub global: bool,
1159    pub id: Ident,
1160    pub body: Box<TsNamespaceBody>,
1161}
1162
1163#[ast_node]
1164#[derive(Eq, Hash, Is, EqIgnoreSpan)]
1165#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1166#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1167pub enum TsModuleName {
1168    #[tag("Identifier")]
1169    Ident(Ident),
1170
1171    #[tag("StringLiteral")]
1172    Str(Str),
1173}
1174
1175#[ast_node("TsImportEqualsDeclaration")]
1176#[derive(Eq, Hash, EqIgnoreSpan)]
1177#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1178#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1179pub struct TsImportEqualsDecl {
1180    pub span: Span,
1181    pub is_export: bool,
1182    pub is_type_only: bool,
1183    pub id: Ident,
1184    pub module_ref: TsModuleRef,
1185}
1186
1187#[ast_node]
1188#[derive(Eq, Hash, Is, EqIgnoreSpan)]
1189#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1190#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1191pub enum TsModuleRef {
1192    #[tag("TsQualifiedName")]
1193    #[tag("Identifier")]
1194    TsEntityName(TsEntityName),
1195
1196    #[tag("TsExternalModuleReference")]
1197    TsExternalModuleRef(TsExternalModuleRef),
1198}
1199
1200#[ast_node("TsExternalModuleReference")]
1201#[derive(Eq, Hash, EqIgnoreSpan)]
1202#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1203#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1204pub struct TsExternalModuleRef {
1205    pub span: Span,
1206    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1207    pub expr: Str,
1208}
1209
1210#[ast_node("TsExportAssignment")]
1214#[derive(Eq, Hash, EqIgnoreSpan)]
1215#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1216#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1217pub struct TsExportAssignment {
1218    pub span: Span,
1219    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1220    pub expr: Box<Expr>,
1221}
1222
1223#[ast_node("TsNamespaceExportDeclaration")]
1224#[derive(Eq, Hash, EqIgnoreSpan)]
1225#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1226#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1227pub struct TsNamespaceExportDecl {
1228    pub span: Span,
1229    pub id: Ident,
1230}
1231
1232#[ast_node("TsAsExpression")]
1237#[derive(Eq, Hash, EqIgnoreSpan)]
1238#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1239#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1240pub struct TsAsExpr {
1241    pub span: Span,
1242    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1243    pub expr: Box<Expr>,
1244    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
1245    pub type_ann: Box<TsType>,
1246}
1247
1248#[ast_node("TsTypeAssertion")]
1249#[derive(Eq, Hash, EqIgnoreSpan)]
1250#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1251#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1252pub struct TsTypeAssertion {
1253    pub span: Span,
1254    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1255    pub expr: Box<Expr>,
1256    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
1257    pub type_ann: Box<TsType>,
1258}
1259
1260#[ast_node("TsNonNullExpression")]
1261#[derive(Eq, Hash, EqIgnoreSpan)]
1262#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1263#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1264pub struct TsNonNullExpr {
1265    pub span: Span,
1266    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1267    pub expr: Box<Expr>,
1268}
1269
1270#[ast_node("TsSatisfiesExpression")]
1271#[derive(Eq, Hash, EqIgnoreSpan)]
1272#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1273#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1274pub struct TsSatisfiesExpr {
1275    pub span: Span,
1276    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1277    pub expr: Box<Expr>,
1278    #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
1279    pub type_ann: Box<TsType>,
1280}
1281
1282#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)]
1283#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1284#[cfg_attr(
1285    any(feature = "rkyv-impl"),
1286    derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
1287)]
1288#[cfg_attr(feature = "rkyv-impl", derive(bytecheck::CheckBytes))]
1289#[cfg_attr(feature = "rkyv-impl", repr(u32))]
1290#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
1291#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1292#[cfg_attr(
1293    feature = "encoding-impl",
1294    derive(::swc_common::Encode, ::swc_common::Decode)
1295)]
1296#[cfg_attr(swc_ast_unknown, non_exhaustive)]
1297pub enum Accessibility {
1298    #[cfg_attr(feature = "serde-impl", serde(rename = "public"))]
1299    Public,
1300    #[cfg_attr(feature = "serde-impl", serde(rename = "protected"))]
1301    Protected,
1302    #[cfg_attr(feature = "serde-impl", serde(rename = "private"))]
1303    Private,
1304}
1305
1306#[ast_node("TsConstAssertion")]
1307#[derive(Eq, Hash, EqIgnoreSpan)]
1308#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1309#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1310pub struct TsConstAssertion {
1311    pub span: Span,
1312    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1313    pub expr: Box<Expr>,
1314}
1315
1316#[ast_node("TsInstantiation")]
1317#[derive(Eq, Hash, EqIgnoreSpan)]
1318#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1319#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1320pub struct TsInstantiation {
1321    pub span: Span,
1322    #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1323    pub expr: Box<Expr>,
1324    #[cfg_attr(feature = "serde-impl", serde(rename = "typeArguments"))]
1325    pub type_args: Box<TsTypeParamInstantiation>,
1326}