I created a parent class in TypeScript, this class was then extended by the child.
class x {
s: number;
c: string;
constructor(s, c) {
this.s = s;
this.c = c;
}
}
class y extends x {
g: string;
constructor(s, c, g) {
super(s, c);
this.g = g;
}
display() {
document.write("" + this.s + " " + this.c + " " + this.g);
}
}
let bp = new y("f");
bp.display();
However, when I pass the string f
to the child object, no error is caused, even though the first parameter in its constructor is of type number. Why is that?