← Каталог
Объекты и классы в TypeScript — Наследование и `super`
Фрагмент из «Объекты и классы в TypeScript»: Наследование и `super`.
class Entity {
constructor(public id: string) {}
}
class Product extends Entity {
constructor(
id: string,
public title: string,
public price: number,
) {
super(id);
}
label(): string {
return `${this.title} (${this.price})`;
}
} class Entity {
constructor(public id: string) {}
}
class Product extends Entity {
constructor(
id: string,
public title: string,
public price: number,
) {
super(id);
}
label(): string {
return `${this.title} (${this.price})`;
}
}