mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 05:41:22 -06:00
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:
parent
c600aa7411
commit
48e1745d6d
@ -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
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user