I am using AMD modules (compiler flag "--module amd") in my TypeScript project. While I can easily use getters/setters on my classes I would like to do the same on my modules but
export get abc() : string {
return "abc";
}
returns
error TS1008: Unexpected token; 'module, class, interface, enum, import or statement' expected.
and
export function get abc() : string {
return "abc";
}
returns
error TS1005: '(' expected.
What am I doing wrong?
You can only add getters and setters to a class at the moment.
The code transformation TypeScript uses on getters and setters adds the property to the prototype of the object, which makes more sense for classes than for modules.