diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c7b01b9b8042d..91e84b2c47289 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6574,6 +6574,16 @@ namespace ts { indent += whitespace.length; } break; + case SyntaxKind.OpenBraceToken: + state = JSDocState.SavingComments; + if (lookAhead(() => nextJSDocToken() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link")) { + pushComment(scanner.getTokenText()); + nextJSDocToken(); + pushComment(scanner.getTokenText()); + nextJSDocToken(); + } + pushComment(scanner.getTokenText()); + break; case SyntaxKind.AsteriskToken: if (state === JSDocState.BeginningOfLine) { // leading asterisks start recording on the *next* (non-whitespace) token diff --git a/src/testRunner/unittests/jsDocParsing.ts b/src/testRunner/unittests/jsDocParsing.ts index 9a97cdc1505c1..6eecad9983b23 100644 --- a/src/testRunner/unittests/jsDocParsing.ts +++ b/src/testRunner/unittests/jsDocParsing.ts @@ -308,6 +308,12 @@ namespace ts { * @param {object} o Doc doc * @param {string} o.f Doc for f */`); + parsesCorrectly("", +`/** + * {@link first link} + * Inside {@link link text} thing + * @see {@link second link text} and {@link Foo|a foo} as well. + */`); }); }); describe("getFirstToken", () => { diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly..json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly..json new file mode 100644 index 0000000000000..c694d24037107 --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly..json @@ -0,0 +1,28 @@ +{ + "kind": "JSDocComment", + "pos": 0, + "end": 127, + "tags": { + "0": { + "kind": "JSDocTag", + "pos": 63, + "end": 68, + "atToken": { + "kind": "AtToken", + "pos": 63, + "end": 64 + }, + "tagName": { + "kind": "Identifier", + "pos": 64, + "end": 67, + "escapedText": "see" + }, + "comment": "{@link second link text} and {@link Foo|a foo} as well." + }, + "length": 1, + "pos": 63, + "end": 68 + }, + "comment": "{@link first link}\nInside {@link link text} thing" +} \ No newline at end of file diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index 40bdb4eadabc9..6b9706810b55a 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6 +Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32