TypeScript
interface Shape {
color: string;
}
interface Square extends Shape {
sideLength: number;
}
let square = <Square>{};
square.color = "blue";
square.sideLength = 10;
对应生成的JavaScript:
var square = {};
square.color = "blue";
square.sideLength = 10;
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;
对应的JavaScript代码:
var square = {};
square.color = "blue";
square.sideLength = 10;
square.penWidth = 5.0;
extends ___ = ___ syntax in typescript
export interface ActionReducer<T, V extends Action = Action> {
(state: T | undefined, action: V): T;
}
It specifies the default type of V . so V can be either a class which extends Action or if not mentioned will be of type Action.