define getter and setter on modules or namespaces #16478
Labels
Out of Scope
This idea sits outside of the TypeScript language design constraints
Suggestion
An idea for TypeScript
Summary :
I need to be able to define getter / setter properties on modules and namespaces.
It could use the get and set keywords like currently on classes.
I'd like to be able to do that:
Code
which would then compile (in amd) to that
Scenario / Motivation:
I have some modules that act as Singletons (I think "revealing module pattern")
I like to prefix the module internal state variables (usually by "_") so that in functions I differentiate these variables from the function's input variables.
But I also want to export these variables as properties to the outside WITHOUT the _ prefix
In a class I would use get and set to do that, however the get and set syntax is not supported on modules (or it's not properly documented :/ )
I also don't want to convert my module into a class, because then I'd have to rely on the facetious "this"
The text was updated successfully, but these errors were encountered: