Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
UN-13 Technical: Translate schemas to typescript (#1721)
Maksim Suslovcb5428534c6e
diff --git a/src/actions/actions.d.ts b/src/actions/actions.d.tsindex 9acefec60..8778d26c7 100644--- a/src/actions/actions.d.ts+++ b/src/actions/actions.d.ts@@ -19,7 +19,7 @@// THE SOFTWARE.import ActionTypes from 'constants/action-types';-import {ParsedConfig} from '../schemas';+import {ParsedConfig} from 'schemas';import {RGBColor} from 'reducers/types';import {Bounds} from 'reducers/map-state-updaters';import {MapInfo} from 'reducers/vis-state-updaters';diff --git a/src/actions/vis-state-actions.d.ts b/src/actions/vis-state-actions.d.tsindex 8b2e3cac0..e3f3af5cc 100644--- a/src/actions/vis-state-actions.d.ts+++ b/src/actions/vis-state-actions.d.ts@@ -21,7 +21,7 @@// vis-state-reducerimport ActionTypes, {ActionType} from 'constants/action-types';import {ProtoDataset, AddDataToMapPayload} from '../actions/actions';-import {ParsedConfig} from '../schemas';+import {ParsedConfig} from 'schemas';import {FileCacheItem} from '../processors/file-handler';import {Layer, LayerConfig, LayerVisConfig} from 'layers';import {Feature, InteractionConfig} from 'reducers/vis-state-updaters';@@ -124,7 +124,6 @@ export function setFilter(valueIndex: number): Merge<SetFilterUpdaterAction, {type: ActionTypes.SET_FILTER}>;-export type SetFilterAnimationTimeUpdaterAction = {idx: number;prop: string;@@ -144,10 +143,9 @@ export type SetFilterAnimationWindowUpdaterAction = {};export function setFilterAnimationWindow({id: string,- animationWindow: string,+ animationWindow: string}): Merge<SetFilterAnimationWindowUpdaterAction, {type: ActionTypes.SET_FILTER_ANIMATION_WINDOW}>;-export type AddFilterUpdaterAction = {dataId: string;};@@ -161,7 +159,7 @@ export type AddLayerUpdaterAction = {};export function addLayer(config: object,- datasetId?: string,+ datasetId?: string): Merge<AddLayerUpdaterAction, {type: ActionTypes.ADD_LAYER}>;export type ReorderLayerUpdaterAction = {@@ -207,9 +205,9 @@ export function showDatasetTable(): Merge<ShowDatasetTableUpdaterAction, {type: ActionTypes.SHOW_DATASET_TABLE}>;export type UpdateDatasetColorUpdater = {- dataId: string,- newColor: RGBColor-}+ dataId: string;+ newColor: RGBColor;+};export function updateTableColor(dataId: string,newColor: RGBColor@@ -266,7 +264,7 @@ export type RenameDatasetUpdaterAction = {label: string;};export function renameDataset(- dataId: string,+ dataId: string,label: string): Merge<RenameDatasetUpdaterAction, {type: ActionTypes.RENAME_DATASET}>;@@ -304,12 +302,16 @@ export function updateLayerAnimationSpeed(): Merge<UpdateLayerAnimationSpeedUpdaterAction, {type: ActionTypes.UPDATE_LAYER_ANIMATION_SPEED}>;export type ToggleLayerAnimationUpdaterAction = {};-export function toggleLayerAnimation():- Merge<ToggleLayerAnimationUpdaterAction, {type: ActionTypes.TOGGLE_LAYER_ANIMATION}>;+export function toggleLayerAnimation(): Merge<+ ToggleLayerAnimationUpdaterAction,+ {type: ActionTypes.TOGGLE_LAYER_ANIMATION}+>;export type ToggleLayerAnimationControlUpdaterAction = {};-export function toggleLayerAnimationControl():- Merge<ToggleLayerAnimationControlUpdaterAction, {type: ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL}>;+export function toggleLayerAnimationControl(): Merge<+ ToggleLayerAnimationControlUpdaterAction,+ {type: ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL}+>;export type EnlargeFilterUpdaterAction = {idx: number;@@ -506,7 +508,7 @@ export type SetFilterAnimationTimeConfigAction = {timezone?: string;timeFormat?: string;};-}+};export function setFilterAnimationTimeConfig(idx: SetFilterAnimationTimeConfigAction['idx'],config: SetFilterAnimationTimeConfigAction['config']diff --git a/src/reducers/vis-state-updaters.d.ts b/src/reducers/vis-state-updaters.d.tsindex 29fc4a27b..3f18eefab 100644--- a/src/reducers/vis-state-updaters.d.ts+++ b/src/reducers/vis-state-updaters.d.ts@@ -1,6 +1,6 @@import {RGBColor, RGBAColor, Millisecond} from './types';import {AddDataToMapOptions, ReceiveMapConfigPayload} from '../actions/actions';-import {ParsedConfig} from '../schemas';+import {ParsedConfig} from 'schemas';import * as VisStateActions from 'actions/vis-state-actions';import ActionTypes from 'constants/action-types';import {LoaderObject} from '@loaders.gl/loader-utils';diff --git a/src/schemas/dataset-schema.js b/src/schemas/dataset-schema.tssimilarity index 97%rename from src/schemas/dataset-schema.jsrename to src/schemas/dataset-schema.tsindex addea65d7..db80f06a6 100644--- a/src/schemas/dataset-schema.js+++ b/src/schemas/dataset-schema.ts@@ -23,7 +23,7 @@ import {console as globalConsole} from 'global/window';import {VERSIONS} from './versions';import Schema from './schema';-import {getFieldsFromData, getSampleForTypeAnalyze} from 'processors/data-processor';+import {getFieldsFromData, getSampleForTypeAnalyze} from '../processors/data-processor';// version v0const fieldPropertiesV0 = {diff --git a/src/schemas/index.d.ts b/src/schemas/index.d.tsdeleted file mode 100644index e0a1b9411..000000000--- a/src/schemas/index.d.ts+++ /dev/null@@ -1,24 +0,0 @@-import {KeplerGLSchema} from './schema-manager';-import Schema from './schema';--export {- default,- default as KeplerGlSchema,- ParsedConfig,- ParsedDataset,- ParsedLayer,- ParsedFilter,- SavedConfigV1,- SavedDatasetV1,- SavedMap,- reducerSchema-} from './schema-manager';-export {CURRENT_VERSION, VERSIONS} from './versions';--export const KeplerGLSchemaClass: typeof KeplerGLSchema;-export const visStateSchema: {[key: string]: Schema};-export const datasetSchema: {[key: string]: Schema};-export const mapStyleSchema: {[key: string]: Schema};-export const mapStateSchema: {[key: string]: Schema};--export {default as Schema} from './schema';diff --git a/src/schemas/index.js b/src/schemas/index.tssimilarity index 92%rename from src/schemas/index.jsrename to src/schemas/index.tsindex 1517cee83..63aba6c81 100644--- a/src/schemas/index.js+++ b/src/schemas/index.ts@@ -25,6 +25,16 @@ export {reducerSchema,KeplerGLSchema as KeplerGLSchemaClass} from './schema-manager';++export type {+ ParsedConfig,+ ParsedDataset,+ ParsedLayer,+ ParsedFilter,+ SavedConfigV1,+ SavedDatasetV1,+ SavedMap+} from './schema-manager';export {CURRENT_VERSION, VERSIONS} from './versions';export {visStateSchemaV1,diff --git a/src/schemas/map-state-schema.js b/src/schemas/map-state-schema.tssimilarity index 100%rename from src/schemas/map-state-schema.jsrename to src/schemas/map-state-schema.tsdiff --git a/src/schemas/map-style-schema.js b/src/schemas/map-style-schema.tssimilarity index 100%rename from src/schemas/map-style-schema.jsrename to src/schemas/map-style-schema.tsdiff --git a/src/schemas/schema-manager.d.ts b/src/schemas/schema-manager.d.tsdeleted file mode 100644index 85f355ef4..000000000--- a/src/schemas/schema-manager.d.ts+++ /dev/null@@ -1,228 +0,0 @@-import {- InteractionConfig,- Filter,- TooltipInfo,- SplitMap,- AnimationConfig,- VisState,- RGBColor,- Merge,- RGBAColor-} from 'reducers';-import {Schema} from './schema';--import {LayerTextLabel} from 'layers/layer-factory';-import {datasetSchema, visStateSchema, mapStyleSchema, mapStateSchema} from 'schemas';--export type SavedFilter = {- dataId: Filter['dataId'];- id: Filter['id'];- name: Filter['name'];- type: Filter['type'];- value: Filter['value'];- enlarged: Filter['enlarged'];- plotType: Filter['plotType'];- yAxis: {- name: string;- type: string;- } | null;- speed: Filter['speed'];- layerId: Filter['layerId'];-};--export type ParsedFilter = Partial<SavedFilter>;--export type SavedInteractionConfig = {- tooltip: TooltipInfo['config'] & {- enabled: boolean;- };- geocoder: TooltipInfo['geocoder'] & {- enabled: boolean;- };- brush: TooltipInfo['brush'] & {- enabled: boolean;- };- coordinate: TooltipInfo['coordinate'] & {- enabled: boolean;- };-};--export type SavedField = {- name: string;- type: string;-} | null;-export type SavedScale = string;-export type SavedVisualChannels = {- [key: string]: SavedField | SavedScale;-};--export type SavedLayer = {- id: string;- type: string;- config: {- dataId: string;- label: string;- color: RGBColor;- highlightColor: RGBAColor;- columns: {- [key: string]: string;- };- isVisible: boolean;- visConfig: object;- hidden: boolean;- textLabel: Merge<LayerTextLabel, {field: {name: string; type: string} | null}>;- };- visualChannels: SavedVisualChannels;-};--export type ParsedLayer = {- id?: string;- type?: string;- config?: Partial<SavedLayer['config']>;-};--export type SavedAnimationConfig = {- currentTime: AnimationConfig['currentTime'];- speed: AnimationConfig['speed'];-};--export type SavedVisState = {- filters: SavedFilter[];- layers: SavedLayer[];- interactionConfig: SavedInteractionConfig;- layerBlending: string;- splitMaps: SplitMap[];- animationConfig: SavedAnimationConfig;-};--export type SavedMapState = {- bearing: number;- dragRotate: boolean;- latitude: number;- longitude: number;- pitch: number;- zoom: number;- isSplit: boolean;-};--export type SavedLayerGroups = {- [key: string]: boolean;-};--export type SavedCustomMapStyle = {- [key: string]: {- accessToken: string;- custom: boolean;- icon: string;- id: string;- label: string;- url: string;- };-};--export type SavedMapStyle = {- styleType: string;- topLayerGroups: SavedLayerGroups;- visibleLayerGroups: SavedLayerGroups;- threeDBuildingColor: RGBColor;- mapStyles: SavedCustomMapStyle;-};--/** Schema for v1 saved configuration */-export type SavedConfigV1 = {- version: 'v1';- config: {- visState: SavedVisState;- mapState: SavedMapState;- mapStyle: SavedMapStyle;- };-};--/** Schema for a parsed configuration ("normalized" across versions) */-export type ParsedConfig = {- version: string;- visState?: {- layers?: ParsedLayer[];- filters?: ParsedFilter[];- interactionConfig?: Partial<SavedInteractionConfig>;- layerBlending?: string;- splitMaps?: SplitMap[];- animationConfig?: Partial<SavedAnimationConfig>;- };- mapState?: Partial<SavedMapState>;- mapStyle?: Partial<SavedMapStyle>;-};--export type SavedField = {- name: string;- type: string;- format?: string;- analyzerType?: string;-};--export type ParsedField = {- name: string;- type: string;- format: string;- analyzerType: string;-};--export type SavedDatasetV1 = {- version: 'v1';- data: {- id: string;- label: string;- color: RGBColor;- allData: any[][];- fields: SavedField[];- };-};--export type ParsedDataset = {- data: {- fields: ParsedField[];- rows: anu[][];- };- info: {- id?: string;- label?: string;- color?: RGBColor;- };-};--export type SavedMap = {- datasets: SavedDatasetV1[];- config: SavedConfigV1;- info: {- app: string;- created_at: string;- title: string;- description: string;- };-};--export type LoadedMap = {datasets?: ParsedDataset[] | null; config?: ParsedConfig | null};-export const reducerSchema: {- [key: string]: typeof mapStateSchema | typeof visStateSchema | typeof mapStyleSchema;-};--export class KeplerGLSchema {- constructor(prop: {- reducers?: typeof reducerSchema;- datasets?: typeof datasetSchema;- validVersions?: string[];- version?: string;- });- save(state: any): SavedMap;- load(arg1: SavedMap | SavedMap['datasets'] | any, arg1?: SavedMap['cnofig'] | any): LoadedMap;- getMapInfo(state: any): VisState['mapInfo'];- getDatasetToSave(state: any): SavedDatasetV1[];- getConfigToSave(state: any): SavedConfigV1;- parseSavedConfig(config: any): ParsedConfig | null;- parseSavedData(datasets: any): ParsedDataset[] | null;- validateVersion(version: any): string | null;- hasDataChanged(state: any): boolean;-}-const KeplerGLSchemaManager: KeplerGLSchema;--export default KeplerGLSchemaManager;diff --git a/src/schemas/schema-manager.js b/src/schemas/schema-manager.tssimilarity index 53%rename from src/schemas/schema-manager.jsrename to src/schemas/schema-manager.tsindex fccbd8abe..a3de7f5ad 100644--- a/src/schemas/schema-manager.js+++ b/src/schemas/schema-manager.ts@@ -28,19 +28,231 @@ import mapStateSchema from './map-state-schema';import {CURRENT_VERSION, VERSIONS} from './versions';import {isPlainObject} from 'utils/utils';-export const reducerSchema = {+import {+ InteractionConfig,+ Filter,+ TooltipInfo,+ SplitMap,+ AnimationConfig,+ VisState,+ RGBColor,+ Merge,+ RGBAColor+} from '../reducers';++import {LayerTextLabel} from '../layers/layer-factory';++export type SavedFilter = {+ dataId: Filter['dataId'];+ id: Filter['id'];+ name: Filter['name'];+ type: Filter['type'];+ value: Filter['value'];+ enlarged: Filter['enlarged'];+ plotType: Filter['plotType'];+ yAxis: {+ name: string;+ type: string;+ } | null;+ speed: Filter['speed'];+ layerId: Filter['layerId'];+};++export type ParsedFilter = Partial<SavedFilter>;++export type SavedInteractionConfig = {+ tooltip: TooltipInfo['config'] & {+ enabled: boolean;+ };+ geocoder: InteractionConfig['geocoder'] & {+ enabled: boolean;+ };+ brush: InteractionConfig['brush'] & {+ enabled: boolean;+ };+ coordinate: InteractionConfig['coordinate'] & {+ enabled: boolean;+ };+};++export type SavedScale = string;+export type SavedVisualChannels = {+ [key: string]: SavedField | SavedScale;+};++export type SavedLayer = {+ id: string;+ type: string;+ config: {+ dataId: string;+ label: string;+ color: RGBColor;+ highlightColor: RGBAColor;+ columns: {+ [key: string]: string;+ };+ isVisible: boolean;+ visConfig: object;+ hidden: boolean;+ textLabel: Merge<LayerTextLabel, {field: {name: string; type: string} | null}>;+ };+ visualChannels: SavedVisualChannels;+};++export type ParsedLayer = {+ id?: string;+ type?: string;+ config?: Partial<SavedLayer['config']>;+};++export type SavedAnimationConfig = {+ currentTime: AnimationConfig['currentTime'];+ speed: AnimationConfig['speed'];+};++export type SavedVisState = {+ filters: SavedFilter[];+ layers: SavedLayer[];+ interactionConfig: SavedInteractionConfig;+ layerBlending: string;+ splitMaps: SplitMap[];+ animationConfig: SavedAnimationConfig;+};++export type SavedMapState = {+ bearing: number;+ dragRotate: boolean;+ latitude: number;+ longitude: number;+ pitch: number;+ zoom: number;+ isSplit: boolean;+};++export type SavedLayerGroups = {+ [key: string]: boolean;+};++export type SavedCustomMapStyle = {+ [key: string]: {+ accessToken: string;+ custom: boolean;+ icon: string;+ id: string;+ label: string;+ url: string;+ };+};++export type SavedMapStyle = {+ styleType: string;+ topLayerGroups: SavedLayerGroups;+ visibleLayerGroups: SavedLayerGroups;+ threeDBuildingColor: RGBColor;+ mapStyles: SavedCustomMapStyle;+};++/** Schema for v1 saved configuration */+export type SavedConfigV1 = {+ version: 'v1';+ config: {+ visState: SavedVisState;+ mapState: SavedMapState;+ mapStyle: SavedMapStyle;+ };+};++/** Schema for a parsed configuration ("normalized" across versions) */+export type ParsedConfig = {+ version: string;+ visState?: {+ layers?: ParsedLayer[];+ filters?: ParsedFilter[];+ interactionConfig?: Partial<SavedInteractionConfig>;+ layerBlending?: string;+ splitMaps?: SplitMap[];+ animationConfig?: Partial<SavedAnimationConfig>;+ };+ mapState?: Partial<SavedMapState>;+ mapStyle?: Partial<SavedMapStyle>;+};++export type SavedField = {+ name: string;+ type: string;+ format?: string;+ analyzerType?: string;+};++export type ParsedField = {+ name: string;+ type: string;+ format: string;+ analyzerType: string;+};++export type SavedDatasetV1 = {+ version: 'v1';+ data: {+ id: string;+ label: string;+ color: RGBColor;+ allData: any[][];+ fields: SavedField[];+ };+};++export type ParsedDataset = {+ data: {+ fields: ParsedField[];+ rows: any[][];+ };+ info: {+ id?: string;+ label?: string;+ color?: RGBColor;+ };+};++export type SavedMap = {+ datasets: SavedDatasetV1[];+ config: SavedConfigV1;+ info: {+ app: string;+ created_at: string;+ title: string;+ description: string;+ };+};++export type LoadedMap = {datasets?: ParsedDataset[] | null; config?: ParsedConfig | null};++export const reducerSchema: {+ [key: string]: typeof mapStateSchema | typeof visStateSchema | typeof mapStyleSchema;+} = {visState: visStateSchema,mapState: mapStateSchema,mapStyle: mapStyleSchema};-/** @type {typeof import('./schema-manager').KeplerGLSchema} */export class KeplerGLSchema {+ _validVersions: typeof VERSIONS;+ _version: 'v1';+ _reducerSchemas: typeof reducerSchema;+ _datasetSchema: typeof datasetSchema;+ _datasetLastSaved: SavedDatasetV1[] | null;+ _savedDataset: SavedDatasetV1[] | null;+constructor({reducers = reducerSchema,datasets = datasetSchema,validVersions = VERSIONS,version = CURRENT_VERSION+ }: {+ reducers?: typeof reducerSchema;+ datasets?: typeof datasetSchema;+ validVersions?: typeof VERSIONS;+ version?: 'v1';} = {}) {this._validVersions = validVersions;this._version = version;@@ -77,7 +289,7 @@ export class KeplerGLSchema {* @param state* @returns app state to save*/- save(state) {+ save(state: any): SavedMap {return {datasets: this.getDatasetToSave(state),config: this.getConfigToSave(state),@@ -89,7 +301,7 @@ export class KeplerGLSchema {};}- getMapInfo(state) {+ getMapInfo(state: any): VisState['mapInfo'] {return state.visState.mapInfo;}/**@@ -97,7 +309,10 @@ export class KeplerGLSchema {* @param savedDatasets* @param savedConfig*/- load(savedDatasets, savedConfig) {+ load(+ savedDatasets: SavedMap | SavedMap['datasets'] | any,+ savedConfig: SavedMap['config'] | any+ ): LoadedMap {// if pass dataset and config in as a single objectif (arguments.length === 1 &&@@ -118,9 +333,10 @@ export class KeplerGLSchema {* @param state - app state* @returns - dataset to save*/- getDatasetToSave(state) {+ getDatasetToSave(state: any): SavedDatasetV1[] {const dataChangedSinceLastSave = this.hasDataChanged(state);if (!dataChangedSinceLastSave) {+ // @ts-expect-errorreturn this._savedDataset;}@@ -143,7 +359,7 @@ export class KeplerGLSchema {* @param {Object} state - app state* @returns {{version: String, config: Object}} - config to save*/- getConfigToSave(state) {+ getConfigToSave(state: any): SavedConfigV1 {const config = Object.keys(this._reducerSchemas).reduce((accu, key) => ({...accu,@@ -154,6 +370,7 @@ export class KeplerGLSchema {return {version: this._version,+ // @ts-expect-errorconfig};}@@ -163,7 +380,7 @@ export class KeplerGLSchema {* @param datasets* @returns - dataset to pass to addDataToMap*/- parseSavedData(datasets) {+ parseSavedData(datasets: any): ParsedDataset[] | null {return datasets.reduce((accu, ds) => {const validVersion = this.validateVersion(ds.version);if (!validVersion) {@@ -177,12 +394,13 @@ export class KeplerGLSchema {/*** Parse saved App config*/- parseSavedConfig({version, config}, state = {}) {+ parseSavedConfig({version, config}, state = {}): ParsedConfig | null {const validVersion = this.validateVersion(version);if (!validVersion) {return null;}+ // @ts-expect-errorreturn Object.keys(config).reduce((accu, key) => ({...accu,@@ -199,7 +417,7 @@ export class KeplerGLSchema {* @param version* @returns validVersion*/- validateVersion(version) {+ validateVersion(version: any): string | null {if (!version) {Console.error('There is no version number associated with this saved map');return null;@@ -218,7 +436,7 @@ export class KeplerGLSchema {* @param state* @returns - whether data has changed or not*/- hasDataChanged(state) {+ hasDataChanged(state: any): boolean {return this._datasetLastSaved !== state.visState.datasets;}}diff --git a/src/schemas/schema-utils.js b/src/schemas/schema-utils.tssimilarity index 100%rename from src/schemas/schema-utils.jsrename to src/schemas/schema-utils.tsdiff --git a/src/schemas/schema.d.ts b/src/schemas/schema.d.tsdeleted file mode 100644index 9341c89a4..000000000--- a/src/schemas/schema.d.ts+++ /dev/null@@ -1,47 +0,0 @@-// Copyright (c) 2020 Uber Technologies, Inc.-//-// Permission is hereby granted, free of charge, to any person obtaining a copy-// of this software and associated documentation files (the "Software"), to deal-// in the Software without restriction, including without limitation the rights-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell-// copies of the Software, and to permit persons to whom the Software is-// furnished to do so, subject to the following conditions:-//-// The above copyright notice and this permission notice shall be included in-// all copies or substantial portions of the Software.-//-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN-// THE SOFTWARE.--type Properties =- | {- [key: string]: null | Schema;- }- | string[]- | null;--export class Schema {- constructor(prop?: {version?: string; key?: string; properties?: Properties}): any;- version: string;- key: string;- properties: Properties;- load(node: any, parents?: string[], accumulator?: any): {[key: string]: any};- save(node: any, parents?: string[], accumulator?: any): {[key: string]: any};- savePropertiesOrApplySchema(- node: any,- parents?: string[],- accumulator?: any- ): {[key: string]: any};- loadPropertiesOrApplySchema(- node: any,- parents?: string[],- accumulator?: any- ): {[key: string]: any};-}--export default Schema;diff --git a/src/schemas/schema.js b/src/schemas/schema.tssimilarity index 71%rename from src/schemas/schema.jsrename to src/schemas/schema.tsindex 23828c89f..7c62549ad 100644--- a/src/schemas/schema.js+++ b/src/schemas/schema.ts@@ -22,23 +22,52 @@ import {console as Console} from 'global/window';import {CURRENT_VERSION} from './versions';-/** @type {typeof import('./schema').Schema} */export default class Schema {- constructor({version = CURRENT_VERSION, key = '', properties = null} = {}) {+ version: string;+ key: string;+ properties:+ | {+ [key: string]: null | Schema;+ }+ | string[]+ | null;++ constructor({+ version = CURRENT_VERSION,+ key = '',+ properties = null+ }: {+ version?: string;+ key?: string;+ properties?:+ | {+ [key: string]: null | Schema;+ }+ | string[]+ | null;+ } = {}) {this.version = version;this.properties = properties;this.key = key;}- loadPropertiesOrApplySchema(node, parents = [], accumulator) {+ loadPropertiesOrApplySchema(+ node: any,+ parents: string[] = [],+ accumulator?: any+ ): {[key: string]: any} {return this._getPropertyValueFromSchema('load', node, parents, accumulator);}- savePropertiesOrApplySchema(node, parents = [], accumulator) {+ savePropertiesOrApplySchema(+ node: any,+ parents: string[] = [],+ accumulator?: any+ ): {[key: string]: any} {return this._getPropertyValueFromSchema('save', node, parents, accumulator);}- _getPropertyValueFromSchema(operation, node, parents = [], accumulator) {+ _getPropertyValueFromSchema(operation, node: any, parents: string[] = [], accumulator) {const internal = `_${operation}`;return {[this.key]: this.properties@@ -46,10 +75,13 @@ export default class Schema {return {...accu,...(key in node- ? this.properties[key]+ ? // @ts-expect-error+ this.properties[key]? // if it's another schema+ // @ts-expect-errorthis.properties[key][operation]? // call save or load+ // @ts-expect-errorthis.properties[key][internal](node[key], [...parents, node], accu): {}: {[key]: node[key]}@@ -73,18 +105,20 @@ export default class Schema {_save(...args) {// make sure nothing is saved to an outdated versionthis.outdatedVersionError();+ // @ts-expect-errorreturn this.save(...args);}- save(node, parents = [], accumulator = {}) {+ save(node: any, parents: string[] = [], accumulator: any = {}): {[key: string]: any} {return this.savePropertiesOrApplySchema(node, parents, accumulator);}_load(...args) {+ // @ts-expect-errorreturn this.load(...args);}- load(node, parents = [], accumulator = {}) {+ load(node: any, parents: string[] = [], accumulator: any = {}): {[key: string]: any} {return this.loadPropertiesOrApplySchema(node, parents, accumulator);}}diff --git a/src/schemas/versions.d.ts b/src/schemas/versions.d.tsdeleted file mode 100644index 11dd65c01..000000000--- a/src/schemas/versions.d.ts+++ /dev/null@@ -1,23 +0,0 @@-// Copyright (c) 2020 Uber Technologies, Inc.-//-// Permission is hereby granted, free of charge, to any person obtaining a copy-// of this software and associated documentation files (the "Software"), to deal-// in the Software without restriction, including without limitation the rights-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell-// copies of the Software, and to permit persons to whom the Software is-// furnished to do so, subject to the following conditions:-//-// The above copyright notice and this permission notice shall be included in-// all copies or substantial portions of the Software.-//-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN-// THE SOFTWARE.--export const VERSIONS: {[key: string]: string};--export const CURRENT_VERSION: string;diff --git a/src/schemas/versions.js b/src/schemas/versions.tssimilarity index 100%rename from src/schemas/versions.jsrename to src/schemas/versions.tsdiff --git a/src/schemas/vis-state-schema.js b/src/schemas/vis-state-schema.tssimilarity index 98%rename from src/schemas/vis-state-schema.jsrename to src/schemas/vis-state-schema.tsindex db8396ba7..2af40f218 100644--- a/src/schemas/vis-state-schema.js+++ b/src/schemas/vis-state-schema.ts@@ -32,6 +32,13 @@ import {notNullorUndefined} from 'utils/data-utils';export const dimensionPropsV0 = ['name', 'type'];+export type modifiedType = {+ strokeColor?: any;+ strokeColorRange?: any;+ filled?: boolean;+ stroked?: boolean;+};+// in v0 geojson there is only sizeField// in v1 geojson@@ -366,7 +373,7 @@ class VisualChannelSchemaV1 extends Schema {}const visConfigModificationV1 = {point: (visConfig, parents, accumulated) => {- const modified = {};+ const modified: modifiedType = {};const [layer] = parents.slice(-2, -1);const isOld =!visConfig.hasOwnProperty('filled') && !visConfig.strokeColor && !visConfig.strokeColorRange;@@ -386,7 +393,7 @@ const visConfigModificationV1 = {},geojson: (visConfig, parents, accumulated) => {// is points?- const modified = {};+ const modified: modifiedType = {};const [layer] = parents.slice(-2, -1);const isOld =layer.visualChannels &&