@@ -67,13 +67,17 @@ namespace ts.InlayHints {
6767 if ( preferences . includeInlayFunctionParameterTypeHints && isFunctionExpressionLike ( node ) ) {
6868 visitFunctionExpressionLikeForParameterType ( node ) ;
6969 }
70- if ( preferences . includeInlayFunctionLikeReturnTypeHints && isFunctionLikeDeclaration ( node ) ) {
70+ if ( preferences . includeInlayFunctionLikeReturnTypeHints && isSignatureSupportingReturnAnnotation ( node ) ) {
7171 visitFunctionDeclarationLikeForReturnType ( node ) ;
7272 }
7373 }
7474 return forEachChild ( node , visitor ) ;
7575 }
7676
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+
7781 function isFunctionExpressionLike ( node : Node ) : node is ArrowFunction | FunctionExpression {
7882 return isArrowFunction ( node ) || isFunctionExpression ( node ) ;
7983 }
@@ -206,7 +210,7 @@ namespace ts.InlayHints {
206210 return isLiteralExpression ( node ) || isBooleanLiteral ( node ) || isFunctionExpressionLike ( node ) || isObjectLiteralExpression ( node ) || isArrayLiteralExpression ( node ) ;
207211 }
208212
209- function visitFunctionDeclarationLikeForReturnType ( decl : FunctionLikeDeclaration ) {
213+ function visitFunctionDeclarationLikeForReturnType ( decl : FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration ) {
210214 if ( isArrowFunction ( decl ) ) {
211215 if ( ! findChildOfKind ( decl , SyntaxKind . OpenParenToken , file ) ) {
212216 return ;
@@ -236,7 +240,7 @@ namespace ts.InlayHints {
236240 addTypeHints ( typeDisplayString , getTypeAnnotationPosition ( decl ) ) ;
237241 }
238242
239- function getTypeAnnotationPosition ( decl : FunctionLikeDeclaration ) {
243+ function getTypeAnnotationPosition ( decl : FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration ) {
240244 const closeParenToken = findChildOfKind ( decl , SyntaxKind . CloseParenToken , file ) ;
241245 if ( closeParenToken ) {
242246 return closeParenToken . end ;
0 commit comments