-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptBugA bug in TypeScriptA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generation
Milestone
Description
TypeScript Version: 3.2.0-dev.20181103
Search Terms: jsdoc no parent
Code
import * as ts from "typescript";
console.log(ts.version);
const testFilePath = "/file.ts";
const testFileText = `
class Test {
/** @internal */
test() {
}
}
`;
const testSourceFile = ts.createSourceFile(testFilePath, testFileText, ts.ScriptTarget.Latest, true);
const classDec = testSourceFile.statements.find(ts.isClassDeclaration)!;
const method = classDec.members.find(ts.isMethodDeclaration)!;
const tag = ts.getJSDocTags(method)[0];
const tagName = tag.tagName; // also happens with atToken
console.log(tag.parent != null); // true, good
console.log(tagName.parent); // undefined, problem
Expected behavior: Should return the tag
as the parent.
Actual behavior: Returns undefined.
IdentifierObject {
pos: 23,
end: 31,
flags: 0,
parent: undefined,
escapedText: 'internal'
}
Fix?
I believe the fix here would be to have forEachChild
visit the tagName
and atToken
for JSDocTag
s and the nodes that extend them. I'm not sure though...
tag.forEachChild(node => {
console.log("here"); // never happens
});
Metadata
Metadata
Assignees
Labels
APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptBugA bug in TypeScriptA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generation