'TypeScript doesn't show Errors on a initialized class that hasnt been imported
So i started learning TypeScript using VSCode and while practicing i created two .ts: point.ts that contains a Point class and in another where i initialized said class. I expected to see an error cause i haven't imported it yet.
main.ts
let point = new Point(2,1);// no Error
point.draw();
point.ts
/*export*/ class Point { //error appear if export is added
constructor(private x?: number, private y?: number) {
}
draw() {
console.log(`X: ${this.x}, Y: ${this.y}`);
}
}
The error only appears after the 'export' declaration is added to the Point class, i've checked the tsconfig file if there was something that would explain this, and is hard to search this problem when problem is that there's no error.
Of course after compiling and executing it shows the error as expected.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|