@@ -12,7 +12,42 @@ namespace ts {
12
12
* @param optional An optional value indicating whether the Node is itself optional.
13
13
* @param lift An optional callback to execute to lift a NodeArray into a valid Node.
14
14
*/
15
- export function visitNode < T extends Node > ( node : T , visitor : Visitor , test : ( node : Node ) => boolean , optional ?: boolean , lift ?: ( node : NodeArray < Node > ) => T ) : T {
15
+ export function visitNode < T extends Node > ( node : T , visitor : Visitor , test : ( node : Node ) => node is T , optional ?: boolean , lift ?: ( node : NodeArray < Node > ) => T ) : T ;
16
+
17
+ /**
18
+ * Visits a Node using the supplied visitor, possibly returning a new Node in its place.
19
+ *
20
+ * @param node The Node to visit.
21
+ * @param visitor The callback used to visit the Node.
22
+ * @param test A callback to execute to verify the Node is valid.
23
+ * @param optional An optional value indicating whether the Node is itself optional.
24
+ * @param lift An optional callback to execute to lift a NodeArray into a valid Node.
25
+ */
26
+ export function visitNode < T extends Node > ( node : T , visitor : Visitor , test ?: ( node : Node ) => boolean , optional ?: boolean , lift ?: ( node : NodeArray < Node > ) => T ) : T ;
27
+
28
+ /**
29
+ * Visits a Node using the supplied visitor, possibly returning a new Node in its place.
30
+ *
31
+ * @param node The Node to visit.
32
+ * @param visitor The callback used to visit the Node.
33
+ * @param test A callback to execute to verify the Node is valid.
34
+ * @param optional An optional value indicating whether the Node is itself optional.
35
+ * @param lift An optional callback to execute to lift a NodeArray into a valid Node.
36
+ */
37
+ export function visitNode < T extends Node > ( node : T | undefined , visitor : Visitor , test : ( node : Node ) => node is T , optional ?: boolean , lift ?: ( node : NodeArray < Node > ) => T ) : T | undefined ;
38
+
39
+ /**
40
+ * Visits a Node using the supplied visitor, possibly returning a new Node in its place.
41
+ *
42
+ * @param node The Node to visit.
43
+ * @param visitor The callback used to visit the Node.
44
+ * @param test A callback to execute to verify the Node is valid.
45
+ * @param optional An optional value indicating whether the Node is itself optional.
46
+ * @param lift An optional callback to execute to lift a NodeArray into a valid Node.
47
+ */
48
+ export function visitNode < T extends Node > ( node : T | undefined , visitor : Visitor , test ?: ( node : Node ) => boolean , optional ?: boolean , lift ?: ( node : NodeArray < Node > ) => T ) : T | undefined ;
49
+
50
+ export function visitNode < T extends Node | undefined > ( node : T , visitor : Visitor , test ?: ( node : Node ) => boolean , optional ?: boolean , lift ?: ( node : NodeArray < Node > ) => T ) : T {
16
51
if ( node === undefined || visitor === undefined ) {
17
52
return node ;
18
53
}
@@ -52,7 +87,51 @@ namespace ts {
52
87
* @param start An optional value indicating the starting offset at which to start visiting.
53
88
* @param count An optional value indicating the maximum number of nodes to visit.
54
89
*/
55
- export function visitNodes < T extends Node > ( nodes : NodeArray < T > , visitor : Visitor , test : ( node : Node ) => boolean , start ?: number , count ?: number ) : NodeArray < T > {
90
+ export function visitNodes < T extends Node > ( nodes : NodeArray < T > , visitor : Visitor , test : ( node : Node ) => node is T , start ?: number , count ?: number ) : NodeArray < T > ;
91
+
92
+ /**
93
+ * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place.
94
+ *
95
+ * @param nodes The NodeArray to visit.
96
+ * @param visitor The callback used to visit a Node.
97
+ * @param test A node test to execute for each node.
98
+ * @param start An optional value indicating the starting offset at which to start visiting.
99
+ * @param count An optional value indicating the maximum number of nodes to visit.
100
+ */
101
+ export function visitNodes < T extends Node > ( nodes : NodeArray < T > , visitor : Visitor , test ?: ( node : Node ) => boolean , start ?: number , count ?: number ) : NodeArray < T > ;
102
+
103
+ /**
104
+ * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place.
105
+ *
106
+ * @param nodes The NodeArray to visit.
107
+ * @param visitor The callback used to visit a Node.
108
+ * @param test A node test to execute for each node.
109
+ * @param start An optional value indicating the starting offset at which to start visiting.
110
+ * @param count An optional value indicating the maximum number of nodes to visit.
111
+ */
112
+ export function visitNodes < T extends Node > ( nodes : NodeArray < T > | undefined , visitor : Visitor , test : ( node : Node ) => node is T , start ?: number , count ?: number ) : NodeArray < T > | undefined ;
113
+
114
+ /**
115
+ * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place.
116
+ *
117
+ * @param nodes The NodeArray to visit.
118
+ * @param visitor The callback used to visit a Node.
119
+ * @param test A node test to execute for each node.
120
+ * @param start An optional value indicating the starting offset at which to start visiting.
121
+ * @param count An optional value indicating the maximum number of nodes to visit.
122
+ */
123
+ export function visitNodes < T extends Node > ( nodes : NodeArray < T > | undefined , visitor : Visitor , test ?: ( node : Node ) => boolean , start ?: number , count ?: number ) : NodeArray < T > | undefined ;
124
+
125
+ /**
126
+ * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place.
127
+ *
128
+ * @param nodes The NodeArray to visit.
129
+ * @param visitor The callback used to visit a Node.
130
+ * @param test A node test to execute for each node.
131
+ * @param start An optional value indicating the starting offset at which to start visiting.
132
+ * @param count An optional value indicating the maximum number of nodes to visit.
133
+ */
134
+ export function visitNodes < T extends Node > ( nodes : NodeArray < T > | undefined , visitor : Visitor , test ?: ( node : Node ) => boolean , start ?: number , count ?: number ) : NodeArray < T > | undefined {
56
135
if ( nodes === undefined || visitor === undefined ) {
57
136
return nodes ;
58
137
}
@@ -137,6 +216,11 @@ namespace ts {
137
216
* environment and merging hoisted declarations upon completion.
138
217
*/
139
218
export function visitFunctionBody ( node : FunctionBody , visitor : Visitor , context : TransformationContext ) : FunctionBody ;
219
+ /**
220
+ * Resumes a suspended lexical environment and visits a function body, ending the lexical
221
+ * environment and merging hoisted declarations upon completion.
222
+ */
223
+ export function visitFunctionBody ( node : FunctionBody | undefined , visitor : Visitor , context : TransformationContext ) : FunctionBody | undefined ;
140
224
/**
141
225
* Resumes a suspended lexical environment and visits a concise body, ending the lexical
142
226
* environment and merging hoisted declarations upon completion.
@@ -162,6 +246,16 @@ namespace ts {
162
246
* @param context A lexical environment context for the visitor.
163
247
*/
164
248
export function visitEachChild < T extends Node > ( node : T , visitor : Visitor , context : TransformationContext ) : T ;
249
+
250
+ /**
251
+ * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place.
252
+ *
253
+ * @param node The Node whose children will be visited.
254
+ * @param visitor The callback used to visit each child.
255
+ * @param context A lexical environment context for the visitor.
256
+ */
257
+ export function visitEachChild < T extends Node > ( node : T | undefined , visitor : Visitor , context : TransformationContext ) : T | undefined ;
258
+
165
259
export function visitEachChild ( node : Node , visitor : Visitor , context : TransformationContext ) : Node {
166
260
if ( node === undefined ) {
167
261
return undefined ;
@@ -317,7 +411,7 @@ namespace ts {
317
411
case SyntaxKind . FunctionExpression :
318
412
return updateFunctionExpression ( < FunctionExpression > node ,
319
413
visitNodes ( ( < FunctionExpression > node ) . modifiers , visitor , isModifier ) ,
320
- visitNode ( ( < FunctionExpression > node ) . name , visitor , isPropertyName ) ,
414
+ visitNode ( ( < FunctionExpression > node ) . name , visitor , isIdentifier , /*optional*/ true ) ,
321
415
visitNodes ( ( < FunctionExpression > node ) . typeParameters , visitor , isTypeParameter ) ,
322
416
visitParameterList ( ( < FunctionExpression > node ) . parameters , visitor , context ) ,
323
417
visitNode ( ( < FunctionExpression > node ) . type , visitor , isTypeNode , /*optional*/ true ) ,
@@ -508,7 +602,7 @@ namespace ts {
508
602
return updateFunctionDeclaration ( < FunctionDeclaration > node ,
509
603
visitNodes ( ( < FunctionDeclaration > node ) . decorators , visitor , isDecorator ) ,
510
604
visitNodes ( ( < FunctionDeclaration > node ) . modifiers , visitor , isModifier ) ,
511
- visitNode ( ( < FunctionDeclaration > node ) . name , visitor , isPropertyName ) ,
605
+ visitNode ( ( < FunctionDeclaration > node ) . name , visitor , isIdentifier , /*optional*/ true ) ,
512
606
visitNodes ( ( < FunctionDeclaration > node ) . typeParameters , visitor , isTypeParameter ) ,
513
607
visitParameterList ( ( < FunctionDeclaration > node ) . parameters , visitor , context ) ,
514
608
visitNode ( ( < FunctionDeclaration > node ) . type , visitor , isTypeNode , /*optional*/ true ) ,
0 commit comments