I am a beginner in the world of TypeScript and I'm currently struggling with running this code snippet:
class TestClass
{
public t: number = 10;
constructor() {
this.t = this.t - 1;
console.log(this.t);
}
}
var obj = new TestClass();
For those interested, you can find a working example on the TypeScript playground.
After transpiling the code to JavaScript, Chrome's developer console prints 'Undefined' instead of expected '9'.
If anyone could shed some light on why this is happening in both TypeScript and JavaScript realms, I would greatly appreciate it.