interface ClockInterface {
currentTime: Date;
}
class Clock implements ClockInterface {
currentTime: Date;
constructor(private h: number, private m: number) { this.currentTime = new Date();
}
}
var Clock = /** @class */ (function () {
function Clock(h, m) {
this.h = h;
this.m = m;
this.currentTime = new Date();
}
return Clock;
}());
构造函数里定义的参数,会自动成为JavaScript函数的属性。