The only solution I’ve found is to use type cast. It works, but looks quite ugly. To me this is an error in the compiler or there should be different way to do this.
UPD: Indeed, this is the only solution, http://typescript.codeplex.com/discussions/401235
interface X{
f:{
(s:string):string;
(s:number):string;
data:any;
};
}
class xxx
{
constructor()
{
this.f = <{ (s:string):string; (s:number):string; data:any; }> function (s:any):string {return s.toString();};
this.f.data = "data"
};
f:{
(s:string):string;
(s:number):string;
data:any;
};
}
var x = new xxx();
function a(x:X):string{
return x.f("1") + x.f(1) + x.f.data;
}
alert(a(x));
1
solved Overload implementation