Я почти уверен, что есть проблемы с форматированием, или вы используете компилятор, которому не нравится синтаксис, но вот код, который я выполнил в https://www.typescriptlang.org/play/, и он работал отлично.
class Point {
private x: number;
private y: number;
constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
public distance(otherPoint: Point): number {
return Math.sqrt(
Math.pow(this.x - otherPoint.getX(), 2) +
Math.pow(this.y - otherPoint.getY(), 2));
}
public getX() {
return this.x;
}
public getY() {
return this.y;
}
}
class Circle {
private center: Point;
private radius: number;
constructor(center: Point, radius: number) {
this.radius = radius;
this.center = center;
}
public isInside(otherPoint: Point): boolean {
return this.center.distance(otherPoint) < this.radius;
}
}
class Triangle extends Point {
private z: number;
constructor(x:number, y: number, z: number) {
super(x, y);
this.z = z;
}
public getZ() {
return this.z
}
public getPerimeter(otherPoint: Triangle): number {
return otherPoint.getX() + otherPoint.getY() + otherPoint.getZ()
}
}
let per = new Triangle(24, 61, 32);
console.log(per);
Запустите приведенный выше код в указанной мной ссылке, нажмите «Выполнить» и нажмите «F12», чтобы открыть консоль, вы увидите вывод из console.log