mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 06:17:19 -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user