@@ -5,41 +5,31 @@ import type {TypedStyleLayer} from './style_layer/typed_style_layer';
55import type { LayerSpecification } from '../style-spec/types' ;
66import type { ConfigOptions } from './properties' ;
77
8- export type LayerConfigs = {
9- [ _ : string ] : LayerSpecification ;
10- } ;
8+ export type LayerConfigs = Record < string , LayerSpecification > ;
119
1210export type Family < Layer extends TypedStyleLayer > = Array < Layer > ;
1311
1412class StyleLayerIndex {
1513 scope : string ;
16- familiesBySource : {
17- [ source : string ] : {
18- [ sourceLayer : string ] : Array < Family < TypedStyleLayer > > ;
19- } ;
20- } ;
21- keyCache : {
22- [ source : string ] : string ;
23- } ;
14+ familiesBySource : Record < string , Record < string , Array < Family < TypedStyleLayer > > > > ;
15+ keyCache : Record < string , string > ;
2416
2517 _layerConfigs : LayerConfigs ;
26- _layers : {
27- [ _ : string ] : TypedStyleLayer ;
28- } ;
18+ _layers : Record < string , TypedStyleLayer > ;
2919 _options : ConfigOptions | null | undefined ;
3020
3121 constructor ( layerConfigs ?: Array < LayerSpecification > | null ) {
32- this . keyCache = { } ;
33- this . _layers = { } ;
34- this . _layerConfigs = { } ;
22+ this . keyCache = Object . create ( null ) as Record < string , string > ;
23+ this . _layers = Object . create ( null ) as Record < string , TypedStyleLayer > ;
24+ this . _layerConfigs = Object . create ( null ) as LayerConfigs ;
3525 if ( layerConfigs ) {
3626 this . replace ( layerConfigs ) ;
3727 }
3828 }
3929
4030 replace ( layerConfigs : Array < LayerSpecification > , options ?: ConfigOptions | null ) {
41- this . _layerConfigs = { } ;
42- this . _layers = { } ;
31+ this . _layerConfigs = Object . create ( null ) as LayerConfigs ;
32+ this . _layers = Object . create ( null ) as Record < string , TypedStyleLayer > ;
4333 this . update ( layerConfigs , [ ] , options ) ;
4434 }
4535
@@ -60,7 +50,7 @@ class StyleLayerIndex {
6050 delete this . _layers [ id ] ;
6151 }
6252
63- this . familiesBySource = { } ;
53+ this . familiesBySource = Object . create ( null ) as StyleLayerIndex [ 'familiesBySource' ] ;
6454
6555 const groups = groupByLayout ( Object . values ( this . _layerConfigs ) , this . keyCache ) ;
6656
@@ -75,7 +65,7 @@ class StyleLayerIndex {
7565 const sourceId = layer . source || '' ;
7666 let sourceGroup = this . familiesBySource [ sourceId ] ;
7767 if ( ! sourceGroup ) {
78- sourceGroup = this . familiesBySource [ sourceId ] = { } ;
68+ sourceGroup = this . familiesBySource [ sourceId ] = Object . create ( null ) as Record < string , Array < Family < TypedStyleLayer > > > ;
7969 }
8070
8171 const sourceLayerId = layer . sourceLayer || '_geojsonTileLayer' ;
0 commit comments