Kiedy próbuję stworzyć dziedziczenie w maszynopisie następujące JavaScript zostanie wygenerowany:maszynopis: Błąd typu b jest niezdefiniowana
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
który wygląda dokładnie jak ten, który powinien być wygenerowany. Ale problemem jest to, że na wykonanie Firefox daje komunikat:
TypeError: b is undefined
W Chrome błąd wygląda nieco inaczej, ale wydaje się być tego samego pochodzenia:
Uncaught TypeError: Cannot read property 'prototype' of undefined
Realizacja w maszynopisie wygląda to
class Movie extends Medium {
//Some Fields
constructor(title: string, description: string, ageRestriction: AgeRestriction, isBluRay: boolean) {
super(title, description, ageRestriction);
this.isBluRay = isBluRay;
}
}
class Medium implements IMedium {
//Getters, Setters and Fields
constructor(title: string, description: string, ageRestriction: AgeRestriction) {
this.title = title;
this.description = description;
this.ageRestriction = ageRestriction;
}
}
próbowałem już różne sposoby kompilacji kodu, ale wynik jest zawsze taki sam
Dzięki, że rozwiązałeś problem – Bajellor