Can't change properties when using TypeScript type definitions

Hi, I’m currently testing the new TypeScript support and run into some problems. Before, the following code would compile and run properly:

private updateLabel(l: Entity, visible: boolean, text: string): void {
    l.show = visible;
    if (l.polyline) {
        l.polyline.show = visible;
    }
    if (l.label) {
        l.label.text = text;
    }
}

But now the compile throws an error, because “l.polyline.show” is not a boolean, but a Property (or undefined), similar for “l.label.text”.

How am I supposed to change these properties in the correct way?

You need to wrap it in a ConstantProperty as @Matt_Amato explains in this GitHub issue: typescript issues · Issue #8898 · CesiumGS/cesium · GitHub

polyline.width = 12;

needs to be

polyline.width = new ConstantProperty(12);

Thanks, works. Only remark is, that by this design, there is no type information about the real type of the property in the client code. Typed properties would be a lot better here.

1 Like