@@ -1197,7 +1197,7 @@ module ts {
1197
1197
}
1198
1198
1199
1199
// Parses a comma-delimited list of elements
1200
- function parseDelimitedList < T extends Node > ( kind : ParsingContext , parseElement : ( ) => T , allowTrailingComma : boolean , preserveTrailingComma : boolean ) : NodeArray < T > {
1200
+ function parseDelimitedList < T extends Node > ( kind : ParsingContext , parseElement : ( ) => T , allowTrailingComma : boolean ) : NodeArray < T > {
1201
1201
var saveParsingContext = parsingContext ;
1202
1202
parsingContext |= 1 << kind ;
1203
1203
var result = < NodeArray < T > > [ ] ;
@@ -1228,11 +1228,8 @@ module ts {
1228
1228
grammarErrorAtPos ( commaStart , scanner . getStartPos ( ) - commaStart , Diagnostics . Trailing_comma_not_allowed ) ;
1229
1229
}
1230
1230
}
1231
- // Even if we reported an error because of a disallowed trailing comma, we still may
1232
- // need to preserve it for the checker so that signature help can work well.
1233
- if ( preserveTrailingComma ) {
1234
- result . push ( < T > createNode ( SyntaxKind . OmittedExpression ) ) ;
1235
- }
1231
+ // Always preserve a trailing comma by marking it on the NodeArray
1232
+ result . hasTrailingComma = true ;
1236
1233
}
1237
1234
1238
1235
break ;
@@ -1267,7 +1264,7 @@ module ts {
1267
1264
1268
1265
function parseBracketedList < T extends Node > ( kind : ParsingContext , parseElement : ( ) => T , startToken : SyntaxKind , endToken : SyntaxKind ) : NodeArray < T > {
1269
1266
if ( parseExpected ( startToken ) ) {
1270
- var result = parseDelimitedList ( kind , parseElement , /*allowTrailingComma*/ false , /*preserveTrailingComma*/ false ) ;
1267
+ var result = parseDelimitedList ( kind , parseElement , /*allowTrailingComma*/ false ) ;
1271
1268
parseExpected ( endToken ) ;
1272
1269
return result ;
1273
1270
}
@@ -2307,7 +2304,7 @@ module ts {
2307
2304
// needs evidence of a trailing comma in order to give good results for signature help.
2308
2305
// That is why we do not allow a trailing comma, but we "preserve" a trailing comma.
2309
2306
callExpr . arguments = parseDelimitedList ( ParsingContext . ArgumentExpressions ,
2310
- parseArgumentExpression , /*allowTrailingComma*/ false , /*preserveTrailingComma*/ true ) ;
2307
+ parseArgumentExpression , /*allowTrailingComma*/ false ) ;
2311
2308
parseExpected ( SyntaxKind . CloseParenToken ) ;
2312
2309
expr = finishNode ( callExpr ) ;
2313
2310
continue ;
@@ -2402,7 +2399,7 @@ module ts {
2402
2399
parseExpected ( SyntaxKind . OpenBracketToken ) ;
2403
2400
if ( scanner . hasPrecedingLineBreak ( ) ) node . flags |= NodeFlags . MultiLine ;
2404
2401
node . elements = parseDelimitedList ( ParsingContext . ArrayLiteralMembers ,
2405
- parseArrayLiteralElement , /*allowTrailingComma*/ true , /*preserveTrailingComma*/ true ) ;
2402
+ parseArrayLiteralElement , /*allowTrailingComma*/ true ) ;
2406
2403
parseExpected ( SyntaxKind . CloseBracketToken ) ;
2407
2404
return finishNode ( node ) ;
2408
2405
}
@@ -2444,10 +2441,7 @@ module ts {
2444
2441
node . flags |= NodeFlags . MultiLine ;
2445
2442
}
2446
2443
2447
- // ES3 itself does not accept a trailing comma in an object literal, however, we'd like to preserve it in ES5.
2448
- var preserveTrailingComma = languageVersion !== ScriptTarget . ES3 ;
2449
-
2450
- node . properties = parseDelimitedList ( ParsingContext . ObjectLiteralMembers , parseObjectLiteralMember , /*allowTrailingComma*/ true , preserveTrailingComma ) ;
2444
+ node . properties = parseDelimitedList ( ParsingContext . ObjectLiteralMembers , parseObjectLiteralMember , /*allowTrailingComma*/ true ) ;
2451
2445
parseExpected ( SyntaxKind . CloseBraceToken ) ;
2452
2446
2453
2447
var seen : Map < SymbolFlags > = { } ;
@@ -2540,7 +2534,7 @@ module ts {
2540
2534
// needs evidence of a trailing comma in order to give good results for signature help.
2541
2535
// That is why we do not allow a trailing comma, but we "preserve" a trailing comma.
2542
2536
node . arguments = parseDelimitedList ( ParsingContext . ArgumentExpressions ,
2543
- parseArgumentExpression , /*allowTrailingComma*/ false , /*preserveTrailingComma*/ true ) ;
2537
+ parseArgumentExpression , /*allowTrailingComma*/ false ) ;
2544
2538
parseExpected ( SyntaxKind . CloseParenToken ) ;
2545
2539
}
2546
2540
return finishNode ( node ) ;
@@ -3110,7 +3104,7 @@ module ts {
3110
3104
3111
3105
function parseVariableDeclarationList ( flags : NodeFlags , noIn ?: boolean ) : NodeArray < VariableDeclaration > {
3112
3106
return parseDelimitedList ( ParsingContext . VariableDeclarations ,
3113
- ( ) => parseVariableDeclaration ( flags , noIn ) , /*allowTrailingComma*/ false , /*preserveTrailingComma*/ false ) ;
3107
+ ( ) => parseVariableDeclaration ( flags , noIn ) , /*allowTrailingComma*/ false ) ;
3114
3108
}
3115
3109
3116
3110
function parseVariableStatement ( pos ?: number , flags ?: NodeFlags ) : VariableStatement {
@@ -3510,7 +3504,7 @@ module ts {
3510
3504
if ( parseOptional ( SyntaxKind . ImplementsKeyword ) ) {
3511
3505
implementsKeywordLength = scanner . getStartPos ( ) - implementsKeywordStart ;
3512
3506
node . implementedTypes = parseDelimitedList ( ParsingContext . BaseTypeReferences ,
3513
- parseTypeReference , /*allowTrailingComma*/ false , /*preserveTrailingComma*/ false ) ;
3507
+ parseTypeReference , /*allowTrailingComma*/ false ) ;
3514
3508
}
3515
3509
var errorCountBeforeClassBody = file . syntacticErrors . length ;
3516
3510
if ( parseExpected ( SyntaxKind . OpenBraceToken ) ) {
@@ -3539,7 +3533,7 @@ module ts {
3539
3533
if ( parseOptional ( SyntaxKind . ExtendsKeyword ) ) {
3540
3534
extendsKeywordLength = scanner . getStartPos ( ) - extendsKeywordStart ;
3541
3535
node . baseTypes = parseDelimitedList ( ParsingContext . BaseTypeReferences ,
3542
- parseTypeReference , /*allowTrailingComma*/ false , /*preserveTrailingComma*/ false ) ;
3536
+ parseTypeReference , /*allowTrailingComma*/ false ) ;
3543
3537
}
3544
3538
var errorCountBeforeInterfaceBody = file . syntacticErrors . length ;
3545
3539
node . members = parseTypeLiteral ( ) . members ;
@@ -3604,7 +3598,7 @@ module ts {
3604
3598
node . name = parseIdentifier ( ) ;
3605
3599
if ( parseExpected ( SyntaxKind . OpenBraceToken ) ) {
3606
3600
node . members = parseDelimitedList ( ParsingContext . EnumMembers ,
3607
- parseAndCheckEnumMember , /*allowTrailingComma*/ true , /*preserveTrailingComma*/ false ) ;
3601
+ parseAndCheckEnumMember , /*allowTrailingComma*/ true ) ;
3608
3602
parseExpected ( SyntaxKind . CloseBraceToken ) ;
3609
3603
}
3610
3604
else {
0 commit comments