mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
publish exported postfix operators as 'E("", ++x) - 1' and 'E("", --x) + 1'
This commit is contained in:
@@ -1963,18 +1963,24 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
function emitPostfixUnaryExpression(node: PostfixUnaryExpression) {
|
||||
const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand);
|
||||
if (exportChanged) {
|
||||
write(`${exportFunctionForFile}("`);
|
||||
// emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)'
|
||||
write(`(${exportFunctionForFile}("`);
|
||||
emitNodeWithoutSourceMap(node.operand);
|
||||
write(`", `);
|
||||
|
||||
write(tokenToString(node.operator));
|
||||
emit(node.operand);
|
||||
|
||||
if (node.operator === SyntaxKind.PlusPlusToken) {
|
||||
write(") - 1)");
|
||||
}
|
||||
else {
|
||||
write(") + 1)");
|
||||
}
|
||||
}
|
||||
|
||||
emit(node.operand);
|
||||
write(tokenToString(node.operator));
|
||||
|
||||
if (exportChanged) {
|
||||
write("), ");
|
||||
emitNodeWithoutSourceMap(node.operand);
|
||||
write(node.operator === SyntaxKind.PlusPlusToken ? " - 1" : " + 1");
|
||||
else {
|
||||
emit(node.operand);
|
||||
write(tokenToString(node.operator));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ x |= 1;
|
||||
x &= 1;
|
||||
for (x = 5;;x++) {}
|
||||
for (x = 8;;x--) {}
|
||||
for (x = 15;;++x) {}
|
||||
for (x = 18;;--x) {}
|
||||
|
||||
for (let x = 50;;) {}
|
||||
function foo() {
|
||||
@@ -35,8 +37,8 @@ System.register([], function(exports_1) {
|
||||
execute: function() {
|
||||
exports_1("x", x);
|
||||
exports_1("x", x = 1);
|
||||
exports_1("x", x++), x - 1;
|
||||
exports_1("x", x--), x + 1;
|
||||
(exports_1("x", ++x) - 1);
|
||||
(exports_1("x", --x) + 1);
|
||||
exports_1("x", ++x);
|
||||
exports_1("x", --x);
|
||||
exports_1("x", x += 1);
|
||||
@@ -45,8 +47,10 @@ System.register([], function(exports_1) {
|
||||
exports_1("x", x /= 1);
|
||||
exports_1("x", x |= 1);
|
||||
exports_1("x", x &= 1);
|
||||
for (exports_1("x", x = 5);; exports_1("x", x++), x - 1) { }
|
||||
for (exports_1("x", x = 8);; exports_1("x", x--), x + 1) { }
|
||||
for (exports_1("x", x = 5);; (exports_1("x", ++x) - 1)) { }
|
||||
for (exports_1("x", x = 8);; (exports_1("x", --x) + 1)) { }
|
||||
for (exports_1("x", x = 15);; exports_1("x", ++x)) { }
|
||||
for (exports_1("x", x = 18);; exports_1("x", --x)) { }
|
||||
for (x_1 = 50;;) { }
|
||||
exports_1("y", y = ([1])[0]);
|
||||
_a = { a: true, b: { c: "123" } }, exports_1("z0", z0 = _a.a), exports_1("z1", z1 = _a.b.c);
|
||||
|
||||
@@ -59,6 +59,18 @@ for (x = 8;;x--) {}
|
||||
>x-- : number
|
||||
>x : any
|
||||
|
||||
for (x = 15;;++x) {}
|
||||
>x = 15 : number
|
||||
>x : any
|
||||
>++x : number
|
||||
>x : any
|
||||
|
||||
for (x = 18;;--x) {}
|
||||
>x = 18 : number
|
||||
>x : any
|
||||
>--x : number
|
||||
>x : any
|
||||
|
||||
for (let x = 50;;) {}
|
||||
>x : number
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ x |= 1;
|
||||
x &= 1;
|
||||
for (x = 5;;x++) {}
|
||||
for (x = 8;;x--) {}
|
||||
for (x = 15;;++x) {}
|
||||
for (x = 18;;--x) {}
|
||||
|
||||
for (let x = 50;;) {}
|
||||
function foo() {
|
||||
|
||||
Reference in New Issue
Block a user