Skip to content

Commit fe4c738

Browse files
No longer emit trailing comma on object literals.
This was done because trailing commas in object literals are not accepted by ES3. Fixes microsoft#271.
1 parent fc00047 commit fe4c738

10 files changed

+18
-18
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,7 @@ module ts {
21072107
var node = <ObjectLiteral>createNode(SyntaxKind.ObjectLiteral);
21082108
parseExpected(SyntaxKind.OpenBraceToken);
21092109
if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine;
2110-
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralMember, TrailingCommaBehavior.Preserve);
2110+
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralMember, TrailingCommaBehavior.Allow);
21112111
parseExpected(SyntaxKind.CloseBraceToken);
21122112

21132113
var seen: Map<SymbolFlags> = {};

tests/baselines/reference/assignmentCompatBug2.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ b3 = {
5050
g: function (s) {
5151
return 0;
5252
},
53-
m: 0,
53+
m: 0
5454
};
5555
b3 = {
5656
f: function (n) {
5757
return 0;
5858
},
5959
g: function (s) {
6060
return 0;
61-
},
61+
}
6262
};
6363
b3 = {
6464
f: function (n) {
6565
return 0;
6666
},
67-
m: 0,
67+
m: 0
6868
};
6969
b3 = {
7070
f: function (n) {
@@ -77,7 +77,7 @@ b3 = {
7777
n: 0,
7878
k: function (a) {
7979
return null;
80-
},
80+
}
8181
};
8282
b3 = {
8383
f: function (n) {
@@ -89,5 +89,5 @@ b3 = {
8989
n: 0,
9090
k: function (a) {
9191
return null;
92-
},
92+
}
9393
};

tests/baselines/reference/commentsOnObjectLiteral2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ var Person = makeClass(
1616
var Person = makeClass({
1717
initialize: function (name) {
1818
this.name = name;
19-
},
19+
}
2020
});

tests/baselines/reference/convertKeywordsYes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ var bigObject = {
380380
var: 0,
381381
void: 0,
382382
while: 0,
383-
with: 0,
383+
with: 0
384384
};
385385
var bigClass = (function () {
386386
function bigClass() {

tests/baselines/reference/declFileModuleAssignmentInObjectLiteralProperty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var m1;
2121
})(m1 || (m1 = {}));
2222
var d = {
2323
m1: { m: m1 },
24-
m2: { c: m1.c },
24+
m2: { c: m1.c }
2525
};
2626

2727

tests/baselines/reference/objectLitIndexerContextualType.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ y = {
2626
var x;
2727
var y;
2828
x = {
29-
s: function (t) { return t * t; },
29+
s: function (t) { return t * t; }
3030
};
3131
x = {
32-
0: function (t) { return t * t; },
32+
0: function (t) { return t * t; }
3333
};
3434
y = {
35-
s: function (t) { return t * t; },
35+
s: function (t) { return t * t; }
3636
};
3737
y = {
38-
0: function (t) { return t * t; },
38+
0: function (t) { return t * t; }
3939
};

tests/baselines/reference/objectLiteralParameterResolution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ var s = $.extend({
2525
dataType: "json",
2626
converters: { "text json": "" },
2727
traditional: true,
28-
timeout: 12,
28+
timeout: 12
2929
}, "");

tests/baselines/reference/objectTypeWithStringNamedPropertyOfIllegalCharacters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var r4 = a["~!@#$%^&*()_+{}|:'<>?\/.,`"];
7777
var b = {
7878
" ": 1,
7979
"a b": "",
80-
"~!@#$%^&*()_+{}|:'<>?\/.,`": 1,
80+
"~!@#$%^&*()_+{}|:'<>?\/.,`": 1
8181
};
8282
var r = b[" "];
8383
var r2 = b[" "];

tests/baselines/reference/stringLiteralTypesInImplementationSignatures2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ var b = {
4444
foo: function (x) {
4545
},
4646
foo: function (x) {
47-
},
47+
}
4848
};

tests/baselines/reference/thisInPropertyBoundDeclarations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ var A = (function () {
101101
this.prop4 = {
102102
a: function () {
103103
return this;
104-
},
104+
}
105105
};
106106
this.prop5 = function () {
107107
return {
108108
a: function () {
109109
return this;
110-
},
110+
}
111111
};
112112
};
113113
}

0 commit comments

Comments
 (0)