Skip to content

Commit 05af840

Browse files
committed
Replace map with object types
1 parent 205031b commit 05af840

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

popgetter-browser/web/src/lib/rust_worker.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class RustBackend {
4343
return result;
4444
}
4545

46-
async search(search_params: Map<any, any>, offset: number): Promise<String> {
46+
async search(search_params: {}, offset: number): Promise<String> {
4747
if (!this.inner) {
4848
throw new Error("RustBackend not initialised");
4949
}
@@ -52,15 +52,15 @@ export class RustBackend {
5252
return result;
5353
}
5454

55-
async downloadMetrics(params: Map<any, any>): Promise<String> {
55+
async downloadMetrics(params: {}): Promise<String> {
5656
if (!this.inner) {
5757
throw new Error("RustBackend not initialised");
5858
}
5959
const result = JSON.parse(await this.inner!.downloadMetrics(params));
6060
// console.log("RustBackend.getCountries result", result);
6161
return result;
6262
}
63-
async downloadGeoms(params: Map<any, any>): Promise<String> {
63+
async downloadGeoms(params: {}): Promise<String> {
6464
if (!this.inner) {
6565
throw new Error("RustBackend not initialised");
6666
}
@@ -69,7 +69,7 @@ export class RustBackend {
6969
return result;
7070
}
7171
async downloadDataRequestMetrics(
72-
data_request_spec: Map<any, any>,
72+
data_request_spec: {},
7373
): Promise<String> {
7474
if (!this.inner) {
7575
throw new Error("RustBackend not initialised");
@@ -80,7 +80,7 @@ export class RustBackend {
8080
return result;
8181
}
8282
async downloadDataRequestMetricsSql(
83-
data_request_spec: Map<any, any>,
83+
data_request_spec: {},
8484
): Promise<String> {
8585
if (!this.inner) {
8686
throw new Error("RustBackend not initialised");
@@ -90,7 +90,7 @@ export class RustBackend {
9090
return result;
9191
}
9292
async downloadDataRequestGeoms(
93-
data_request_spec: Map<any, any>,
93+
data_request_spec: {},
9494
): Promise<String> {
9595
if (!this.inner) {
9696
throw new Error("RustBackend not initialised");
@@ -102,7 +102,7 @@ export class RustBackend {
102102
return result;
103103
}
104104
async downloadDataRequestGeomsPmtiles(
105-
data_request_spec: Map<any, any>,
105+
data_request_spec: {},
106106
): Promise<String> {
107107
if (!this.inner) {
108108
throw new Error("RustBackend not initialised");
@@ -113,7 +113,7 @@ export class RustBackend {
113113
return result;
114114
}
115115

116-
async downloadDataRequest(data_request_spec: Map<any, any>): Promise<String> {
116+
async downloadDataRequest(data_request_spec: {}): Promise<String> {
117117
if (!this.inner) {
118118
throw new Error("RustBackend not initialised");
119119
}

popgetter-browser/web/src/routes/DownloadMode.svelte

+7-8
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
}
9494
});
9595
96-
async function setPreviewedMetrics(): Promise<Array<Map<any, any>>> {
96+
async function setPreviewedMetrics(): Promise<Array<{}>> {
9797
const metricsDownload = $selectedMetricsList.map((record) => ({
9898
MetricId: {
9999
id: record.metric_id,
@@ -126,7 +126,7 @@
126126
}
127127
128128
// TODO: consider if can be async to enable preview to be generated here
129-
function add(record: Map<any, any>) {
129+
function add(record: {}) {
130130
console.log(record);
131131
$selectedMetricsList.indexOf(record) === -1
132132
? $selectedMetricsList.push(record)
@@ -137,7 +137,7 @@
137137
}
138138
139139
// TODO: consider if previewed metrics can be updated here too
140-
export function remove(record: Map<any, any>) {
140+
export function remove(record: {}) {
141141
console.log(record);
142142
const index = $selectedMetricsList.indexOf(record);
143143
if (index > -1) {
@@ -148,7 +148,7 @@
148148
return;
149149
}
150150
151-
async function search(x, offset): Promise<Array<Map<any, any>>> {
151+
async function search(x, offset): Promise<Array<{}>> {
152152
try {
153153
const loaded = await $rustBackend!.isLoaded();
154154
if (!loaded) {
@@ -173,8 +173,7 @@
173173
];
174174
}
175175
176-
// async function download(dataRequestSpec): Promise<Array<Map<any, any>>> {
177-
async function download(dataRequestSpec): Promise<any> {
176+
async function download(dataRequestSpec: {}): Promise<Array<{}>> {
178177
const loaded = await $rustBackend!.isLoaded();
179178
if (!loaded) {
180179
await $rustBackend!.initialise();
@@ -198,8 +197,8 @@
198197
let searchParams = {};
199198
200199
// For search results
201-
let data: Array<Map<any, any>> = [];
202-
let items: Array<Map<any, any>> = [];
200+
let data: Array<{}> = [];
201+
let items: Array<{}> = [];
203202
204203
// For downloaded geojson
205204
let gj: FeatureCollection = {

popgetter-browser/web/src/routes/PreviewedMetrics.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import * as d3 from "d3-scale";
2020
import { interpolateViridis } from "d3-scale-chromatic";
2121
22-
function setPreviewMetricMap(item: Map<any, any>) {
22+
function setPreviewMetricMap(item: {}) {
2323
console.log("Set preview metric map: ", item);
2424
previewMetricMap.set(item);
2525
// console.log($previewMetricMap)

popgetter-browser/web/src/routes/SelectedMetrics.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
TableHeadCell,
1111
} from "flowbite-svelte";
1212
13-
function remove(record: Map<any, any>) {
13+
function remove(record: {}) {
1414
console.log(record);
1515
const index = $selectedMetricsList.indexOf(record);
1616
if (index > -1) {

popgetter-browser/web/src/routes/globals.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ export const rustIsLoaded = writable(false);
2525
export type Mode = { kind: "title" } | { kind: "level" } | { kind: "download" };
2626

2727
export const mode: Writable<Mode> = writable({ kind: "title" });
28-
export const countries: Writable<Array<any>> = writable([]);
28+
export const countries: Writable<Array<{}>> = writable([]);
2929
export const selectedCountry: Writable<String> = writable("");
3030
export const selectedLevel: Writable<String> = writable("");
31-
export const selectedMetricsList: Writable<Array<Map<any, any>>> = writable([]);
32-
export const previewedMetricsList: Writable<Array<Map<any, any>>> = writable(
31+
export const selectedMetricsList: Writable<Array<{}>> = writable([]);
32+
export const previewedMetricsList: Writable<Array<{}>> = writable(
3333
[],
3434
);
3535
// Metric metadata to preview on map
36-
export const previewMetricMap: Writable<Map<any, any>> = writable({});
36+
export const previewMetricMap: Writable<{}> = writable({});
3737
// Colours for previewMetricMap
38-
export const previewMetricMapColors: Writable<Array<String>> = writable([]);
38+
export const previewMetricMapColors: Writable<Array<{}>> = writable([]);
3939
export const tileUrl = writable("pmtiles://https://popgetter.blob.core.windows.net/dev/v0.2/usa/geometries/tract_2019.pmtiles");

0 commit comments

Comments
 (0)