File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1300,7 +1300,7 @@ namespace ts {
1300
1300
return <ImportEqualsDeclaration>node;
1301
1301
}
1302
1302
1303
- return findAncestor(node, n => n.kind === SyntaxKind.ImportDeclaration) as ImportDeclaration ;
1303
+ return findAncestor(node, isImportDeclaration) ;
1304
1304
}
1305
1305
}
1306
1306
@@ -22638,7 +22638,7 @@ namespace ts {
22638
22638
const symbolIsUmdExport = symbolFile !== referenceFile;
22639
22639
return symbolIsUmdExport ? undefined : symbolFile;
22640
22640
}
22641
- return findAncestor(node.parent, n => isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) as ModuleDeclaration | EnumDeclaration ;
22641
+ return findAncestor(node.parent, (n): n is ModuleDeclaration | EnumDeclaration => isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol);
22642
22642
}
22643
22643
}
22644
22644
}
Original file line number Diff line number Diff line change @@ -230,6 +230,8 @@ namespace ts {
230
230
* If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit"
231
231
* At that point findAncestor returns undefined.
232
232
*/
233
+ export function findAncestor < T extends Node > ( node : Node , callback : ( element : Node ) => element is T ) : T | undefined ;
234
+ export function findAncestor ( node : Node , callback : ( element : Node ) => boolean | "quit" ) : Node | undefined ;
233
235
export function findAncestor ( node : Node , callback : ( element : Node ) => boolean | "quit" ) : Node {
234
236
while ( node ) {
235
237
const result = callback ( node ) ;
Original file line number Diff line number Diff line change @@ -4010,6 +4010,10 @@ namespace ts {
4010
4010
return node . kind === SyntaxKind . ImportEqualsDeclaration ;
4011
4011
}
4012
4012
4013
+ export function isImportDeclaration ( node : Node ) : node is ImportDeclaration {
4014
+ return node . kind === SyntaxKind . ImportDeclaration ;
4015
+ }
4016
+
4013
4017
export function isImportClause ( node : Node ) : node is ImportClause {
4014
4018
return node . kind === SyntaxKind . ImportClause ;
4015
4019
}
You can’t perform that action at this time.
0 commit comments