Skip to content

Commit

Permalink
Fix crash with empty @example tag
Browse files Browse the repository at this point in the history
Resolves #1967
  • Loading branch information
Gerrit0 committed Jun 29, 2022
1 parent 513a91e commit 1bae4ff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Unreleased

### Bug Fixes

- TypeDoc will no longer crash if a comment contains an empty `@example` tag, #1967.

## v0.23.2 (2022-06-28)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion src/lib/converter/comments/parser.ts
Expand Up @@ -109,7 +109,7 @@ function postProcessComment(comment: Comment, warning: (msg: string) => void) {
tag.tag === "@example" &&
!tag.content.some((part) => part.kind === "code")
) {
const caption = tag.content[0].text.match(
const caption = tag.content[0]?.text.match(
/^\s*<caption>(.*?)<\/caption>\s*(\n|$)/
);
if (caption) {
Expand Down
4 changes: 4 additions & 0 deletions src/test/converter2/issues/gh1967.ts
@@ -0,0 +1,4 @@
/**
* @example
*/
export const abc = 123;
9 changes: 9 additions & 0 deletions src/test/issueTests.ts
Expand Up @@ -539,4 +539,13 @@ export const issueTests: {
gh1963(project) {
ok(project.hasComment(), "Missing module comment");
},

gh1967(project) {
equal(query(project, "abc").comment?.getTag("@example")?.content, [
{
kind: "code",
text: "```ts\n\n```",
},
]);
},
};

0 comments on commit 1bae4ff

Please sign in to comment.