diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 191ef80d3211c..1524d2ee51638 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -9374,7 +9374,9 @@ namespace Parser { function tryParseTypeExpression(): JSDocTypeExpression | undefined { skipWhitespaceOrAsterisk(); - return token() === SyntaxKind.OpenBraceToken ? parseJSDocTypeExpression() : undefined; + if (token() === SyntaxKind.OpenBraceToken && !lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken)) { + return parseJSDocTypeExpression(); + } } function parseBracketNameInPropertyAndParamTag(): { name: EntityName; isBracketed: boolean; } { diff --git a/tests/baselines/reference/inlineTagInTypePosition.baseline b/tests/baselines/reference/inlineTagInTypePosition.baseline new file mode 100644 index 0000000000000..720e8df17e40c --- /dev/null +++ b/tests/baselines/reference/inlineTagInTypePosition.baseline @@ -0,0 +1,97 @@ +// === QuickInfo === +=== /tests/cases/fourslash/inlineTagInTypePosition.ts === +// class C { +// } +// /** +// * @throws {@link C} +// */ +// function CC() { +// ^^ +// | ---------------------------------------------------------------------- +// | function CC(): void +// | @throws {@link C} +// | ---------------------------------------------------------------------- +// } + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/inlineTagInTypePosition.ts", + "position": 50, + "name": "" + }, + "item": { + "kind": "function", + "kindModifiers": "", + "textSpan": { + "start": 50, + "length": 2 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "CC", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "documentation": [], + "tags": [ + { + "name": "throws", + "text": [ + { + "text": "", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "C", + "kind": "linkName", + "target": { + "fileName": "/tests/cases/fourslash/inlineTagInTypePosition.ts", + "textSpan": { + "start": 0, + "length": 11 + } + } + }, + { + "text": "}", + "kind": "link" + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/inlineTagInTypePosition.ts b/tests/cases/fourslash/inlineTagInTypePosition.ts new file mode 100644 index 0000000000000..9b7764b55422e --- /dev/null +++ b/tests/cases/fourslash/inlineTagInTypePosition.ts @@ -0,0 +1,11 @@ +/// + +//// class C { +//// } +//// /** +//// * @throws {@link C} +//// */ +//// function /**/CC() { +//// } + +verify.baselineQuickInfo();