@@ -3,7 +3,7 @@ import { describe, it } from 'mocha';
33
44import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery' ;
55
6- import type { ASTNode } from '../ast' ;
6+ import type { ASTNode , SelectionSetNode } from '../ast' ;
77import { isNode } from '../ast' ;
88import { Kind } from '../kinds' ;
99import { parse } from '../parser' ;
@@ -51,8 +51,7 @@ function checkVisitorFnArgs(ast: any, args: any, isEdited: boolean = false) {
5151}
5252
5353function getValue ( node : ASTNode ) {
54- // @ts -expect-error FIXME: TS Conversion
55- return node . value != null ? node . value : undefined ;
54+ return 'value' in node ? node . value : undefined ;
5655}
5756
5857describe ( 'Visitor' , ( ) => {
@@ -62,7 +61,7 @@ describe('Visitor', () => {
6261 } ) ;
6362
6463 it ( 'validates path argument' , ( ) => {
65- const visited = [ ] ;
64+ const visited : Array < any > = [ ] ;
6665
6766 const ast = parse ( '{ a }' , { noLocation : true } ) ;
6867
@@ -93,7 +92,7 @@ describe('Visitor', () => {
9392
9493 it ( 'validates ancestors argument' , ( ) => {
9594 const ast = parse ( '{ a }' , { noLocation : true } ) ;
96- const visitedNodes = [ ] ;
95+ const visitedNodes : Array < any > = [ ] ;
9796
9897 visit ( ast , {
9998 enter ( node , key , parent , _path , ancestors ) {
@@ -122,7 +121,7 @@ describe('Visitor', () => {
122121 it ( 'allows editing a node both on enter and on leave' , ( ) => {
123122 const ast = parse ( '{ a, b, c { a, b, c } }' , { noLocation : true } ) ;
124123
125- let selectionSet ;
124+ let selectionSet : SelectionSetNode ;
126125
127126 const editedAST = visit ( ast , {
128127 OperationDefinition : {
@@ -265,8 +264,7 @@ describe('Visitor', () => {
265264 if ( node . kind === 'Field' && node . name . value === 'a' ) {
266265 return {
267266 kind : 'Field' ,
268- // @ts -expect-error FIXME: TS Conversion
269- selectionSet : [ addedField ] . concat ( node . selectionSet ) ,
267+ selectionSet : [ addedField , node . selectionSet ] ,
270268 } ;
271269 }
272270 if ( node === addedField ) {
@@ -279,7 +277,7 @@ describe('Visitor', () => {
279277 } ) ;
280278
281279 it ( 'allows skipping a sub-tree' , ( ) => {
282- const visited = [ ] ;
280+ const visited : Array < any > = [ ] ;
283281
284282 const ast = parse ( '{ a, b { x }, c }' , { noLocation : true } ) ;
285283 visit ( ast , {
@@ -317,7 +315,7 @@ describe('Visitor', () => {
317315 } ) ;
318316
319317 it ( 'allows early exit while visiting' , ( ) => {
320- const visited = [ ] ;
318+ const visited : Array < any > = [ ] ;
321319
322320 const ast = parse ( '{ a, b { x }, c }' , { noLocation : true } ) ;
323321 visit ( ast , {
@@ -352,7 +350,7 @@ describe('Visitor', () => {
352350 } ) ;
353351
354352 it ( 'allows early exit while leaving' , ( ) => {
355- const visited = [ ] ;
353+ const visited : Array < any > = [ ] ;
356354
357355 const ast = parse ( '{ a, b { x }, c }' , { noLocation : true } ) ;
358356 visit ( ast , {
@@ -389,7 +387,7 @@ describe('Visitor', () => {
389387 } ) ;
390388
391389 it ( 'allows a named functions visitor API' , ( ) => {
392- const visited = [ ] ;
390+ const visited : Array < any > = [ ] ;
393391
394392 const ast = parse ( '{ a, b { x }, c }' , { noLocation : true } ) ;
395393 visit ( ast , {
@@ -438,7 +436,7 @@ describe('Visitor', () => {
438436 } ,
439437 } ) ;
440438
441- const visited = [ ] ;
439+ const visited : Array < any > = [ ] ;
442440 visit ( customAST , {
443441 enter ( node ) {
444442 visited . push ( [ 'enter' , node . kind , getValue ( node ) ] ) ;
@@ -469,7 +467,7 @@ describe('Visitor', () => {
469467 noLocation : true ,
470468 allowLegacyFragmentVariables : true ,
471469 } ) ;
472- const visited = [ ] ;
470+ const visited : Array < any > = [ ] ;
473471
474472 visit ( ast , {
475473 enter ( node ) {
@@ -516,8 +514,8 @@ describe('Visitor', () => {
516514
517515 it ( 'visits kitchen sink' , ( ) => {
518516 const ast = parse ( kitchenSinkQuery ) ;
519- const visited = [ ] ;
520- const argsStack = [ ] ;
517+ const visited : Array < any > = [ ] ;
518+ const argsStack : Array < any > = [ ] ;
521519
522520 visit ( ast , {
523521 enter ( node , key , parent ) {
@@ -895,7 +893,7 @@ describe('Visitor', () => {
895893 // Note: nearly identical to the above test of the same test but
896894 // using visitInParallel.
897895 it ( 'allows skipping a sub-tree' , ( ) => {
898- const visited = [ ] ;
896+ const visited : Array < any > = [ ] ;
899897
900898 const ast = parse ( '{ a, b { x }, c }' ) ;
901899 visit (
@@ -938,7 +936,7 @@ describe('Visitor', () => {
938936 } ) ;
939937
940938 it ( 'allows skipping different sub-trees' , ( ) => {
941- const visited = [ ] ;
939+ const visited : Array < any > = [ ] ;
942940
943941 const ast = parse ( '{ a { x }, b { y} }' ) ;
944942 visit (
@@ -1014,7 +1012,7 @@ describe('Visitor', () => {
10141012 // Note: nearly identical to the above test of the same test but
10151013 // using visitInParallel.
10161014 it ( 'allows early exit while visiting' , ( ) => {
1017- const visited = [ ] ;
1015+ const visited : Array < any > = [ ] ;
10181016
10191017 const ast = parse ( '{ a, b { x }, c }' ) ;
10201018 visit (
@@ -1054,7 +1052,7 @@ describe('Visitor', () => {
10541052 } ) ;
10551053
10561054 it ( 'allows early exit from different points' , ( ) => {
1057- const visited = [ ] ;
1055+ const visited : Array < any > = [ ] ;
10581056
10591057 const ast = parse ( '{ a { y }, b { x } }' ) ;
10601058 visit (
@@ -1116,7 +1114,7 @@ describe('Visitor', () => {
11161114 // Note: nearly identical to the above test of the same test but
11171115 // using visitInParallel.
11181116 it ( 'allows early exit while leaving' , ( ) => {
1119- const visited = [ ] ;
1117+ const visited : Array < any > = [ ] ;
11201118
11211119 const ast = parse ( '{ a, b { x }, c }' ) ;
11221120 visit (
@@ -1157,7 +1155,7 @@ describe('Visitor', () => {
11571155 } ) ;
11581156
11591157 it ( 'allows early exit from leaving different points' , ( ) => {
1160- const visited = [ ] ;
1158+ const visited : Array < any > = [ ] ;
11611159
11621160 const ast = parse ( '{ a { y }, b { x } }' ) ;
11631161 visit (
@@ -1233,7 +1231,7 @@ describe('Visitor', () => {
12331231 } ) ;
12341232
12351233 it ( 'allows for editing on enter' , ( ) => {
1236- const visited = [ ] ;
1234+ const visited : Array < any > = [ ] ;
12371235
12381236 const ast = parse ( '{ a, b, c { a, b, c } }' , { noLocation : true } ) ;
12391237 const editedAST = visit (
@@ -1297,7 +1295,7 @@ describe('Visitor', () => {
12971295 } ) ;
12981296
12991297 it ( 'allows for editing on leave' , ( ) => {
1300- const visited = [ ] ;
1298+ const visited : Array < any > = [ ] ;
13011299
13021300 const ast = parse ( '{ a, b, c { a, b, c } }' , { noLocation : true } ) ;
13031301 const editedAST = visit (
0 commit comments