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 JSDocTags and the nodes that extend them. I'm not sure though...
tag.forEachChild(node => {
console.log("here"); // never happens
});
TypeScript Version: 3.2.0-dev.20181103
Search Terms: jsdoc no parent
Code
Expected behavior: Should return the
tagas the parent.Actual behavior: Returns undefined.
Fix?
I believe the fix here would be to have
forEachChildvisit thetagNameandatTokenforJSDocTags and the nodes that extend them. I'm not sure though...