diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8f0cabdfc44..2acaa3200fb 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -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 diff --git a/src/testRunner/unittests/jsDocParsing.ts b/src/testRunner/unittests/jsDocParsing.ts index 117e8b51a66..0af076df762 100644 --- a/src/testRunner/unittests/jsDocParsing.ts +++ b/src/testRunner/unittests/jsDocParsing.ts @@ -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); + }); }); }