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))]
413pub enum TsKeywordTypeKind {
414 #[cfg_attr(feature = "serde-impl", serde(rename = "any"))]
415 TsAnyKeyword,
416
417 #[cfg_attr(feature = "serde-impl", serde(rename = "unknown"))]
418 TsUnknownKeyword,
419
420 #[cfg_attr(feature = "serde-impl", serde(rename = "number"))]
421 TsNumberKeyword,
422
423 #[cfg_attr(feature = "serde-impl", serde(rename = "object"))]
424 TsObjectKeyword,
425
426 #[cfg_attr(feature = "serde-impl", serde(rename = "boolean"))]
427 TsBooleanKeyword,
428
429 #[cfg_attr(feature = "serde-impl", serde(rename = "bigint"))]
430 TsBigIntKeyword,
431
432 #[cfg_attr(feature = "serde-impl", serde(rename = "string"))]
433 TsStringKeyword,
434
435 #[cfg_attr(feature = "serde-impl", serde(rename = "symbol"))]
436 TsSymbolKeyword,
437
438 #[cfg_attr(feature = "serde-impl", serde(rename = "void"))]
439 TsVoidKeyword,
440
441 #[cfg_attr(feature = "serde-impl", serde(rename = "undefined"))]
442 TsUndefinedKeyword,
443
444 #[cfg_attr(feature = "serde-impl", serde(rename = "null"))]
445 TsNullKeyword,
446
447 #[cfg_attr(feature = "serde-impl", serde(rename = "never"))]
448 TsNeverKeyword,
449
450 #[cfg_attr(feature = "serde-impl", serde(rename = "intrinsic"))]
451 TsIntrinsicKeyword,
452}
453
454#[ast_node("TsThisType")]
455#[derive(Copy, Eq, Hash, EqIgnoreSpan)]
456#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
457#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
458pub struct TsThisType {
459 pub span: Span,
460}
461
462#[ast_node]
463#[derive(Eq, Hash, Is, EqIgnoreSpan)]
464#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
465#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
466pub enum TsFnParam {
467 #[tag("Identifier")]
468 Ident(BindingIdent),
469
470 #[tag("ArrayPattern")]
471 Array(ArrayPat),
472
473 #[tag("RestElement")]
474 Rest(RestPat),
475
476 #[tag("ObjectPattern")]
477 Object(ObjectPat),
478}
479
480#[ast_node("TsFunctionType")]
481#[derive(Eq, Hash, EqIgnoreSpan)]
482#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
483#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
484pub struct TsFnType {
485 pub span: Span,
486 pub params: Vec<TsFnParam>,
487
488 #[cfg_attr(feature = "serde-impl", serde(default))]
489 pub type_params: Option<Box<TsTypeParamDecl>>,
490 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
491 pub type_ann: Box<TsTypeAnn>,
492}
493
494#[ast_node("TsConstructorType")]
495#[derive(Eq, Hash, EqIgnoreSpan)]
496#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
497#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
498pub struct TsConstructorType {
499 pub span: Span,
500 pub params: Vec<TsFnParam>,
501 #[cfg_attr(feature = "serde-impl", serde(default))]
502 pub type_params: Option<Box<TsTypeParamDecl>>,
503 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
504 pub type_ann: Box<TsTypeAnn>,
505 pub is_abstract: bool,
506}
507
508#[ast_node("TsTypeReference")]
509#[derive(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 TsTypeRef {
513 pub span: Span,
514 pub type_name: TsEntityName,
515 #[cfg_attr(feature = "serde-impl", serde(default))]
516 pub type_params: Option<Box<TsTypeParamInstantiation>>,
517}
518
519#[ast_node("TsTypePredicate")]
520#[derive(Eq, Hash, EqIgnoreSpan)]
521#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
522#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
523pub struct TsTypePredicate {
524 pub span: Span,
525 pub asserts: bool,
526 pub param_name: TsThisTypeOrIdent,
527 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
528 pub type_ann: Option<Box<TsTypeAnn>>,
529}
530
531#[ast_node]
532#[derive(Eq, Hash, Is, EqIgnoreSpan)]
533#[allow(variant_size_differences)]
534#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
535#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
536pub enum TsThisTypeOrIdent {
537 #[tag("TsThisType")]
538 TsThisType(TsThisType),
539
540 #[tag("Identifier")]
541 Ident(Ident),
542}
543
544#[ast_node("TsTypeQuery")]
546#[derive(Eq, Hash, EqIgnoreSpan)]
547#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
548#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
549pub struct TsTypeQuery {
550 pub span: Span,
551 pub expr_name: TsTypeQueryExpr,
552 #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeArguments"))]
553 pub type_args: Option<Box<TsTypeParamInstantiation>>,
554}
555
556#[ast_node]
557#[derive(Eq, Hash, Is, EqIgnoreSpan)]
558#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
559#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
560pub enum TsTypeQueryExpr {
561 #[tag("TsQualifiedName")]
562 #[tag("Identifier")]
563 TsEntityName(TsEntityName),
564 #[tag("TsImportType")]
565 Import(TsImportType),
566}
567
568#[ast_node("TsImportCallOptions")]
569#[derive(Eq, Hash, EqIgnoreSpan)]
570#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
571#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
572pub struct TsImportCallOptions {
573 pub span: Span,
574 #[cfg_attr(feature = "serde-impl", serde(default))]
575 pub with: Box<ObjectLit>,
576}
577
578#[ast_node("TsImportType")]
579#[derive(Eq, Hash, EqIgnoreSpan)]
580#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
581#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
582pub struct TsImportType {
583 pub span: Span,
584 #[cfg_attr(feature = "serde-impl", serde(rename = "argument"))]
585 pub arg: Str,
586 pub qualifier: Option<TsEntityName>,
587 #[cfg_attr(feature = "serde-impl", serde(rename = "typeArguments"))]
588 pub type_args: Option<Box<TsTypeParamInstantiation>>,
589 #[cfg_attr(feature = "serde-impl", serde(default))]
590 pub attributes: Option<TsImportCallOptions>,
591}
592
593#[ast_node("TsTypeLiteral")]
594#[derive(Eq, Hash, EqIgnoreSpan)]
595#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
596#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
597pub struct TsTypeLit {
598 pub span: Span,
599 pub members: Vec<TsTypeElement>,
600}
601
602#[ast_node("TsArrayType")]
603#[derive(Eq, Hash, EqIgnoreSpan)]
604#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
605#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
606pub struct TsArrayType {
607 pub span: Span,
608 pub elem_type: Box<TsType>,
609}
610
611#[ast_node("TsTupleType")]
612#[derive(Eq, Hash, EqIgnoreSpan)]
613#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
614#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
615pub struct TsTupleType {
616 pub span: Span,
617 pub elem_types: Vec<TsTupleElement>,
618}
619
620#[ast_node("TsTupleElement")]
621#[derive(Eq, Hash, EqIgnoreSpan)]
622#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
623#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
624pub struct TsTupleElement {
625 pub span: Span,
626 pub label: Option<Pat>,
628 pub ty: Box<TsType>,
629}
630
631#[ast_node("TsOptionalType")]
632#[derive(Eq, Hash, EqIgnoreSpan)]
633#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
634#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
635pub struct TsOptionalType {
636 pub span: Span,
637 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
638 pub type_ann: Box<TsType>,
639}
640
641#[ast_node("TsRestType")]
642#[derive(Eq, Hash, EqIgnoreSpan)]
643#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
644#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
645pub struct TsRestType {
646 pub span: Span,
647 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
648 pub type_ann: Box<TsType>,
649}
650
651#[ast_node]
652#[derive(Eq, Hash, Is, EqIgnoreSpan)]
653#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
654#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
655pub enum TsUnionOrIntersectionType {
656 #[tag("TsUnionType")]
657 TsUnionType(TsUnionType),
658
659 #[tag("TsIntersectionType")]
660 TsIntersectionType(TsIntersectionType),
661}
662
663#[ast_node("TsUnionType")]
664#[derive(Eq, Hash, EqIgnoreSpan)]
665#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
666#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
667pub struct TsUnionType {
668 pub span: Span,
669 pub types: Vec<Box<TsType>>,
670}
671
672#[ast_node("TsIntersectionType")]
673#[derive(Eq, Hash, EqIgnoreSpan)]
674#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
675#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
676pub struct TsIntersectionType {
677 pub span: Span,
678 pub types: Vec<Box<TsType>>,
679}
680
681#[ast_node("TsConditionalType")]
682#[derive(Eq, Hash, EqIgnoreSpan)]
683#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
684#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
685pub struct TsConditionalType {
686 pub span: Span,
687 pub check_type: Box<TsType>,
688 pub extends_type: Box<TsType>,
689 pub true_type: Box<TsType>,
690 pub false_type: Box<TsType>,
691}
692
693#[ast_node("TsInferType")]
694#[derive(Eq, Hash, EqIgnoreSpan)]
695#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
696#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
697pub struct TsInferType {
698 pub span: Span,
699 pub type_param: TsTypeParam,
700}
701
702#[ast_node("TsParenthesizedType")]
703#[derive(Eq, Hash, EqIgnoreSpan)]
704#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
705#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
706pub struct TsParenthesizedType {
707 pub span: Span,
708 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
709 pub type_ann: Box<TsType>,
710}
711
712#[ast_node("TsTypeOperator")]
713#[derive(Eq, Hash, EqIgnoreSpan)]
714#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
715#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
716pub struct TsTypeOperator {
717 pub span: Span,
718 pub op: TsTypeOperatorOp,
719 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
720 pub type_ann: Box<TsType>,
721}
722
723#[derive(StringEnum, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)]
724#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
725#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
726#[cfg_attr(
727 any(feature = "rkyv-impl"),
728 derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
729)]
730#[cfg_attr(feature = "rkyv-impl", derive(bytecheck::CheckBytes))]
731#[cfg_attr(feature = "rkyv-impl", repr(u32))]
732pub enum TsTypeOperatorOp {
733 KeyOf,
735 Unique,
737 ReadOnly,
739}
740
741#[ast_node("TsIndexedAccessType")]
742#[derive(Eq, Hash, EqIgnoreSpan)]
743#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
744#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
745pub struct TsIndexedAccessType {
746 pub span: Span,
747 pub readonly: bool,
748 #[cfg_attr(feature = "serde-impl", serde(rename = "objectType"))]
749 pub obj_type: Box<TsType>,
750 pub index_type: Box<TsType>,
751}
752
753#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)]
754#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
755#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
756#[cfg_attr(
757 any(feature = "rkyv-impl"),
758 derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
759)]
760#[cfg_attr(feature = "rkyv-impl", derive(bytecheck::CheckBytes))]
761#[cfg_attr(feature = "rkyv-impl", repr(u32))]
762pub enum TruePlusMinus {
763 True,
764 Plus,
765 Minus,
766}
767
768#[cfg(feature = "serde-impl")]
769impl Serialize for TruePlusMinus {
770 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
771 where
772 S: ::serde::Serializer,
773 {
774 match *self {
775 TruePlusMinus::True => serializer.serialize_bool(true),
776 TruePlusMinus::Plus => serializer.serialize_str("+"),
777 TruePlusMinus::Minus => serializer.serialize_str("-"),
778 }
779 }
780}
781
782#[cfg(feature = "serde-impl")]
783impl<'de> Deserialize<'de> for TruePlusMinus {
784 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
785 where
786 D: Deserializer<'de>,
787 {
788 struct TruePlusMinusVisitor;
789
790 impl Visitor<'_> for TruePlusMinusVisitor {
791 type Value = TruePlusMinus;
792
793 fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
794 formatter.write_str("one of '+', '-', true")
795 }
796
797 fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
798 where
799 E: de::Error,
800 {
801 match value {
802 "+" => Ok(TruePlusMinus::Plus),
803 "-" => Ok(TruePlusMinus::Minus),
804 "true" => Ok(TruePlusMinus::True),
805 _ => Err(de::Error::invalid_value(Unexpected::Str(value), &self)),
806 }
807 }
808
809 fn visit_bool<E>(self, value: bool) -> Result<Self::Value, E>
810 where
811 E: de::Error,
812 {
813 if value {
814 Ok(TruePlusMinus::True)
815 } else {
816 Err(de::Error::invalid_value(Unexpected::Bool(value), &self))
817 }
818 }
819 }
820
821 deserializer.deserialize_any(TruePlusMinusVisitor)
822 }
823}
824
825#[ast_node("TsMappedType")]
826#[derive(Eq, Hash, EqIgnoreSpan)]
827#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
828#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
829pub struct TsMappedType {
830 pub span: Span,
831 #[cfg_attr(feature = "serde-impl", serde(default))]
832 pub readonly: Option<TruePlusMinus>,
833 pub type_param: TsTypeParam,
834 #[cfg_attr(feature = "serde-impl", serde(default, rename = "nameType"))]
835 pub name_type: Option<Box<TsType>>,
836 #[cfg_attr(feature = "serde-impl", serde(default))]
837 pub optional: Option<TruePlusMinus>,
838 #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeAnnotation"))]
839 pub type_ann: Option<Box<TsType>>,
840}
841
842#[ast_node("TsLiteralType")]
843#[derive(Eq, Hash, EqIgnoreSpan)]
844#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
845#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
846pub struct TsLitType {
847 pub span: Span,
848 #[cfg_attr(feature = "serde-impl", serde(rename = "literal"))]
849 pub lit: TsLit,
850}
851
852#[ast_node]
853#[derive(Eq, Hash, Is, EqIgnoreSpan)]
854#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
855#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
856pub enum TsLit {
857 #[tag("NumericLiteral")]
858 Number(Number),
859
860 #[tag("StringLiteral")]
861 Str(Str),
862
863 #[tag("BooleanLiteral")]
864 Bool(Bool),
865
866 #[tag("BigIntLiteral")]
867 BigInt(BigInt),
868
869 #[tag("TemplateLiteral")]
870 Tpl(TsTplLitType),
871}
872
873#[ast_node("TemplateLiteral")]
874#[derive(Eq, Hash, EqIgnoreSpan)]
875#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
876#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
877pub struct TsTplLitType {
878 pub span: Span,
879
880 pub types: Vec<Box<TsType>>,
881
882 pub quasis: Vec<TplElement>,
883}
884
885#[ast_node("TsInterfaceDeclaration")]
890#[derive(Eq, Hash, EqIgnoreSpan)]
891#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
892#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
893pub struct TsInterfaceDecl {
894 pub span: Span,
895 pub id: Ident,
896 pub declare: bool,
897 #[cfg_attr(feature = "serde-impl", serde(default))]
898 pub type_params: Option<Box<TsTypeParamDecl>>,
899 pub extends: Vec<TsExprWithTypeArgs>,
900 pub body: TsInterfaceBody,
901}
902
903#[ast_node("TsInterfaceBody")]
904#[derive(Eq, Hash, EqIgnoreSpan)]
905#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
906#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
907pub struct TsInterfaceBody {
908 pub span: Span,
909 pub body: Vec<TsTypeElement>,
910}
911
912#[ast_node("TsExpressionWithTypeArguments")]
913#[derive(Eq, Hash, EqIgnoreSpan)]
914#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
915#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
916pub struct TsExprWithTypeArgs {
917 pub span: Span,
918 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
919 pub expr: Box<Expr>,
920 #[cfg_attr(feature = "serde-impl", serde(default, rename = "typeArguments"))]
921 pub type_args: Option<Box<TsTypeParamInstantiation>>,
922}
923
924#[ast_node("TsTypeAliasDeclaration")]
925#[derive(Eq, Hash, EqIgnoreSpan)]
926#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
927#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
928pub struct TsTypeAliasDecl {
929 pub span: Span,
930 pub declare: bool,
931 pub id: Ident,
932 #[cfg_attr(feature = "serde-impl", serde(default))]
933 pub type_params: Option<Box<TsTypeParamDecl>>,
934 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
935 pub type_ann: Box<TsType>,
936}
937
938#[ast_node("TsEnumDeclaration")]
939#[derive(Eq, Hash, EqIgnoreSpan)]
940#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
941#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
942pub struct TsEnumDecl {
943 pub span: Span,
944 pub declare: bool,
945 pub is_const: bool,
946 pub id: Ident,
947 pub members: Vec<TsEnumMember>,
948}
949
950#[ast_node("TsEnumMember")]
951#[derive(Eq, Hash, EqIgnoreSpan)]
952#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
953#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
954pub struct TsEnumMember {
955 pub span: Span,
956 pub id: TsEnumMemberId,
957 #[cfg_attr(feature = "serde-impl", serde(default))]
958 pub init: Option<Box<Expr>>,
959}
960
961#[ast_node]
964#[derive(Eq, Hash, Is, EqIgnoreSpan)]
965#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
966#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
967pub enum TsEnumMemberId {
968 #[tag("Identifier")]
969 Ident(Ident),
970
971 #[tag("StringLiteral")]
972 Str(Str),
973}
974
975impl AsRef<Atom> for TsEnumMemberId {
976 fn as_ref(&self) -> &Atom {
977 match &self {
978 TsEnumMemberId::Str(Str { value: ref sym, .. })
979 | TsEnumMemberId::Ident(Ident { ref sym, .. }) => sym,
980 }
981 }
982}
983
984#[ast_node("TsModuleDeclaration")]
985#[derive(Eq, Hash, EqIgnoreSpan)]
986#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
987#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
988pub struct TsModuleDecl {
989 pub span: Span,
990 pub declare: bool,
991 pub global: bool,
993 pub namespace: bool,
994
995 pub id: TsModuleName,
996 #[cfg_attr(feature = "serde-impl", serde(default))]
997 pub body: Option<TsNamespaceBody>,
998}
999
1000#[ast_node]
1003#[derive(Eq, Hash, Is, EqIgnoreSpan)]
1004#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1005#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1006pub enum TsNamespaceBody {
1007 #[tag("TsModuleBlock")]
1008 TsModuleBlock(TsModuleBlock),
1009
1010 #[tag("TsNamespaceDeclaration")]
1011 TsNamespaceDecl(TsNamespaceDecl),
1012}
1013
1014#[ast_node("TsModuleBlock")]
1015#[derive(Eq, Hash, EqIgnoreSpan)]
1016#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1017#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1018pub struct TsModuleBlock {
1019 pub span: Span,
1020 pub body: Vec<ModuleItem>,
1021}
1022
1023#[ast_node("TsNamespaceDeclaration")]
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 TsNamespaceDecl {
1028 pub span: Span,
1029 pub declare: bool,
1030 pub global: bool,
1032 pub id: Ident,
1033 pub body: Box<TsNamespaceBody>,
1034}
1035
1036#[ast_node]
1037#[derive(Eq, Hash, Is, EqIgnoreSpan)]
1038#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1039#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1040pub enum TsModuleName {
1041 #[tag("Identifier")]
1042 Ident(Ident),
1043
1044 #[tag("StringLiteral")]
1045 Str(Str),
1046}
1047
1048#[ast_node("TsImportEqualsDeclaration")]
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 TsImportEqualsDecl {
1053 pub span: Span,
1054 pub is_export: bool,
1055 pub is_type_only: bool,
1056 pub id: Ident,
1057 pub module_ref: TsModuleRef,
1058}
1059
1060#[ast_node]
1061#[derive(Eq, Hash, Is, EqIgnoreSpan)]
1062#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1063#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1064pub enum TsModuleRef {
1065 #[tag("TsQualifiedName")]
1066 #[tag("Identifier")]
1067 TsEntityName(TsEntityName),
1068
1069 #[tag("TsExternalModuleReference")]
1070 TsExternalModuleRef(TsExternalModuleRef),
1071}
1072
1073#[ast_node("TsExternalModuleReference")]
1074#[derive(Eq, Hash, EqIgnoreSpan)]
1075#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1076#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1077pub struct TsExternalModuleRef {
1078 pub span: Span,
1079 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1080 pub expr: Str,
1081}
1082
1083#[ast_node("TsExportAssignment")]
1087#[derive(Eq, Hash, EqIgnoreSpan)]
1088#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1089#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1090pub struct TsExportAssignment {
1091 pub span: Span,
1092 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1093 pub expr: Box<Expr>,
1094}
1095
1096#[ast_node("TsNamespaceExportDeclaration")]
1097#[derive(Eq, Hash, EqIgnoreSpan)]
1098#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1099#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1100pub struct TsNamespaceExportDecl {
1101 pub span: Span,
1102 pub id: Ident,
1103}
1104
1105#[ast_node("TsAsExpression")]
1110#[derive(Eq, Hash, EqIgnoreSpan)]
1111#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1112#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1113pub struct TsAsExpr {
1114 pub span: Span,
1115 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1116 pub expr: Box<Expr>,
1117 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
1118 pub type_ann: Box<TsType>,
1119}
1120
1121#[ast_node("TsTypeAssertion")]
1122#[derive(Eq, Hash, EqIgnoreSpan)]
1123#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1124#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1125pub struct TsTypeAssertion {
1126 pub span: Span,
1127 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1128 pub expr: Box<Expr>,
1129 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
1130 pub type_ann: Box<TsType>,
1131}
1132
1133#[ast_node("TsNonNullExpression")]
1134#[derive(Eq, Hash, EqIgnoreSpan)]
1135#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1136#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1137pub struct TsNonNullExpr {
1138 pub span: Span,
1139 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1140 pub expr: Box<Expr>,
1141}
1142
1143#[ast_node("TsSatisfiesExpression")]
1144#[derive(Eq, Hash, EqIgnoreSpan)]
1145#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1146#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1147pub struct TsSatisfiesExpr {
1148 pub span: Span,
1149 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1150 pub expr: Box<Expr>,
1151 #[cfg_attr(feature = "serde-impl", serde(rename = "typeAnnotation"))]
1152 pub type_ann: Box<TsType>,
1153}
1154
1155#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EqIgnoreSpan)]
1156#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1157#[cfg_attr(
1158 any(feature = "rkyv-impl"),
1159 derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
1160)]
1161#[cfg_attr(feature = "rkyv-impl", derive(bytecheck::CheckBytes))]
1162#[cfg_attr(feature = "rkyv-impl", repr(u32))]
1163#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
1164#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1165pub enum Accessibility {
1166 #[cfg_attr(feature = "serde-impl", serde(rename = "public"))]
1167 Public,
1168 #[cfg_attr(feature = "serde-impl", serde(rename = "protected"))]
1169 Protected,
1170 #[cfg_attr(feature = "serde-impl", serde(rename = "private"))]
1171 Private,
1172}
1173
1174#[ast_node("TsConstAssertion")]
1175#[derive(Eq, Hash, EqIgnoreSpan)]
1176#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1177#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1178pub struct TsConstAssertion {
1179 pub span: Span,
1180 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1181 pub expr: Box<Expr>,
1182}
1183
1184#[ast_node("TsInstantiation")]
1185#[derive(Eq, Hash, EqIgnoreSpan)]
1186#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1187#[cfg_attr(feature = "shrink-to-fit", derive(shrink_to_fit::ShrinkToFit))]
1188pub struct TsInstantiation {
1189 pub span: Span,
1190 #[cfg_attr(feature = "serde-impl", serde(rename = "expression"))]
1191 pub expr: Box<Expr>,
1192 #[cfg_attr(feature = "serde-impl", serde(rename = "typeArguments"))]
1193 pub type_args: Box<TsTypeParamInstantiation>,
1194}