【发布时间】:2012-10-19 16:02:37
【问题描述】:
在视频中,我发现接口可以使用奇怪的重载技术。下面的代码已编译但不起作用。 我有一些问题,都放在代码里面了:
interface X{
// how can the class implements such overload ?
f:{
(s:string):string;
(s:number):string;
data:any;
};
}
class xxx
{
// how to initialize this structure ?
f:{
(s:string):string;
(s:number):string;
data:any;
};
}
var x = new xxx();
// how should the class xxxx look to be used with this function ?
function a(x:X):string{
return x.f("1");
}
a(x);
【问题讨论】:
标签: typescript