File tree Expand file tree Collapse file tree
Open diff view settings
Expand file tree Collapse file tree
Open diff view settings
Original file line number Diff line number Diff line change @@ -1300,7 +1300,7 @@ namespace ts {
13001300 return <ImportEqualsDeclaration>node;
13011301 }
13021302
1303- return findAncestor(node, n => n.kind === SyntaxKind.ImportDeclaration) as ImportDeclaration ;
1303+ return findAncestor(node, isImportDeclaration) ;
13041304 }
13051305 }
13061306
@@ -22638,7 +22638,7 @@ namespace ts {
2263822638 const symbolIsUmdExport = symbolFile !== referenceFile;
2263922639 return symbolIsUmdExport ? undefined : symbolFile;
2264022640 }
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);
2264222642 }
2264322643 }
2264422644 }
Original file line number Diff line number Diff line change @@ -230,6 +230,8 @@ namespace ts {
230230 * If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit"
231231 * At that point findAncestor returns undefined.
232232 */
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 ;
233235 export function findAncestor ( node : Node , callback : ( element : Node ) => boolean | "quit" ) : Node {
234236 while ( node ) {
235237 const result = callback ( node ) ;
Original file line number Diff line number Diff line change @@ -4010,6 +4010,10 @@ namespace ts {
40104010 return node . kind === SyntaxKind . ImportEqualsDeclaration ;
40114011 }
40124012
4013+ export function isImportDeclaration ( node : Node ) : node is ImportDeclaration {
4014+ return node . kind === SyntaxKind . ImportDeclaration ;
4015+ }
4016+
40134017 export function isImportClause ( node : Node ) : node is ImportClause {
40144018 return node . kind === SyntaxKind . ImportClause ;
40154019 }
You can’t perform that action at this time.
0 commit comments