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