No, there is no way to declare a property on a module in TypeScript using any of the features of the document language.
You can do this in several rounding methods.
A module can extend existing class or function . So, I created a class with the static property, and then created a module that uses the same name as the class .
class My { static get Value():Number { return 42; } } module My { var works: boolean = true; } alert(My.Value);
It generates one weirdness in the generated JavaScript code that you wouldn’t do manually (and in any case it needs to be removed by most optimizers) ... when creating the module, it will update the My variable. This does not cause a run-time problem since the variable has already been stripped in JavaScript and will not conflict with the first use.
Here is another option:
module Global { class Inner { get Value():Number { return 42; } } export var My; My = new Inner(); } var My = Global.My; alert(My.Value);
While it represents an extra namespace, you can manipulate it, but you want to use the inner class or change it as needed. Thus, the variable My is global, as it would be like module .
source share