@@ -23,75 +23,16 @@ impl VisitMut for StripType {
23
23
Box <TsTypeParamInstantiation >
24
24
) ;
25
25
26
- fn visit_mut_module_items ( & mut self , n : & mut Vec < ModuleItem > ) {
27
- n. retain ( should_retain_module_item) ;
28
- n. visit_mut_children_with ( self ) ;
29
- }
30
-
31
- fn visit_mut_import_specifiers ( & mut self , n : & mut Vec < ImportSpecifier > ) {
32
- n. retain ( |s| !matches ! ( s, ImportSpecifier :: Named ( named) if named. is_type_only) ) ;
33
- }
34
-
35
- fn visit_mut_export_specifiers ( & mut self , n : & mut Vec < ExportSpecifier > ) {
36
- n. retain ( |s| match s {
37
- ExportSpecifier :: Named ( ExportNamedSpecifier { is_type_only, .. } ) => !is_type_only,
38
- _ => true ,
39
- } )
40
- }
41
-
42
- fn visit_mut_stmts ( & mut self , n : & mut Vec < Stmt > ) {
43
- n. retain ( should_retain_stmt) ;
44
- n. visit_mut_children_with ( self ) ;
45
- }
46
-
47
- // https://github.com/tc39/proposal-type-annotations#parameter-optionality
48
- fn visit_mut_ident ( & mut self , n : & mut Ident ) {
49
- n. optional = false ;
50
- }
51
-
52
26
fn visit_mut_array_pat ( & mut self , n : & mut ArrayPat ) {
53
27
n. visit_mut_children_with ( self ) ;
54
28
n. optional = false ;
55
29
}
56
30
57
- fn visit_mut_object_pat ( & mut self , pat : & mut ObjectPat ) {
58
- pat. visit_mut_children_with ( self ) ;
59
- pat. optional = false ;
60
- }
61
-
62
- fn visit_mut_expr ( & mut self , n : & mut Expr ) {
63
- // https://github.com/tc39/proposal-type-annotations#type-assertions
64
- // https://github.com/tc39/proposal-type-annotations#non-nullable-assertions
65
- while let Expr :: TsAs ( TsAsExpr { expr, .. } )
66
- | Expr :: TsNonNull ( TsNonNullExpr { expr, .. } )
67
- | Expr :: TsTypeAssertion ( TsTypeAssertion { expr, .. } )
68
- | Expr :: TsConstAssertion ( TsConstAssertion { expr, .. } )
69
- | Expr :: TsInstantiation ( TsInstantiation { expr, .. } )
70
- | Expr :: TsSatisfies ( TsSatisfiesExpr { expr, .. } ) = n
71
- {
72
- * n = * expr. take ( ) ;
73
- }
74
-
75
- n. visit_mut_children_with ( self ) ;
76
- }
77
-
78
- // https://github.com/tc39/proposal-type-annotations#this-parameters
79
- fn visit_mut_params ( & mut self , n : & mut Vec < Param > ) {
80
- if n. first ( )
81
- . filter ( |param| {
82
- matches ! (
83
- & param. pat,
84
- Pat :: Ident ( BindingIdent {
85
- id: Ident { sym, .. } ,
86
- ..
87
- } ) if & * * sym == "this"
88
- )
89
- } )
90
- . is_some ( )
91
- {
92
- n. drain ( 0 ..1 ) ;
93
- }
94
-
31
+ fn visit_mut_auto_accessor ( & mut self , n : & mut AutoAccessor ) {
32
+ n. type_ann = None ;
33
+ n. accessibility = None ;
34
+ n. definite = false ;
35
+ n. is_override = false ;
95
36
n. visit_mut_children_with ( self ) ;
96
37
}
97
38
@@ -130,11 +71,6 @@ impl VisitMut for StripType {
130
71
n. visit_mut_children_with ( self ) ;
131
72
}
132
73
133
- fn visit_mut_constructor ( & mut self , n : & mut Constructor ) {
134
- n. accessibility = None ;
135
- n. visit_mut_children_with ( self ) ;
136
- }
137
-
138
74
fn visit_mut_class_method ( & mut self , n : & mut ClassMethod ) {
139
75
n. accessibility = None ;
140
76
n. is_override = false ;
@@ -153,6 +89,73 @@ impl VisitMut for StripType {
153
89
prop. visit_mut_children_with ( self ) ;
154
90
}
155
91
92
+ fn visit_mut_constructor ( & mut self , n : & mut Constructor ) {
93
+ n. accessibility = None ;
94
+ n. visit_mut_children_with ( self ) ;
95
+ }
96
+
97
+ fn visit_mut_export_specifiers ( & mut self , n : & mut Vec < ExportSpecifier > ) {
98
+ n. retain ( |s| match s {
99
+ ExportSpecifier :: Named ( ExportNamedSpecifier { is_type_only, .. } ) => !is_type_only,
100
+ _ => true ,
101
+ } )
102
+ }
103
+
104
+ fn visit_mut_expr ( & mut self , n : & mut Expr ) {
105
+ // https://github.com/tc39/proposal-type-annotations#type-assertions
106
+ // https://github.com/tc39/proposal-type-annotations#non-nullable-assertions
107
+ while let Expr :: TsAs ( TsAsExpr { expr, .. } )
108
+ | Expr :: TsNonNull ( TsNonNullExpr { expr, .. } )
109
+ | Expr :: TsTypeAssertion ( TsTypeAssertion { expr, .. } )
110
+ | Expr :: TsConstAssertion ( TsConstAssertion { expr, .. } )
111
+ | Expr :: TsInstantiation ( TsInstantiation { expr, .. } )
112
+ | Expr :: TsSatisfies ( TsSatisfiesExpr { expr, .. } ) = n
113
+ {
114
+ * n = * expr. take ( ) ;
115
+ }
116
+
117
+ n. visit_mut_children_with ( self ) ;
118
+ }
119
+
120
+ // https://github.com/tc39/proposal-type-annotations#parameter-optionality
121
+ fn visit_mut_ident ( & mut self , n : & mut Ident ) {
122
+ n. optional = false ;
123
+ }
124
+
125
+ fn visit_mut_import_specifiers ( & mut self , n : & mut Vec < ImportSpecifier > ) {
126
+ n. retain ( |s| !matches ! ( s, ImportSpecifier :: Named ( named) if named. is_type_only) ) ;
127
+ }
128
+
129
+ fn visit_mut_module_items ( & mut self , n : & mut Vec < ModuleItem > ) {
130
+ n. retain ( should_retain_module_item) ;
131
+ n. visit_mut_children_with ( self ) ;
132
+ }
133
+
134
+ fn visit_mut_object_pat ( & mut self , pat : & mut ObjectPat ) {
135
+ pat. visit_mut_children_with ( self ) ;
136
+ pat. optional = false ;
137
+ }
138
+
139
+ // https://github.com/tc39/proposal-type-annotations#this-parameters
140
+ fn visit_mut_params ( & mut self , n : & mut Vec < Param > ) {
141
+ if n. first ( )
142
+ . filter ( |param| {
143
+ matches ! (
144
+ & param. pat,
145
+ Pat :: Ident ( BindingIdent {
146
+ id: Ident { sym, .. } ,
147
+ ..
148
+ } ) if & * * sym == "this"
149
+ )
150
+ } )
151
+ . is_some ( )
152
+ {
153
+ n. drain ( 0 ..1 ) ;
154
+ }
155
+
156
+ n. visit_mut_children_with ( self ) ;
157
+ }
158
+
156
159
fn visit_mut_private_prop ( & mut self , prop : & mut PrivateProp ) {
157
160
prop. readonly = false ;
158
161
prop. is_override = false ;
@@ -162,11 +165,14 @@ impl VisitMut for StripType {
162
165
prop. visit_mut_children_with ( self ) ;
163
166
}
164
167
165
- fn visit_mut_auto_accessor ( & mut self , n : & mut AutoAccessor ) {
166
- n. type_ann = None ;
167
- n. accessibility = None ;
168
- n. definite = false ;
169
- n. is_override = false ;
168
+ fn visit_mut_setter_prop ( & mut self , n : & mut SetterProp ) {
169
+ n. this_param = None ;
170
+
171
+ n. visit_mut_children_with ( self ) ;
172
+ }
173
+
174
+ fn visit_mut_stmts ( & mut self , n : & mut Vec < Stmt > ) {
175
+ n. retain ( should_retain_stmt) ;
170
176
n. visit_mut_children_with ( self ) ;
171
177
}
172
178
0 commit comments