Modules in typescript are compatible with interfaces. e.g. the following is valid:
module M{
var s = "test"
export function f(){
return s;
}
}
interface ITest{
f():string;
}
var x:ITest = M;
However is it possible to have a callable signature in a module? Specifically how can I write a module compatible with the following interface:
interface ITest{
():string;
}
No, it is not possible. The only entity that can match a call signature is a function
interface ITest{
():string;
}
var x:ITest = function() {return "";}
var y:ITest = () => "";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With