I am using mapbox with angular. And I try to show/hide some stuff with mapbox.
So I have this component:
export class ToggleLayersComponent implements OnInit {
layouts = {
contours: {
visibility: 'visible',
'line-join': 'round',
'line-cap': 'round',
},
museums: {
visibility: 'visible',
},
};
ngOnInit() {}
toggleLayer(evt: {value: 'contours' | 'museums'}) {
this.layouts[evt.value] = {
...this.layouts[evt.value],
visibility: this.layouts[evt.value].visibility === 'visible' ? 'none' : 'visible',
};
}
}
But I get this error:
Type '{ visibility: string; 'line-join': string; 'line-cap': string; } | { visibility: string; }' is not assignable to type '{ visibility: string; 'line-join': string; 'line-cap': string; } & { visibility: string; }'.
Type '{ visibility: string; }' is not assignable to type '{ visibility: string; 'line-join': string; 'line-cap': string; } & { visibility: string; }'.
Type '{ visibility: string; }' is missing the following properties from type '{ visibility: string; 'line-join': string;
Of course I googled first. But I can't find any solution.
So how to fix this?
Thank you
So the error is on this line:
this.layouts[evt.value]
So I can't even run Angular anymore:
ERROR in src/app/desktop-dashboard/toggle-layer/toggle-layer.component.ts:63:5 - error TS2322: Type '{ visibility: string; 'line-join': string; 'line-cap': string; } | { visibility: string; }' is not assignable to type '{ visibility: string; 'line-join': string; 'line-cap': string; } & { visibility: string; }'.
Type '{ visibility: string; }' is not assignable to type '{ visibility: string; 'line-join': string; 'line-cap': string; } & { visibility: string; }'.
Type '{ visibility: string; }' is missing the following properties from type '{ visibility: string; 'line-join': string; 'line-cap': string; }': 'line-join', 'line-cap'
63 this.layouts[evt.value] = {