File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -617,7 +617,8 @@ export class Node<NodeType extends ts.Node = ts.Node> {
617
617
if ( stop || skip || up )
618
618
return ;
619
619
620
- forEachChildForNode ( node ) ;
620
+ if ( ! node . wasForgotten ( ) )
621
+ forEachChildForNode ( node ) ;
621
622
} ;
622
623
const arrayCallback = cbNodeArray == null ? undefined : ( nodes : Node [ ] ) => {
623
624
if ( stop )
Original file line number Diff line number Diff line change @@ -1455,6 +1455,23 @@ class MyClass {
1455
1455
"" // end of file token
1456
1456
] ) ;
1457
1457
} ) ;
1458
+
1459
+ it ( "should not error when the current node is forgotten/removed" , ( ) => {
1460
+ const { sourceFile} = getInfoFromText ( "class Test {} interface Test2 {}" ) ;
1461
+ const nodeTexts : string [ ] = [ ] ;
1462
+ sourceFile . forEachDescendant ( node => {
1463
+ nodeTexts . push ( node . getText ( ) ) ;
1464
+ if ( TypeGuards . isClassDeclaration ( node ) )
1465
+ node . remove ( ) ;
1466
+ } ) ;
1467
+
1468
+ expect ( nodeTexts ) . to . deep . equal ( [
1469
+ "class Test {}" ,
1470
+ "interface Test2 {}" ,
1471
+ "Test2" ,
1472
+ "" // end of file token
1473
+ ] ) ;
1474
+ } ) ;
1458
1475
} ) ;
1459
1476
1460
1477
describe ( nameof < Node > ( n => n . getNodeProperty ) , ( ) => {
You can’t perform that action at this time.
0 commit comments