Why can't I do this? Is this due to the technical limitations of Javascript / Typescript, or is it a Typescript developer design decision? The same code will work fine in Java or C #.
class Test {
static str: string = "test";
public static getTest(): string {
return this.str;
}
}
console.log(Test.getTest());
var test: Test = new Test();
console.log(test.getTest());
source
share