@@ -304,14 +304,17 @@ namespace ts.SignatureHelp {
304304 if ( ! info ) return undefined ;
305305 const { contextualType, argumentIndex, argumentCount, argumentsSpan } = info ;
306306
307- const signatures = contextualType . getCallSignatures ( ) ;
307+ // for optional function condition.
308+ const nonNullableContextualType = contextualType . getNonNullableType ( ) ;
309+
310+ const signatures = nonNullableContextualType . getCallSignatures ( ) ;
308311 if ( signatures . length !== 1 ) return undefined ;
309312
310- const invocation : ContextualInvocation = { kind : InvocationKind . Contextual , signature : first ( signatures ) , node : startingToken , symbol : chooseBetterSymbol ( contextualType . symbol ) } ;
313+ const invocation : ContextualInvocation = { kind : InvocationKind . Contextual , signature : first ( signatures ) , node : startingToken , symbol : chooseBetterSymbol ( nonNullableContextualType . symbol ) } ;
311314 return { isTypeParameterList : false , invocation, argumentsSpan, argumentIndex, argumentCount } ;
312315 }
313316
314- interface ContextualSignatureLocationInfo { readonly contextualType : Type ; readonly argumentIndex : number ; readonly argumentCount : number ; readonly argumentsSpan : TextSpan ; }
317+ interface ContextualSignatureLocationInfo { readonly contextualType : Type ; readonly argumentIndex : number ; readonly argumentCount : number ; readonly argumentsSpan : TextSpan ; }
315318 function getContextualSignatureLocationInfo ( startingToken : Node , sourceFile : SourceFile , checker : TypeChecker ) : ContextualSignatureLocationInfo | undefined {
316319 if ( startingToken . kind !== SyntaxKind . OpenParenToken && startingToken . kind !== SyntaxKind . CommaToken ) return undefined ;
317320 const { parent } = startingToken ;
0 commit comments