TypeScript語言規(guī)范的6.3節(jié)討論了函數(shù)重載,并提供了有關(guān)如何實現(xiàn)此功能的具體示例。但是,如果我嘗試這樣的事情: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"; } }我收到一個編譯器錯誤,指示重復的標識符,即使函數(shù)參數(shù)的類型不同。即使我向第二個createFeatureLayer函數(shù)添加了一個附加參數(shù),我仍然會遇到編譯器錯誤。請給我個主意。
TypeScript函數(shù)重載
開心每一天1111
2019-10-28 10:33:17