Skip to content

Commit 44a2296

Browse files
committed
fix pattern for matching @return tags
1 parent 34539d3 commit 44a2296

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/utils/natspec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ export function parseNatspec(item: DocItemWithContext): NatSpec {
7979
if (!p.name) {
8080
res.returns.push({ description: content.trim() });
8181
} else {
82-
const paramMatches = content.match(/(\w+) ([^]*)/);
82+
const paramMatches = content.match(/(\w+)( ([^]*))?/);
8383
if (!paramMatches || paramMatches[1] !== p.name) {
8484
throw new Error(`Expected @return tag to start with name '${p.name}'`);
8585
}
86-
const [, name, description] = paramMatches as [string, string, string];
87-
res.returns.push({ name, description: description.trim() });
86+
const [, name, description] = paramMatches as [string, string, string?];
87+
res.returns.push({ name, description: description?.trim() ?? '' });
8888
}
8989
}
9090

0 commit comments

Comments
 (0)