@@ -304,14 +304,17 @@ namespace ts.SignatureHelp {
304
304
if ( ! info ) return undefined ;
305
305
const { contextualType, argumentIndex, argumentCount, argumentsSpan } = info ;
306
306
307
- const signatures = contextualType . getCallSignatures ( ) ;
307
+ // for optional function condition.
308
+ const nonNullableContextualType = contextualType . getNonNullableType ( ) ;
309
+
310
+ const signatures = nonNullableContextualType . getCallSignatures ( ) ;
308
311
if ( signatures . length !== 1 ) return undefined ;
309
312
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 ) } ;
311
314
return { isTypeParameterList : false , invocation, argumentsSpan, argumentIndex, argumentCount } ;
312
315
}
313
316
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 ; }
315
318
function getContextualSignatureLocationInfo ( startingToken : Node , sourceFile : SourceFile , checker : TypeChecker ) : ContextualSignatureLocationInfo | undefined {
316
319
if ( startingToken . kind !== SyntaxKind . OpenParenToken && startingToken . kind !== SyntaxKind . CommaToken ) return undefined ;
317
320
const { parent } = startingToken ;
0 commit comments