@@ -67,7 +67,7 @@ namespace ts.InlayHints {
67
67
if ( preferences . includeInlayFunctionParameterTypeHints && isFunctionExpressionLike ( node ) ) {
68
68
visitFunctionExpressionLikeForParameterType ( node ) ;
69
69
}
70
- if ( preferences . includeInlayFunctionLikeReturnTypeHints && isFunctionDeclarationLike ( node ) ) {
70
+ if ( preferences . includeInlayFunctionLikeReturnTypeHints && isFunctionLikeDeclaration ( node ) ) {
71
71
visitFunctionDeclarationLikeForReturnType ( node ) ;
72
72
}
73
73
}
@@ -78,10 +78,6 @@ namespace ts.InlayHints {
78
78
return isArrowFunction ( node ) || isFunctionExpression ( node ) ;
79
79
}
80
80
81
- function isFunctionDeclarationLike ( node : Node ) : node is FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration {
82
- return isArrowFunction ( node ) || isFunctionExpression ( node ) || isFunctionDeclaration ( node ) || isMethodDeclaration ( node ) ;
83
- }
84
-
85
81
function addParameterHints ( text : string , position : number , isFirstVariadicArgument : boolean ) {
86
82
result . push ( {
87
83
text : `${ isFirstVariadicArgument ? "..." : "" } ${ truncation ( text , maxHintsLength ) } :` ,
@@ -206,7 +202,7 @@ namespace ts.InlayHints {
206
202
return isLiteralExpression ( node ) || isBooleanLiteral ( node ) || isFunctionExpressionLike ( node ) || isObjectLiteralExpression ( node ) || isArrayLiteralExpression ( node ) ;
207
203
}
208
204
209
- function visitFunctionDeclarationLikeForReturnType ( decl : ArrowFunction | FunctionExpression | MethodDeclaration | FunctionDeclaration ) {
205
+ function visitFunctionDeclarationLikeForReturnType ( decl : FunctionLikeDeclaration ) {
210
206
if ( isArrowFunction ( decl ) ) {
211
207
if ( ! findChildOfKind ( decl , SyntaxKind . OpenParenToken , file ) ) {
212
208
return ;
@@ -218,9 +214,7 @@ namespace ts.InlayHints {
218
214
return ;
219
215
}
220
216
221
- const type = checker . getTypeAtLocation ( decl ) ;
222
- const signatures = checker . getSignaturesOfType ( type , SignatureKind . Call ) ;
223
- const signature = firstOrUndefined ( signatures ) ;
217
+ const signature = checker . getSignatureFromDeclaration ( decl ) ;
224
218
if ( ! signature ) {
225
219
return ;
226
220
}
@@ -238,7 +232,7 @@ namespace ts.InlayHints {
238
232
addTypeHints ( typeDisplayString , getTypeAnnotationPosition ( decl ) ) ;
239
233
}
240
234
241
- function getTypeAnnotationPosition ( decl : ArrowFunction | FunctionExpression | MethodDeclaration | FunctionDeclaration ) {
235
+ function getTypeAnnotationPosition ( decl : FunctionLikeDeclaration ) {
242
236
const closeParenToken = findChildOfKind ( decl , SyntaxKind . CloseParenToken , file ) ;
243
237
if ( closeParenToken ) {
244
238
return closeParenToken . end ;
0 commit comments