diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 398b7f1e61305..23b4b3d0ddb5f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -282,6 +282,7 @@ import { isJSDoc, isJSDocAugmentsTag, isJSDocFunctionType, + isJSDocImplementsTag, isJSDocLinkLike, isJSDocMemberName, isJSDocNameReference, @@ -2452,7 +2453,7 @@ export function isPartOfTypeNode(node: Node): boolean { case SyntaxKind.VoidKeyword: return node.parent.kind !== SyntaxKind.VoidExpression; case SyntaxKind.ExpressionWithTypeArguments: - return isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); + return isPartOfTypeExpressionWithTypeArguments(node); case SyntaxKind.TypeParameter: return node.parent.kind === SyntaxKind.MappedType || node.parent.kind === SyntaxKind.InferType; @@ -2491,7 +2492,7 @@ export function isPartOfTypeNode(node: Node): boolean { } switch (parent.kind) { case SyntaxKind.ExpressionWithTypeArguments: - return isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); + return isPartOfTypeExpressionWithTypeArguments(parent); case SyntaxKind.TypeParameter: return node === (parent as TypeParameterDeclaration).constraint; case SyntaxKind.JSDocTemplateTag: @@ -2527,6 +2528,12 @@ export function isPartOfTypeNode(node: Node): boolean { return false; } +function isPartOfTypeExpressionWithTypeArguments(node: Node) { + return isJSDocImplementsTag(node.parent) + || isJSDocAugmentsTag(node.parent) + || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); +} + /** @internal */ export function isChildOfNodeWithKind(node: Node, kind: SyntaxKind): boolean { while (node) { diff --git a/tests/baselines/reference/quickInfoJsDocTags15.baseline b/tests/baselines/reference/quickInfoJsDocTags15.baseline new file mode 100644 index 0000000000000..da5ff2162dba0 --- /dev/null +++ b/tests/baselines/reference/quickInfoJsDocTags15.baseline @@ -0,0 +1,308 @@ +// === QuickInfo === +=== /b.js === +// import * as _a from "./a.js"; +// /** +// * @implements {_a.Foo} +// ^^^ +// | ---------------------------------------------------------------------- +// | type Foo = { +// | getName: _a.Bar; +// | } +// | ---------------------------------------------------------------------- +// */ +// class C1 { } +// +// /** +// * @extends {_a.Foo} +// ^^^ +// | ---------------------------------------------------------------------- +// | type Foo = { +// | getName: _a.Bar; +// | } +// | ---------------------------------------------------------------------- +// */ +// class C2 { } +// +// /** +// * @augments {_a.Foo} +// ^^^ +// | ---------------------------------------------------------------------- +// | type Foo = { +// | getName: _a.Bar; +// | } +// | ---------------------------------------------------------------------- +// */ +// class C3 { } + +[ + { + "marker": { + "fileName": "/b.js", + "position": 56, + "name": "1" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 53, + "length": 3 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getName", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "_a", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Bar", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [] + } + }, + { + "marker": { + "fileName": "/b.js", + "position": 99, + "name": "2" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 96, + "length": 3 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getName", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "_a", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Bar", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [] + } + }, + { + "marker": { + "fileName": "/b.js", + "position": 143, + "name": "3" + }, + "item": { + "kind": "type", + "kindModifiers": "", + "textSpan": { + "start": 140, + "length": 3 + }, + "displayParts": [ + { + "text": "type", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Foo", + "kind": "aliasName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=", + "kind": "operator" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "{", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "getName", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "_a", + "kind": "aliasName" + }, + { + "text": ".", + "kind": "punctuation" + }, + { + "text": "Bar", + "kind": "aliasName" + }, + { + "text": ";", + "kind": "punctuation" + }, + { + "text": "\n", + "kind": "lineBreak" + }, + { + "text": "}", + "kind": "punctuation" + } + ], + "documentation": [] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoJsDocTags15.ts b/tests/cases/fourslash/quickInfoJsDocTags15.ts new file mode 100644 index 0000000000000..aa611224d8e89 --- /dev/null +++ b/tests/cases/fourslash/quickInfoJsDocTags15.ts @@ -0,0 +1,36 @@ +/// + +// @allowJs: true +// @checkJs: true +// @filename: /a.js +/////** +//// * @callback Bar +//// * @param {string} name +//// * @returns {string} +//// */ +//// +/////** +//// * @typedef Foo +//// * @property {Bar} getName +//// */ +////export const foo = 1; + +// @filename: /b.js +////import * as _a from "./a.js"; +/////** +//// * @implements {_a.Foo/*1*/} +//// */ +////class C1 { } +//// +/////** +//// * @extends {_a.Foo/*2*/} +//// */ +////class C2 { } +//// +/////** +//// * @augments {_a.Foo/*3*/} +//// */ +////class C3 { } + +goTo.file("/b.js") +verify.baselineQuickInfo();