diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 622ec14caa8..ab775ba9fc6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2445,7 +2445,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } function emitPrefixUnaryExpression(node: PrefixUnaryExpression) { - const exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); + const exportChanged = (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) && + isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.operand); if (exportChanged) { // emit diff --git a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.js b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.js new file mode 100644 index 00000000000..5d414c97d05 --- /dev/null +++ b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.js @@ -0,0 +1,58 @@ +//// [prefixUnaryOperatorsOnExportedVariables.ts] + +export var x = false; +export var y = 1; +if (!x) { + +} + +if (+x) { + +} + +if (-x) { + +} + +if (~x) { + +} + +if (void x) { + +} + +if (typeof x) { + +} + +if (++y) { + +} + +//// [prefixUnaryOperatorsOnExportedVariables.js] +System.register([], function(exports_1) { + "use strict"; + var x, y; + return { + setters:[], + execute: function() { + exports_1("x", x = false); + exports_1("y", y = 1); + if (!x) { + } + if (+x) { + } + if (-x) { + } + if (~x) { + } + if (void x) { + } + if (typeof x) { + } + if (exports_1("y", ++y)) { + } + } + } +}); diff --git a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.symbols b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.symbols new file mode 100644 index 00000000000..c8293ef1902 --- /dev/null +++ b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/prefixUnaryOperatorsOnExportedVariables.ts === + +export var x = false; +>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10)) + +export var y = 1; +>y : Symbol(y, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 2, 10)) + +if (!x) { +>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10)) + +} + +if (+x) { +>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10)) + +} + +if (-x) { +>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10)) + +} + +if (~x) { +>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10)) + +} + +if (void x) { +>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10)) + +} + +if (typeof x) { +>x : Symbol(x, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 1, 10)) + +} + +if (++y) { +>y : Symbol(y, Decl(prefixUnaryOperatorsOnExportedVariables.ts, 2, 10)) + +} diff --git a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types new file mode 100644 index 00000000000..c75ba492c31 --- /dev/null +++ b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types @@ -0,0 +1,51 @@ +=== tests/cases/compiler/prefixUnaryOperatorsOnExportedVariables.ts === + +export var x = false; +>x : boolean +>false : boolean + +export var y = 1; +>y : number +>1 : number + +if (!x) { +>!x : boolean +>x : boolean + +} + +if (+x) { +>+x : number +>x : boolean + +} + +if (-x) { +>-x : number +>x : boolean + +} + +if (~x) { +>~x : number +>x : boolean + +} + +if (void x) { +>void x : undefined +>x : boolean + +} + +if (typeof x) { +>typeof x : string +>x : boolean + +} + +if (++y) { +>++y : number +>y : number + +} diff --git a/tests/cases/compiler/prefixUnaryOperatorsOnExportedVariables.ts b/tests/cases/compiler/prefixUnaryOperatorsOnExportedVariables.ts new file mode 100644 index 00000000000..58b05bb513a --- /dev/null +++ b/tests/cases/compiler/prefixUnaryOperatorsOnExportedVariables.ts @@ -0,0 +1,32 @@ +// @target: ES5 +// @module: system + +export var x = false; +export var y = 1; +if (!x) { + +} + +if (+x) { + +} + +if (-x) { + +} + +if (~x) { + +} + +if (void x) { + +} + +if (typeof x) { + +} + +if (++y) { + +} \ No newline at end of file