mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
feat(47977): show completion in jsdoc extends/implements tags (#51028)
This commit is contained in:
@@ -56,6 +56,7 @@ import {
|
||||
every,
|
||||
ExportKind,
|
||||
Expression,
|
||||
ExpressionWithTypeArguments,
|
||||
factory,
|
||||
filter,
|
||||
find,
|
||||
@@ -167,6 +168,8 @@ import {
|
||||
isInString,
|
||||
isIntersectionTypeNode,
|
||||
isJSDoc,
|
||||
isJSDocAugmentsTag,
|
||||
isJSDocImplementsTag,
|
||||
isJSDocParameterTag,
|
||||
isJSDocTag,
|
||||
isJSDocTemplateTag,
|
||||
@@ -2967,11 +2970,14 @@ function getCompletionData(
|
||||
}
|
||||
}
|
||||
|
||||
function tryGetTypeExpressionFromTag(tag: JSDocTag): JSDocTypeExpression | undefined {
|
||||
function tryGetTypeExpressionFromTag(tag: JSDocTag): JSDocTypeExpression | ExpressionWithTypeArguments | undefined {
|
||||
if (isTagWithTypeExpression(tag)) {
|
||||
const typeExpression = isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression;
|
||||
return typeExpression && typeExpression.kind === SyntaxKind.JSDocTypeExpression ? typeExpression : undefined;
|
||||
}
|
||||
if (isJSDocAugmentsTag(tag) || isJSDocImplementsTag(tag)) {
|
||||
return tag.class;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
8
tests/cases/fourslash/jsdocExtendsTagCompletion.ts
Normal file
8
tests/cases/fourslash/jsdocExtendsTagCompletion.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
/////** @extends {/**/} */
|
||||
////class A {}
|
||||
|
||||
verify.completions(
|
||||
{ marker: "", exact: completion.globalTypesPlus(["A"]) },
|
||||
);
|
||||
8
tests/cases/fourslash/jsdocImplementsTagCompletion.ts
Normal file
8
tests/cases/fourslash/jsdocImplementsTagCompletion.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
/////** @implements {/**/} */
|
||||
////class A {}
|
||||
|
||||
verify.completions(
|
||||
{ marker: "", exact: completion.globalTypesPlus(["A"]) },
|
||||
);
|
||||
Reference in New Issue
Block a user