Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Enhancement] Typescript improvement (#1254)

Shan He2ebd136888c4
diff --git a/src/actions/actions.d.ts b/src/actions/actions.d.ts
index ccc1df519..dd640f921 100644
--- a/src/actions/actions.d.ts
+++ b/src/actions/actions.d.ts
@@ -56,7 +56,11 @@ export type AddDataToMapOptions = {
};
export type AddDataToMapPayload = {
- datasets: ProtoDataset[];
+ // TODO/ib - internally the code calls `toArray` a couple of layers deep
+ // so this function can actually accept both an array and an object
+ // recommend dropping such "sloppy typing" and enforcing array type
+ // as the field is called `datasets`
+ datasets: ProtoDataset[] | ProtoDataset;
options?: AddDataToMapOptions;
config?: ParsedConfig;
info?: Partial<MapInfo>
diff --git a/src/actions/vis-state-actions.d.ts b/src/actions/vis-state-actions.d.ts
index 0431ff048..5eee259dc 100644
--- a/src/actions/vis-state-actions.d.ts
+++ b/src/actions/vis-state-actions.d.ts
@@ -316,11 +316,11 @@ export function setMapInfo(
): Merge<SetMapInfoUpdaterAction, {type: ActionTypes.SET_MAP_INFO}>;
export type LoadFilesUpdaterAction = {
- files: FileList;
+ files: File[];
onFinish?(result: any): any;
};
export function loadFiles(
- files: FileList,
+ files: File[],
onFinish?: (result: any) => any
): Merge<LoadFilesUpdaterAction, {type: ActionTypes.LOAD_FILES}>;
diff --git a/src/processors/file-handler.d.ts b/src/processors/file-handler.d.ts
index a95e99c55..9acf3db2e 100644
--- a/src/processors/file-handler.d.ts
+++ b/src/processors/file-handler.d.ts
@@ -41,3 +41,5 @@ export function processFileData(payload: {
}): Promise<FileCacheItem[]>;
export function filesToDataPayload(fileCache: FileCacheItem[]): AddDataToMapPayload[];
+
+export function readBatch(asyncIterator, fileName): AsyncIterable<any>;
diff --git a/src/reducers/index.d.ts b/src/reducers/index.d.ts
index 732971afc..dcef113b1 100644
--- a/src/reducers/index.d.ts
+++ b/src/reducers/index.d.ts
@@ -23,13 +23,13 @@
// export {default as keplerGlReducer} from './root';
// Core Reducer
-// export {
-// default as keplerGlReducerCore,
-// visStateLens,
-// mapStateLens,
-// uiStateLens,
-// mapStyleLens
-// } from './core';
+export {
+ default as keplerGlReducerCore,
+ visStateLens,
+ mapStateLens,
+ uiStateLens,
+ mapStyleLens
+} from './core';
// Each individual reducer
// export {default as visStateReducer} from './vis-state';
diff --git a/src/reducers/vis-state-merger.d.ts b/src/reducers/vis-state-merger.d.ts
index e7cddb7c7..b0eb3da9c 100644
--- a/src/reducers/vis-state-merger.d.ts
+++ b/src/reducers/vis-state-merger.d.ts
@@ -32,6 +32,9 @@ export type Merger = {
toMergeProp?: string
};
+export function validateSavedVisualChannels(fields, newLayer, savedLayer);
+export function validateLayerWithData({fields, id: dataId}, savedLayer, layerClasses);
+
export type VisStateMergers = Merger[];
export const VIS_STATE_MERGERS: VisStateMergers;
diff --git a/src/schemas/schema-manager.d.ts b/src/schemas/schema-manager.d.ts
index cb7eeec70..90aaa1a68 100644
--- a/src/schemas/schema-manager.d.ts
+++ b/src/schemas/schema-manager.d.ts
@@ -123,6 +123,7 @@ export type SavedMapStyle = {
mapStyles: SavedCustomMapStyle;
};
+/** Schema for v1 saved configuration */
export type SavedConfigV1 = {
version: 'v1';
config: {
@@ -132,7 +133,9 @@ export type SavedConfigV1 = {
};
};
+/** Schema for a parsed configuration ("normalized" across versions) */
export type ParsedConfig = {
+ version: string;
visState?: {
layers?: ParsedLayer[];
filters?: ParsedFilter[];