I have a JavaScript function that creates a style object in my Typescript class. My project is using Angular version 5:
private createCircle(parameters: any): any {
return new Circle({
radius: parameters.radius,
snapToPixel: parameters.snapToPixel,
fill: new Fill(parameters.fill),
stroke: new Stroke(parameters.stroke)
});
}
Circle, Fill and Stroke are third party library classes. And function parameter (parameters) is a JSON object like this:
{
"radius": 10,
"snapToPixel": true,
"fill": {
"color": "rgba(255, 255, 0, 0.4)"
},
"stroke": {
"color": "red",
"width": 1,
"lineDash": null,
"lineCap": "round",
"lineJoin": "round",
"miterLimit": 10
}
}
Can I cast this JSON object to a Circle class directly? (Circle, Fill and Stroke should be created using the new keyword)