@@ -67,13 +67,17 @@ namespace ts.InlayHints {
67
67
if ( preferences . includeInlayFunctionParameterTypeHints && isFunctionExpressionLike ( node ) ) {
68
68
visitFunctionExpressionLikeForParameterType ( node ) ;
69
69
}
70
- if ( preferences . includeInlayFunctionLikeReturnTypeHints && isFunctionLikeDeclaration ( node ) ) {
70
+ if ( preferences . includeInlayFunctionLikeReturnTypeHints && isSignatureSupportingReturnAnnotation ( node ) ) {
71
71
visitFunctionDeclarationLikeForReturnType ( node ) ;
72
72
}
73
73
}
74
74
return forEachChild ( node , visitor ) ;
75
75
}
76
76
77
+ function isSignatureSupportingReturnAnnotation ( node : Node ) : node is FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration {
78
+ return isArrowFunction ( node ) || isFunctionExpression ( node ) || isFunctionDeclaration ( node ) || isMethodDeclaration ( node ) || isGetAccessorDeclaration ( node ) ;
79
+ }
80
+
77
81
function isFunctionExpressionLike ( node : Node ) : node is ArrowFunction | FunctionExpression {
78
82
return isArrowFunction ( node ) || isFunctionExpression ( node ) ;
79
83
}
@@ -206,7 +210,7 @@ namespace ts.InlayHints {
206
210
return isLiteralExpression ( node ) || isBooleanLiteral ( node ) || isFunctionExpressionLike ( node ) || isObjectLiteralExpression ( node ) || isArrayLiteralExpression ( node ) ;
207
211
}
208
212
209
- function visitFunctionDeclarationLikeForReturnType ( decl : FunctionLikeDeclaration ) {
213
+ function visitFunctionDeclarationLikeForReturnType ( decl : FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration ) {
210
214
if ( isArrowFunction ( decl ) ) {
211
215
if ( ! findChildOfKind ( decl , SyntaxKind . OpenParenToken , file ) ) {
212
216
return ;
@@ -236,7 +240,7 @@ namespace ts.InlayHints {
236
240
addTypeHints ( typeDisplayString , getTypeAnnotationPosition ( decl ) ) ;
237
241
}
238
242
239
- function getTypeAnnotationPosition ( decl : FunctionLikeDeclaration ) {
243
+ function getTypeAnnotationPosition ( decl : FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration ) {
240
244
const closeParenToken = findChildOfKind ( decl , SyntaxKind . CloseParenToken , file ) ;
241
245
if ( closeParenToken ) {
242
246
return closeParenToken . end ;
0 commit comments