@@ -64,8 +64,8 @@ namespace ts.InlayHints {
6464 visitCallOrNewExpression ( node ) ;
6565 }
6666 else {
67- if ( preferences . includeInlayFunctionParameterTypeHints && isFunctionExpressionLike ( node ) ) {
68- visitFunctionExpressionLikeForParameterType ( node ) ;
67+ if ( preferences . includeInlayFunctionParameterTypeHints && isFunctionLikeDeclaration ( node ) && hasContextSensitiveParameters ( node ) ) {
68+ visitFunctionLikeForParameterType ( node ) ;
6969 }
7070 if ( preferences . includeInlayFunctionLikeReturnTypeHints && isSignatureSupportingReturnAnnotation ( node ) ) {
7171 visitFunctionDeclarationLikeForReturnType ( node ) ;
@@ -78,10 +78,6 @@ namespace ts.InlayHints {
7878 return isArrowFunction ( node ) || isFunctionExpression ( node ) || isFunctionDeclaration ( node ) || isMethodDeclaration ( node ) || isGetAccessorDeclaration ( node ) ;
7979 }
8080
81- function isFunctionExpressionLike ( node : Node ) : node is ArrowFunction | FunctionExpression {
82- return isArrowFunction ( node ) || isFunctionExpression ( node ) ;
83- }
84-
8581 function addParameterHints ( text : string , position : number , isFirstVariadicArgument : boolean ) {
8682 result . push ( {
8783 text : `${ isFirstVariadicArgument ? "..." : "" } ${ truncation ( text , maxHintsLength ) } :` ,
@@ -207,7 +203,7 @@ namespace ts.InlayHints {
207203 }
208204
209205 function isHintableExpression ( node : Node ) {
210- return isLiteralExpression ( node ) || isBooleanLiteral ( node ) || isFunctionExpressionLike ( node ) || isObjectLiteralExpression ( node ) || isArrayLiteralExpression ( node ) ;
206+ return isLiteralExpression ( node ) || isBooleanLiteral ( node ) || isArrowFunction ( node ) || isFunctionExpression ( node ) || isObjectLiteralExpression ( node ) || isArrayLiteralExpression ( node ) ;
211207 }
212208
213209 function visitFunctionDeclarationLikeForReturnType ( decl : FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration ) {
@@ -248,24 +244,14 @@ namespace ts.InlayHints {
248244 return decl . parameters . end ;
249245 }
250246
251- function visitFunctionExpressionLikeForParameterType ( expr : ArrowFunction | FunctionExpression ) {
252- if ( ! expr . parameters . length || expr . parameters . every ( param => ! ! getEffectiveTypeAnnotationNode ( param ) ) ) {
253- return ;
254- }
255-
256- const contextualType = checker . getContextualType ( expr ) ;
257- if ( ! contextualType ) {
258- return ;
259- }
260-
261- const signatures = checker . getSignaturesOfType ( contextualType , SignatureKind . Call ) ;
262- const signature = firstOrUndefined ( signatures ) ;
247+ function visitFunctionLikeForParameterType ( node : FunctionLikeDeclaration ) {
248+ const signature = checker . getSignatureFromDeclaration ( node ) ;
263249 if ( ! signature ) {
264250 return ;
265251 }
266252
267- for ( let i = 0 ; i < expr . parameters . length && i < signature . parameters . length ; ++ i ) {
268- const param = expr . parameters [ i ] ;
253+ for ( let i = 0 ; i < node . parameters . length && i < signature . parameters . length ; ++ i ) {
254+ const param = node . parameters [ i ] ;
269255 const effectiveTypeAnnotation = getEffectiveTypeAnnotationNode ( param ) ;
270256
271257 if ( effectiveTypeAnnotation ) {
0 commit comments