Fix Node#getStart(sourceFile, true) throwing when node has a js doc and no parent (#37439)

* Fix missing source file argument.

* Add test

* fix lint

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
David SherretandNathan Shively-Sanders authored and GitHub committed 2020-03-17 16:08:57 -07:00
1 parent c600aa7411
commit 48e1745d6d
2 files changed
+5 -1

No files matched your search

+1 -1
View File
@@ -510,7 +510,7 @@ namespace ts {
}
if (includeJsDoc && hasJSDocNodes(node)) {
return getTokenPosOfNode(node.jsDoc![0]);
return getTokenPosOfNode(node.jsDoc![0], sourceFile);
}
// For a syntax list, it is possible that one of its children has JSDocComment nodes, while
+4
View File
@@ -342,5 +342,9 @@ namespace ts {
assert.equal(last!.kind, SyntaxKind.EndOfFileToken);
});
});
describe("getStart of node with JSDoc but no parent pointers", () => {
const root = createSourceFile("foo.ts", "/** */var a = true;", ScriptTarget.ES5, /*setParentNodes*/ false);
root.statements[0].getStart(root, /*includeJsdocComment*/ true);
});
});
}