Cleanup imports, improve typing

This commit is contained in:
Pieter Vander Vennet 2024-05-16 00:26:28 +02:00
parent d4085d608b
commit 3204a76fc9
2 changed files with 4 additions and 7 deletions

View file

@ -4,7 +4,6 @@
import type { Feature } from "geojson"
import type { SpecialVisualizationState } from "../../SpecialVisualization"
import TagRenderingAnswer from "./TagRenderingAnswer.svelte"
import { PencilAltIcon } from "@rgossiaux/svelte-heroicons/solid"
import TagRenderingQuestion from "./TagRenderingQuestion.svelte"
import { onDestroy } from "svelte"
import Tr from "../../Base/Tr.svelte"
@ -12,9 +11,7 @@
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
import { Utils } from "../../../Utils"
import { twMerge } from "tailwind-merge"
import { ariaLabel } from "../../../Utils/ariaLabel"
import EditButton from "./EditButton.svelte"
import EditItemButton from "../../Studio/EditItemButton.svelte"
export let config: TagRenderingConfig
export let tags: UIEventSource<Record<string, string>>

View file

@ -1035,7 +1035,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
}
}
const promise =
/*NO AWAIT as we work with the promise directly */ Utils.downloadJsonAdvanced(
/*NO AWAIT as we work with the promise directly */ Utils.downloadJsonAdvanced<T>(
url,
headers
)
@ -1069,11 +1069,11 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
})
}
public static async downloadJsonAdvanced(
public static async downloadJsonAdvanced<T = object | []>(
url: string,
headers?: Record<string, string>
): Promise<
{ content: object | object[] } | { error: string; url: string; statuscode?: number }
{ content: T } | { error: string; url: string; statuscode?: number }
> {
const injected = Utils.injectedDownloads[url]
if (injected !== undefined) {
@ -1091,7 +1091,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
try {
if (typeof data === "string") {
if (data === "") {
return { content: {} }
return { content: <T> {} }
}
return { content: JSON.parse(data) }
}