-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Describe the bug
If an export from a namespace is mutable, and a function in the namespace mutates the value, the exported value is not mutated.
Input code
namespace A {
export let a = 5;
export function setA(value: number) {
a = value;
}
}Config
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "commonjs"
},
"minify": false,
"isModule": true
}Playground link
Expected behavior
tsc output correctly mutates the value:
"use strict";
var A;
(function (A) {
A.a = 5;
function setA(value) {
A.a = value;
}
A.setA = setA;
})(A || (A = {}));Actual behavior
Mutates the variable internal to the namespace but not the exported value from the namespace.
"use strict";
var A;
(function(A) {
var setA = function setA(value) {
a = value;
};
var a = A.a = 5;
A.setA = setA;
})(A || (A = {}));Version
1.2.218
Additional context
No response