Skip to content

Instantly share code, notes, and snippets.

@majo44
Created August 5, 2015 14:26
Show Gist options
  • Save majo44/4d84feac30ad5a803658 to your computer and use it in GitHub Desktop.
Save majo44/4d84feac30ad5a803658 to your computer and use it in GitHub Desktop.
Variables are not exported properly by tsc when -m systemjs
<!DOCTYPE html>
<html lang="en">
<head>
<script src="bower_components/system.js/dist/system.js"></script>
</head>
<body>
<script>
System.config({
baseURL: '.',
defaultJSExtensions: true
});
System.import("moduleA");
</script>
</body>
</html>
import * as moduleB from "./moduleB"
console.log(moduleB.value); // !!! undefined
console.log(moduleB.moduleC); // !!! undefined
console.log(moduleB.moduleCStar); // => {value: "youpi", default: "youpi"}
/** TSC Output
System.register(["./moduleB"], function(exports_1) {
var moduleB;
return {
setters:[
function (_moduleB) {
moduleB = _moduleB;
}],
execute: function() {
console.log(moduleB.value);
console.log(moduleB.moduleC);
console.log(moduleB.moduleCStar);
}
}
});
**/
import * as moduleCStar from "./moduleC"
import moduleC from "./moduleC"
import {value} from "./moduleC"
export {
moduleCStar,
moduleC,
value
}
/** TSC Output
System.register(["./moduleC", "./moduleC", "./moduleC"], function(exports_1) {
var moduleCStar, moduleC_1, moduleC_2;
return {
setters:[
function (_moduleCStar) {
moduleCStar = _moduleCStar;
exports_1("moduleCStar", moduleCStar);
},
function (_moduleC_1) {
moduleC_1 = _moduleC_1;
exports_1("moduleC", moduleC_1.default); // Why this is not in execute ? default is undefined at this point !!!
},
function (_moduleC_2) {
moduleC_2 = _moduleC_2;
exports_1("value", moduleC_2.value); // Why this is not in execute ? value is undefined at this point !!!
}],
execute: function() {
}
}
});
**/
export var value = "youpi";
export default value;
/** TSC Output
System.register([], function(exports_1) {
var value;
return {
setters:[],
execute: function() {
exports_1("value", value = "youpi");
exports_1("default",value);
}
}
});
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment