@@ -4129,11 +4129,18 @@ module ts {
4129
4129
return unknownSignature ;
4130
4130
}
4131
4131
4132
- function signatureHasCorrectArity ( node : CallExpression , signature : Signature ) {
4132
+ function signatureHasCorrectArity ( node : CallExpression , signature : Signature ) : boolean {
4133
4133
var args = node . arguments || emptyArray ;
4134
- return args . length >= signature . minArgumentCount &&
4134
+ var isCorrect = args . length >= signature . minArgumentCount &&
4135
4135
( signature . hasRestParameter || args . length <= signature . parameters . length ) &&
4136
4136
( ! node . typeArguments || signature . typeParameters && node . typeArguments . length === signature . typeParameters . length ) ;
4137
+
4138
+ // For error recovery, since we have parsed OmittedExpressions for any extra commas
4139
+ // in the argument list, if we see any OmittedExpressions, just return true.
4140
+ if ( ! isCorrect && forEach ( node . arguments , arg => arg . kind === SyntaxKind . OmittedExpression ) ) {
4141
+ return true ;
4142
+ }
4143
+ return isCorrect ;
4137
4144
}
4138
4145
4139
4146
// The candidate list orders groups in reverse, but within a group signatures are kept in declaration order
@@ -4208,6 +4215,9 @@ module ts {
4208
4215
var mapper = createInferenceMapper ( context ) ;
4209
4216
// First infer from arguments that are not context sensitive
4210
4217
for ( var i = 0 ; i < args . length ; i ++ ) {
4218
+ if ( args [ i ] . kind === SyntaxKind . OmittedExpression ) {
4219
+ continue ;
4220
+ }
4211
4221
if ( ! excludeArgument || excludeArgument [ i ] === undefined ) {
4212
4222
var parameterType = getTypeAtPosition ( signature , i ) ;
4213
4223
inferTypes ( context , checkExpressionWithContextualType ( args [ i ] , parameterType , mapper ) , parameterType ) ;
@@ -4216,6 +4226,9 @@ module ts {
4216
4226
// Next, infer from those context sensitive arguments that are no longer excluded
4217
4227
if ( excludeArgument ) {
4218
4228
for ( var i = 0 ; i < args . length ; i ++ ) {
4229
+ if ( args [ i ] . kind === SyntaxKind . OmittedExpression ) {
4230
+ continue ;
4231
+ }
4219
4232
if ( excludeArgument [ i ] === false ) {
4220
4233
var parameterType = getTypeAtPosition ( signature , i ) ;
4221
4234
inferTypes ( context , checkExpressionWithContextualType ( args [ i ] , parameterType , mapper ) , parameterType ) ;
@@ -4244,6 +4257,10 @@ module ts {
4244
4257
if ( node . arguments ) {
4245
4258
for ( var i = 0 ; i < node . arguments . length ; i ++ ) {
4246
4259
var arg = node . arguments [ i ] ;
4260
+ if ( arg . kind === SyntaxKind . OmittedExpression ) {
4261
+ continue ;
4262
+ }
4263
+
4247
4264
var paramType = getTypeAtPosition ( signature , i ) ;
4248
4265
// String literals get string literal types unless we're reporting errors
4249
4266
var argType = arg . kind === SyntaxKind . StringLiteral && ! reportErrors ?
0 commit comments