Simplify addJSDocComment (#25196)

* Simplify addJSDocComment

* Add assert
This commit is contained in:
Andy
2018-06-25 11:36:37 -07:00
committed by GitHub
parent 62e5541a66
commit 4c326b2b6c

View File

@@ -864,13 +864,9 @@ namespace ts {
}
function addJSDocComment<T extends HasJSDoc>(node: T): T {
const comments = getJSDocCommentRanges(node, sourceFile.text);
if (comments) {
for (const comment of comments) {
node.jsDoc = append<JSDoc>(node.jsDoc, JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos));
}
}
Debug.assert(!node.jsDoc); // Should only be called once per node
const jsDoc = mapDefined(getJSDocCommentRanges(node, sourceFile.text), comment => JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos));
if (jsDoc.length) node.jsDoc = jsDoc;
return node;
}