When using getters and setters in object literals, I cannot see an easy way to access the outer "this" scope in Typescript. Consider the following:
class Report {
stuff: any[];
options = {
length: 10,
get maxLength() { return REPORT.stuff.length }
}
}
Where REPORT
wants to be a reference to the instance of the Report
object. I realize that I can solve this by setting options within the constructor and using a var REPORT = this
or similar, but seems inelegant. Is there a way to do this more cleanly?