I just started learning TypeScript and I don't have any prior knowledge of JavaScript. I know both are kind of similar. I am facing an issue at runtime, not compile time. Perhaps I am misusing the syntax? The video tutorial I am currently learning from is pretty old. Maybe th syntax has changed in the meantime. Can you please tell me, what the problem is with the code? I would be thankful for typescript best practices and guides.
Code:
class Point{
x: number;
y: number;
draw(){
console.log('X ' + this.x + ',Y ' + this.y);
}
GetDistance(another: Point){
//....
}
}
let p = new Point();
p.draw();
Console output:
Error: x: number;
SyntaxError: Unexpected identifier
[90m at wrapSafe (internal/modules/cjs/loader.js:1054:16)[39m
[90m at Module._compile (internal/modules/cjs/loader.js:1102:27)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:986:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:879:14)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)[39m
[90m at internal/main/run_main_module.js:17:47[39m