Skip to content

Commit

Permalink
fix: Fix JSDocTag#getStructure() not returning the whole tag text.
Browse files Browse the repository at this point in the history
This was due to a bug in the compiler API that has been reported previously.
  • Loading branch information
dsherret committed Dec 8, 2019
1 parent 0f6182f commit c096d30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ts-morph/src/compiler/ast/doc/JSDocTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class JSDocTag<NodeType extends ts.JSDocTag = ts.JSDocTag> extends JSDocT
}

function getText(jsDocTag: JSDocTag) {
return getTextWithoutStars(jsDocTag.getSourceFile().getFullText().substring(jsDocTag.getTagNameNode().getEnd(), jsDocTag.getEnd()).trim());
return getTextWithoutStars(jsDocTag.getSourceFile().getFullText().substring(jsDocTag.getTagNameNode().getEnd(), getTagEnd(jsDocTag)).trim());
}

function getTagEnd(jsDocTag: JSDocTag) {
Expand Down
5 changes: 5 additions & 0 deletions packages/ts-morph/src/tests/compiler/ast/doc/jsDocTagTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,10 @@ describe(nameof(JSDocTag), () => {
it("should get when there is multi-line text following the tag name", () => {
doTest("/** @param t - Test\n * Other. */\nfunction test() {}", { tagName: "param", text: "t - Test\nOther." });
});

it("should get the text for non-param tags", () => {
// necessary because of inconsistencies with js doc tag with in the compiler
doTest("/** @example Something\n * Other. */\nfunction test() {}", { tagName: "example", text: "Something\nOther." });
});
});
});

0 comments on commit c096d30

Please sign in to comment.