【发布时间】:2013-01-26 15:40:08
【问题描述】:
为什么 Typescript 没有警告我我定义的函数与接口声明不匹配,但如果我尝试调用该函数,它会警告我。
interface IFormatter {
(data: string, toUpper : boolean): string;
};
//Compiler does not flag error here.
var upperCaseFormatter: IFormatter = function (data: string) {
return data.toUpperCase();
}
upperCaseFormatter("test"); //but does flag an error here.
【问题讨论】:
标签: interface typescript