相关疑难解决方法(0)

TypeScript函数重载

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";
     }        

}
Run Code Online (Sandbox Code Playgroud)

即使函数参数属于不同类型,我也会收到指示重复标识符的编译器错误.即使我在第二个createFeatureLayer函数中添加了一个额外的参数,我仍然会遇到编译器错误.想法,请.

overloading typescript

212
推荐指数
5
解决办法
15万
查看次数

标签 统计

overloading ×1

typescript ×1