Wrong type in typescript

In Cesium.d.ts, the type of many property is wrong.
For example: the type of PolygonGraphics.material should be “MaterialProperty|Color|string ”, but now, it only be MaterialProperty


Why?

The type is right because after you create a entity, your color will be changed to a ColorMaterialProperty by createMaterialProperty().

But sure, I think that is not good enough. They could provide a setter which can accept a MaterialProperty, a Color or a string which may make this better.

1 Like

Yes, you are right.

But in create ,

material should be create by Color or String(texture url), but …

I filed an issue about this a while ago. I even went as far as submitting a pull request to ‘fix’ it.
However, as @mramato pointed out at the time, it wasn’t something that is so easily fixed. Javascript allows you (and the cesium developers) to do things that are hard to codify in typescript. It would be nice to see MaterialProperty | Color | string as the type for these properties, but I don’t expect they’ll get round to fixing this anytime soon.
You can work around the issue by explicitly creating a MaterialProperty with the color or texture you want to apply.

1 Like