mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
only '++' and '--' unary operators can change exports
This commit is contained in:
parent
22856de23a
commit
a8f87bb2ca
@ -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
|
||||
|
||||
@ -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)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -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))
|
||||
|
||||
}
|
||||
@ -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
|
||||
|
||||
}
|
||||
@ -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) {
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user