interface Counter {
(start: number): string;
interval: number;
reset(): void;
}
function getCounter(): Counter {
let counter = <Counter>function (start: number) { };
counter.interval = 123;
counter.reset = function () { };
return counter;
}
Why does the above API specify that the counter function returns string, but in fact, the counter function does not return, and does not report an error
interface Counter {
(start: number): void;
interval: number;
reset(): void;
}
function getCounter(): Counter {
let counter = <Counter>function (start: number) { return "12"};
counter.interval = 123;
counter.reset = function () { };
return counter;
}
but I swapped the interface and function return and reported an error