diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ea0ec323798bc..72b7fdc4850c8 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6334,19 +6334,18 @@ namespace ts { Debug.assert(start <= end); Debug.assert(end <= content.length); + // Check for /** (JSDoc opening part) + if (!isJSDocLikeText(content, start)) { + return undefined; + } + let tags: JSDocTag[]; let tagsPos: number; let tagsEnd: number; const comments: string[] = []; - let result: JSDoc | undefined; - - // Check for /** (JSDoc opening part) - if (!isJSDocLikeText(content, start)) { - return result; - } // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, () => { + return scanner.scanRange(start + 3, length - 5, () => { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. let state = JSDocState.SawAsterisk; @@ -6432,11 +6431,9 @@ namespace ts { } removeLeadingNewlines(comments); removeTrailingNewlines(comments); - result = createJSDocComment(); + return createJSDocComment(); }); - return result; - function removeLeadingNewlines(comments: string[]) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { comments.shift();