【Typescript 】extends. if number2, return error, how to create extends Class

[javascript]
class ErrorReport{
public reportIt(){
if(this.num == 2){
return "error";
} else {
return "ok";
}
}
constructor(public num:number){
}
}
var faf = new ErrorReport(2);
alert(faf.reportIt());//error
[/javascript]

but this is diffcult to understand someone that saw source code,
then, extend class function,

[javascript]
class ErrorReport{
public reportIt(){
alert(this.errorNumber);
}
constructor(public errorNumber:number){
}
}
class RichErrorReport extends ErrorReport {
public reportIt(){
if(this.errorNumber == 1) alert("Memory Overflow");
else if (this.errorNumber == 2) alert("File Not Found");
else alert(this.errorNumber);
}
}
var faf:ErrorReport = new RichErrorReport(2);
alert(faf.reportIt());
[/javascript]

## duckTyping。Since the members are included in the type A in B, it does not matter even if the extra member is present. Operate
[javascript]
class A {
a: number;
}
class B {
a: number;
b: number;
}
var x: A = new B();

[/javascript]

## Definition of TypeScript can take advantage of the objects defined in the javascript side without
[javascript]
var A = (function(){
function A (msg){
this.msg = msg;
}
return A;
})();

declare class A {
msg: string;
constructor(msg: string);
}
var a = new A("Message frome Space");
alert(a.msg);
[/javascript]