From 0dcc117a1c030bd40ccde43b94ab2d37306e6cb1 Mon Sep 17 00:00:00 2001 From: Martin Rosenbeck Date: Fri, 17 Jan 2020 13:49:29 +0100 Subject: [PATCH] Allow comments in jsDoc. When a comment was encountered, the previous tag was not parsed by doctrine. Setting `recovarable: true` fixes the issue. --- src/parser.ts | 5 ++++- test/fixtures/parse/@extends.js | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/parser.ts b/src/parser.ts index 3ed851c1..59088709 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -229,7 +229,10 @@ export class Parser { isBlockComment(comment) && /^\*/.test(comment.value) ) .forEach(comment => { - const { tags } = doctrine.parse(`/*${comment.value}*/`, { unwrap: true }); + const { tags } = doctrine.parse(`/*${comment.value}*/`, { + unwrap: true, + recoverable: true, + }); tags .filter(tag => tagsHavingType.has(tag.title) && tag.type) .map(tag => this.extractType(tag.type!)) diff --git a/test/fixtures/parse/@extends.js b/test/fixtures/parse/@extends.js index 4720c350..bd1bdf15 100644 --- a/test/fixtures/parse/@extends.js +++ b/test/fixtures/parse/@extends.js @@ -1,6 +1,7 @@ /** * @interface * @extends {goog.Foo} + * I am a comment */ var Foo = function() { };