@@ -67,7 +67,7 @@ namespace ts.InlayHints {
6767 if ( preferences . includeInlayFunctionParameterTypeHints && isFunctionExpressionLike ( node ) ) {
6868 visitFunctionExpressionLikeForParameterType ( node ) ;
6969 }
70- if ( preferences . includeInlayFunctionLikeReturnTypeHints && isFunctionDeclarationLike ( node ) ) {
70+ if ( preferences . includeInlayFunctionLikeReturnTypeHints && isFunctionLikeDeclaration ( node ) ) {
7171 visitFunctionDeclarationLikeForReturnType ( node ) ;
7272 }
7373 }
@@ -78,10 +78,6 @@ namespace ts.InlayHints {
7878 return isArrowFunction ( node ) || isFunctionExpression ( node ) ;
7979 }
8080
81- function isFunctionDeclarationLike ( node : Node ) : node is FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration {
82- return isArrowFunction ( node ) || isFunctionExpression ( node ) || isFunctionDeclaration ( node ) || isMethodDeclaration ( node ) ;
83- }
84-
8581 function addParameterHints ( text : string , position : number , isFirstVariadicArgument : boolean ) {
8682 result . push ( {
8783 text : `${ isFirstVariadicArgument ? "..." : "" } ${ truncation ( text , maxHintsLength ) } :` ,
@@ -206,7 +202,7 @@ namespace ts.InlayHints {
206202 return isLiteralExpression ( node ) || isBooleanLiteral ( node ) || isFunctionExpressionLike ( node ) || isObjectLiteralExpression ( node ) || isArrayLiteralExpression ( node ) ;
207203 }
208204
209- function visitFunctionDeclarationLikeForReturnType ( decl : ArrowFunction | FunctionExpression | MethodDeclaration | FunctionDeclaration ) {
205+ function visitFunctionDeclarationLikeForReturnType ( decl : FunctionLikeDeclaration ) {
210206 if ( isArrowFunction ( decl ) ) {
211207 if ( ! findChildOfKind ( decl , SyntaxKind . OpenParenToken , file ) ) {
212208 return ;
@@ -218,9 +214,7 @@ namespace ts.InlayHints {
218214 return ;
219215 }
220216
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 ) ;
224218 if ( ! signature ) {
225219 return ;
226220 }
@@ -238,7 +232,7 @@ namespace ts.InlayHints {
238232 addTypeHints ( typeDisplayString , getTypeAnnotationPosition ( decl ) ) ;
239233 }
240234
241- function getTypeAnnotationPosition ( decl : ArrowFunction | FunctionExpression | MethodDeclaration | FunctionDeclaration ) {
235+ function getTypeAnnotationPosition ( decl : FunctionLikeDeclaration ) {
242236 const closeParenToken = findChildOfKind ( decl , SyntaxKind . CloseParenToken , file ) ;
243237 if ( closeParenToken ) {
244238 return closeParenToken . end ;
0 commit comments