Applying a new style (stroke color) to a GeoJSON polygon

Any idea on what is wrong here?

Actually yes! That info helps a lot. This is not the first weird little quirk of using CesiumJS in Typescript and probably won’t be the last. I actually found exactly this same issue previously reported in github: Typescript errors when setting color properties of various Cesium objects · Issue #9667 · CesiumGS/cesium · GitHub

Borrowing words from a previous comment:

These are Property instances, just not a MaterialProperty, i.e.

graphics.outlineColor = new ConstantProperty(Color.BLUE);
graphics.outlineColor = new SampledProperty(Color);

graphics.outlineColor = Color.BLUE; works but will result in graphics.outlineColor being a ConstantProperty (using implicit conversion borrowed from C#).

Changing your code to use ConstantProperty should work and make typescript happy, see an updated sandcastle. Maybe not ideal but hopefully that works for you for now.

Longer term we’ve recently been working on improving how we generate our Types files in the first place which should hopefully make creating actual fixes for issues like these easier.

2 Likes