You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When setting a color-property (color, fillColor, outlineColor, etc) of an instance of a Cesium object, the typescript definitions don't seem to match the actual implementation in CesiumJS.
For instance, if I try to set the fillColor of a LabelGraphics object:
labelGraphics.fillColor = Cesium.Color.PURPLE
typescript errors occur when setting the property to a Cesium.Color directly. Wrapping the Color in a ColorMaterialProperty:
labelGraphics.fillColor = new ColorMaterialProperty(Cesium.Color.PURPLE)
this silences the typescript error, but the color isn't applied during runtime.
If I ignore the typescript error and set the color directly it does work, but then the typescript errors interfere with my normal development process.
Sandcastle example:
AFAIK there is no option to use typescript in sandcastle, so it's not possible to repro this issue there.
Browser: Any
Operating System: MacOS (not likely to have a bearing on this)
Looking at the typescript definitions in node_modules/cesium/Source/Cesium.d.ts, I see at line 21534:
fillColor: Property | undefined;
If I change this to:
fillColor: Color | Property | undefined;
this solves the problem, but it's debatable whether this is the proper solution or rather that the implementation in CesiumJS should be fixed to match the typescript definitions.
The text was updated successfully, but these errors were encountered:
The solution Matt mentioned in this comment to use new ConstantProperty(Color.RED) instead of the color directly should work and make Typescript happy.
Longer term I think this is something that should be easier to address once #10455 and #8359 are addressed
I'm surprised this issue is still open. Back in 2020 I started work on a (pre-existing) large angular application that employs Cesium for mapping. The cesium dependency in that application was many releases behind at the time, and my first task was updating it which led to typescript errors that I thought should be solved by changing the jsdoc typings of some properties. I even made a pull request to that end (9673).
The suggestion by @mramato to wrap the color in a constantproperty was spot on however, and solved my issues, so I closed the PR, which was unnecessary.
I do concur that the documentation on this could be improved.
When setting a color-property (color, fillColor, outlineColor, etc) of an instance of a Cesium object, the typescript definitions don't seem to match the actual implementation in CesiumJS.
For instance, if I try to set the fillColor of a LabelGraphics object:
labelGraphics.fillColor = Cesium.Color.PURPLE
typescript errors occur when setting the property to a Cesium.Color directly. Wrapping the Color in a ColorMaterialProperty:
labelGraphics.fillColor = new ColorMaterialProperty(Cesium.Color.PURPLE)
this silences the typescript error, but the color isn't applied during runtime.
If I ignore the typescript error and set the color directly it does work, but then the typescript errors interfere with my normal development process.
Sandcastle example:
AFAIK there is no option to use typescript in sandcastle, so it's not possible to repro this issue there.
Browser: Any
Operating System: MacOS (not likely to have a bearing on this)
Looking at the typescript definitions in node_modules/cesium/Source/Cesium.d.ts, I see at line 21534:
fillColor: Property | undefined;
If I change this to:
fillColor: Color | Property | undefined;
this solves the problem, but it's debatable whether this is the proper solution or rather that the implementation in CesiumJS should be fixed to match the typescript definitions.
The text was updated successfully, but these errors were encountered: