Reputation: 275927
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;
}
Upvotes: 6
Views: 752
Reputation: 11953
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 = () => "";
Upvotes: 2