No longer emit trailing comma on object literals.

This was done because trailing commas in object literals are not accepted by ES3.

Fixes #271.
This commit is contained in:
Daniel Rosenwasser 2014-07-28 11:34:30 -07:00
parent fc0004749f
commit fe4c738b01
10 changed files with 18 additions and 18 deletions

View file

@ -2107,7 +2107,7 @@ module ts {
var node = <ObjectLiteral>createNode(SyntaxKind.ObjectLiteral); var node = <ObjectLiteral>createNode(SyntaxKind.ObjectLiteral);
parseExpected(SyntaxKind.OpenBraceToken); parseExpected(SyntaxKind.OpenBraceToken);
if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine; if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine;
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralMember, TrailingCommaBehavior.Preserve); node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralMember, TrailingCommaBehavior.Allow);
parseExpected(SyntaxKind.CloseBraceToken); parseExpected(SyntaxKind.CloseBraceToken);
var seen: Map<SymbolFlags> = {}; var seen: Map<SymbolFlags> = {};

View file

@ -50,7 +50,7 @@ b3 = {
g: function (s) { g: function (s) {
return 0; return 0;
}, },
m: 0, m: 0
}; };
b3 = { b3 = {
f: function (n) { f: function (n) {
@ -58,13 +58,13 @@ b3 = {
}, },
g: function (s) { g: function (s) {
return 0; return 0;
}, }
}; };
b3 = { b3 = {
f: function (n) { f: function (n) {
return 0; return 0;
}, },
m: 0, m: 0
}; };
b3 = { b3 = {
f: function (n) { f: function (n) {
@ -77,7 +77,7 @@ b3 = {
n: 0, n: 0,
k: function (a) { k: function (a) {
return null; return null;
}, }
}; };
b3 = { b3 = {
f: function (n) { f: function (n) {
@ -89,5 +89,5 @@ b3 = {
n: 0, n: 0,
k: function (a) { k: function (a) {
return null; return null;
}, }
}; };

View file

@ -16,5 +16,5 @@ var Person = makeClass(
var Person = makeClass({ var Person = makeClass({
initialize: function (name) { initialize: function (name) {
this.name = name; this.name = name;
}, }
}); });

View file

@ -380,7 +380,7 @@ var bigObject = {
var: 0, var: 0,
void: 0, void: 0,
while: 0, while: 0,
with: 0, with: 0
}; };
var bigClass = (function () { var bigClass = (function () {
function bigClass() { function bigClass() {

View file

@ -21,7 +21,7 @@ var m1;
})(m1 || (m1 = {})); })(m1 || (m1 = {}));
var d = { var d = {
m1: { m: m1 }, m1: { m: m1 },
m2: { c: m1.c }, m2: { c: m1.c }
}; };

View file

@ -26,14 +26,14 @@ y = {
var x; var x;
var y; var y;
x = { x = {
s: function (t) { return t * t; }, s: function (t) { return t * t; }
}; };
x = { x = {
0: function (t) { return t * t; }, 0: function (t) { return t * t; }
}; };
y = { y = {
s: function (t) { return t * t; }, s: function (t) { return t * t; }
}; };
y = { y = {
0: function (t) { return t * t; }, 0: function (t) { return t * t; }
}; };

View file

@ -25,5 +25,5 @@ var s = $.extend({
dataType: "json", dataType: "json",
converters: { "text json": "" }, converters: { "text json": "" },
traditional: true, traditional: true,
timeout: 12, timeout: 12
}, ""); }, "");

View file

@ -77,7 +77,7 @@ var r4 = a["~!@#$%^&*()_+{}|:'<>?\/.,`"];
var b = { var b = {
" ": 1, " ": 1,
"a b": "", "a b": "",
"~!@#$%^&*()_+{}|:'<>?\/.,`": 1, "~!@#$%^&*()_+{}|:'<>?\/.,`": 1
}; };
var r = b[" "]; var r = b[" "];
var r2 = b[" "]; var r2 = b[" "];

View file

@ -44,5 +44,5 @@ var b = {
foo: function (x) { foo: function (x) {
}, },
foo: function (x) { foo: function (x) {
}, }
}; };

View file

@ -101,13 +101,13 @@ var A = (function () {
this.prop4 = { this.prop4 = {
a: function () { a: function () {
return this; return this;
}, }
}; };
this.prop5 = function () { this.prop5 = function () {
return { return {
a: function () { a: function () {
return this; return this;
}, }
}; };
}; };
} }