在TypeScript或Javascript中如何处理类型转换?
假设我有以下TypeScript代码:
module Symbology {
export class SymbolFactory {
createStyle( symbolInfo : SymbolInfo) : any {
if (symbolInfo == null)
{
return null;
}
if (symbolInfo.symbolShapeType === "marker") {
// how to cast to MarkerSymbolInfo
return this.createMarkerStyle((MarkerSymbolInfo) symbolInfo);
}
}
createMarkerStyle(markerSymbol : MarkerSymbolInfo ): any {
throw "createMarkerStyle not implemented";
}
}
}
其中SymbolInfo是基类。我如何处理类型转换从SymbolInfo到MarkerSymbolInfo在TypeScript或Javascript?