Skip to content

Commit be85524

Browse files
authored
Merge pull request #11397 from Microsoft/release-2.0.5_fix11384
[Release-2.0.5] Do not emit wrong extra comma
2 parents c1a69f8 + fdda541 commit be85524

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/compiler/emitter.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,17 +1968,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19681968
emitObjectLiteralBody(node, firstComputedPropertyIndex);
19691969

19701970
for (let i = firstComputedPropertyIndex, n = properties.length; i < n; i++) {
1971-
writeComma();
1972-
19731971
const property = properties[i];
19741972

1975-
emitStart(property);
19761973
if (property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor) {
19771974
// TODO (drosen): Reconcile with 'emitMemberFunctions'.
19781975
const accessors = getAllAccessorDeclarations(node.properties, <AccessorDeclaration>property);
19791976
if (property !== accessors.firstAccessor) {
19801977
continue;
19811978
}
1979+
writeComma();
1980+
emitStart(property);
19821981
write("Object.defineProperty(");
19831982
emit(tempVar);
19841983
write(", ");
@@ -2019,6 +2018,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20192018
emitEnd(property);
20202019
}
20212020
else {
2021+
writeComma();
2022+
emitStart(property);
20222023
emitLeadingComments(property);
20232024
emitStart(property.name);
20242025
emit(tempVar);
@@ -2039,9 +2040,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20392040
else {
20402041
Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind);
20412042
}
2043+
emitEnd(property);
20422044
}
20432045

2044-
emitEnd(property);
20452046
}
20462047

20472048
writeComma();

tests/baselines/reference/computedPropertyNames49_ES5.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ var x = (_a = {
6060
enumerable: true,
6161
configurable: true
6262
}),
63-
,
6463
_a.p2 = 20,
6564
_a
6665
);

tests/baselines/reference/computedPropertyNames50_ES5.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ var x = (_a = {
5656
enumerable: true,
5757
configurable: true
5858
}),
59-
,
6059
_a.p2 = 20,
6160
_a
6261
);

0 commit comments

Comments
 (0)