最佳答案
TypeScript语言规范的第6.3节讨论了函数重载,并给出了如何实现函数重载的具体示例。然而,如果我尝试这样做:
export class LayerFactory {
constructor (public styleFactory: Symbology.StyleFactory) { }
createFeatureLayer (userContext : Model.UserContext, mapWrapperObj : MapWrapperBase) : any {
throw "not implemented";
}
createFeatureLayer(layerName : string, style : any) : any {
throw "not implemented";
}
}
我得到一个编译器错误指示重复的标识符,即使函数参数是不同的类型。即使我在第二个createFeatureLayer函数中添加了一个额外的参数,我仍然会得到一个编译器错误。想法,请。