From 13ebc7fd5a4643a5a311abef862fdb3546d86f43 Mon Sep 17 00:00:00 2001 From: Wykks Date: Wed, 15 Nov 2017 01:21:02 +0100 Subject: [PATCH] refactor: fix for ts 2.6 --- .../lib/control/geolocate-control.directive.ts | 9 +++++++-- src/app/lib/map/map.service.ts | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/app/lib/control/geolocate-control.directive.ts b/src/app/lib/control/geolocate-control.directive.ts index 28d843898..b16ba719a 100644 --- a/src/app/lib/control/geolocate-control.directive.ts +++ b/src/app/lib/control/geolocate-control.directive.ts @@ -29,9 +29,14 @@ export class GeolocateControlDirective implements OnInit { trackUserLocation: this.trackUserLocation, showUserLocation: this.showUserLocation }; + Object.keys(options) - .forEach((key: keyof typeof options) => - options[key] === undefined && delete options[key]); + .forEach((key: string) => { + const tkey = key; + if (options[tkey] === undefined) { + delete options[tkey]; + } + }); this.ControlComponent.control = new GeolocateControl(options); this.MapService.addControl(this.ControlComponent.control, this.ControlComponent.position); }); diff --git a/src/app/lib/map/map.service.ts b/src/app/lib/map/map.service.ts index 03711fe11..03a419546 100644 --- a/src/app/lib/map/map.service.ts +++ b/src/app/lib/map/map.service.ts @@ -177,8 +177,12 @@ export class MapService { addLayer(layer: SetupLayer, before?: string) { this.zone.runOutsideAngular(() => { Object.keys(layer.layerOptions) - .forEach((key: keyof MapboxGl.Layer) => - layer.layerOptions[key] === undefined && delete layer.layerOptions[key]); + .forEach((key: string) => { + const tkey = key; + if (layer.layerOptions[tkey] === undefined) { + delete layer.layerOptions[tkey]; + } + }); this.mapInstance.addLayer(layer.layerOptions, before); this.mapInstance.on('click', layer.layerOptions.id, (evt: MapboxGl.MapMouseEvent) => { this.zone.run(() => { @@ -340,8 +344,12 @@ export class MapService { private createMap(options: MapboxGl.MapboxOptions) { Object.keys(options) - .forEach((key: keyof MapboxGl.MapboxOptions) => - options[key] === undefined && delete options[key]); + .forEach((key: string) => { + const tkey = key; + if (options[tkey] === undefined) { + delete options[tkey]; + } + }); this.mapInstance = new MapboxGl.Map(options); }