In Typescript, we can have a function implement an interface like this:
interface ISample {
(argument: boolean): number
}
let v: ISample;
v = function (isTrue: boolean): number {
return 10;
}
But that applies only to functions created via function expressions (that is, initializing them through a variable, in this case it's v). When I try to do something similar to a function statement, it doesn't work:
interface ISample {
(argument: boolean): number
}
function v: ISample (isTrue: boolean): number {
return 10;
} // Doesn't work, compiler says '"(" expected'
So, is there a way to do that with function statements or tough luck, I'll have to ditch interface functions or use function expressions instead? Thanks!