All:
I am pretty new to typescript, when I try typescript handbook, there are two type(function and class) Interface definitions:
For function, it says:
interface SearchFunc {
(source: string, subString: string): boolean;
}
For class, it says:
interface ClockInterface {
currentTime: Date;
setTime(d: Date);
}
class Clock implements ClockInterface {
currentTime: Date;
setTime(d: Date) {
this.currentTime = d;
}
constructor(h: number, m: number) { }
}
What confuses me here is:
Why there are diff ways to define function inside Interface, in the Function Types section it says:
To describe a function type with an interface, we give the interface a call signature. This is like a function declaration with only the parameter list and return type given.
Why both works when define function? Or the second one( setTime(d: Date); part ) is not a function definition?
Thanks