Typescript errors when setting color properties of various Cesium objects
- Dominant language
- JavaScript
- Stars
- 15.8k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
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.
Contributor guide
Research direction
Start by inspecting node_modules/cesium/Source/Cesium.d.ts around line 21534 and compare the fillColor definition with the corresponding LabelGraphics runtime behavior. Reproduce the direct Cesium.Color assignment and the ColorMaterialProperty assignment in a TypeScript consumer. Done means the definitions and runtime behavior agree for the reported color properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- computer-graphics, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100