TypeScript


interface Shape {
    color: string;
}

interface Square extends Shape {
    sideLength: number;
}

let square = <Square>{};
square.color = "blue";
square.sideLength = 10;
Copy the code

Corresponding to generated JavaScript:

var square = {};
square.color = "blue";
square.sideLength = 10;
Copy the code

TypeScript

interface Shape {
    color: string;
}

interface PenStroke {
    penWidth: number;
}

interface Square extends Shape, PenStroke {
    sideLength: number;
}

let square = <Square>{};
square.color = "blue";
square.sideLength = 10;
square.penWidth = 5.0;
Copy the code

The corresponding JavaScript code:

var square = {};
square.color = "blue";
square.sideLength = 10;
square.penWidth = 5.0;
Copy the code