Handle PropertyAssignment in getCommentOwnerInfo (#25911)

This commit is contained in:
Andy
2018-07-24 17:43:46 -07:00
committed by GitHub
parent fd2eb4918d
commit e4d4b0ae4b
3 changed files with 60 additions and 38 deletions
+10
View File
@@ -142,6 +142,16 @@ namespace ts {
return undefined;
}
export function forEachAncestor<T>(node: Node, callback: (n: Node) => T | undefined | "quit"): T | undefined {
while (true) {
const res = callback(node);
if (res === "quit") return undefined;
if (res !== undefined) return res;
if (isSourceFile(node)) return undefined;
node = node.parent;
}
}
/**
* Calls `callback` for each entry in the map, returning the first truthy result.
* Use `map.forEach` instead for normal iteration.