@@ -1770,14 +1770,15 @@ namespace ts.Completions {
1770
1770
if ( tag . tagName . pos <= position && position <= tag . tagName . end ) {
1771
1771
return { kind : CompletionDataKind . JsDocTagName } ;
1772
1772
}
1773
- if ( isTagWithTypeExpression ( tag ) && tag . typeExpression && tag . typeExpression . kind === SyntaxKind . JSDocTypeExpression ) {
1773
+ const typeExpression = tryGetTypeExpressionFromTag ( tag ) ;
1774
+ if ( typeExpression ) {
1774
1775
currentToken = getTokenAtPosition ( sourceFile , position ) ;
1775
1776
if ( ! currentToken ||
1776
1777
( ! isDeclarationName ( currentToken ) &&
1777
1778
( currentToken . parent . kind !== SyntaxKind . JSDocPropertyTag ||
1778
1779
( currentToken . parent as JSDocPropertyTag ) . name !== currentToken ) ) ) {
1779
1780
// Use as type location if inside tag's type expression
1780
- insideJsDocTagTypeExpression = isCurrentlyEditingNode ( tag . typeExpression ) ;
1781
+ insideJsDocTagTypeExpression = isCurrentlyEditingNode ( typeExpression ) ;
1781
1782
}
1782
1783
}
1783
1784
if ( ! insideJsDocTagTypeExpression && isJSDocParameterTag ( tag ) && ( nodeIsMissing ( tag . name ) || tag . name . pos <= position && position <= tag . name . end ) ) {
@@ -2046,7 +2047,7 @@ namespace ts.Completions {
2046
2047
hasUnresolvedAutoImports,
2047
2048
} ;
2048
2049
2049
- type JSDocTagWithTypeExpression = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag ;
2050
+ type JSDocTagWithTypeExpression = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag | JSDocTemplateTag ;
2050
2051
2051
2052
function isTagWithTypeExpression ( tag : JSDocTag ) : tag is JSDocTagWithTypeExpression {
2052
2053
switch ( tag . kind ) {
@@ -2056,11 +2057,21 @@ namespace ts.Completions {
2056
2057
case SyntaxKind . JSDocTypeTag :
2057
2058
case SyntaxKind . JSDocTypedefTag :
2058
2059
return true ;
2060
+ case SyntaxKind . JSDocTemplateTag :
2061
+ return ! ! ( tag as JSDocTemplateTag ) . constraint ;
2059
2062
default :
2060
2063
return false ;
2061
2064
}
2062
2065
}
2063
2066
2067
+ function tryGetTypeExpressionFromTag ( tag : JSDocTag ) : JSDocTypeExpression | undefined {
2068
+ if ( isTagWithTypeExpression ( tag ) ) {
2069
+ const typeExpression = isJSDocTemplateTag ( tag ) ? tag . constraint : tag . typeExpression ;
2070
+ return typeExpression && typeExpression . kind === SyntaxKind . JSDocTypeExpression ? typeExpression : undefined ;
2071
+ }
2072
+ return undefined ;
2073
+ }
2074
+
2064
2075
function getTypeScriptMemberSymbols ( ) : void {
2065
2076
// Right of dot member completion list
2066
2077
completionKind = CompletionKind . PropertyAccess ;
0 commit comments