I have some code like this
interface ClockInterface {
currentTime: Date;
setTime(d: Date, d2:Date);
}
class Clock implements ClockInterface {
currentTime: Date;
setTime(d: Date) {
this.currentTime = d;
}
constructor(h: number, m: number) { }
}
I hope typescript will give me an error like the method "setTime" should have two param, but it does not happen. Why?
@overrideannotation, so the compiler can ensure that you're actually implementing the method properly.d2so it just ignores that possible parameter. The Typescript team felt that this was a common enough pattern for Javascript developers that they made it so that you can always specify a smaller function header than what's required and it will type check. Source: github.com/Microsoft/TypeScript/wiki/…