Closed
Description
Suggestion moved over from codeplex.
I would like to suggest the following: Why not have anonymous/unnamed modules? The following code snippet totally makes sense for me to compile:
module {
class Simple {
constructor(public name: string) {}
greet(who: string) {
return "Greetings "+ who +", I'm "+ this.name +"!";
}
static main() {
var s = new Simple('Flynn');
console.log(s.greet("Program"));
}
}
Simple.main()
}
The generated code should be wrapped in a closure function and not cluttering the global scope.
(function () {
// ...
})();
Also it would be nice to have a compiler option to put everything compiled in an anonymous module so that the global namespace is not cluttered.
The above snippet is with little modification from: https://gist.github.com/3916195
Thanks!