publish exported postfix operators as 'E("", ++x) - 1' and 'E("", --x) + 1'

This commit is contained in:
Vladimir Matveev
2015-04-13 21:32:27 -07:00
parent 5d2897d67f
commit 0feebd44b3
4 changed files with 37 additions and 13 deletions

View File

@@ -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));
}
}