Migrate all the non react components code to typescript (#847)

This completes the migration to typescript of all the non react
components code.
The only changes introduced besides types are the type checks using
`"something" in object` which narrows down types in typescript.
This commit is contained in:
Harel M
2023-12-21 00:07:53 +02:00
committed by GitHub
parent e8d07fa694
commit 3bf0e510e6
15 changed files with 149 additions and 96 deletions
+27
View File
@@ -0,0 +1,27 @@
import type {StyleSpecification, SourceSpecification} from "@maplibre/maplibre-gl-style-spec";
export function deleteSource(mapStyle: StyleSpecification, sourceId: string) {
const remainingSources = { ...mapStyle.sources}
delete remainingSources[sourceId]
return {
...mapStyle,
sources: remainingSources
}
}
export function addSource(mapStyle: StyleSpecification, sourceId: string, source: SourceSpecification) {
return changeSource(mapStyle, sourceId, source)
}
export function changeSource(mapStyle: StyleSpecification, sourceId: string, source: SourceSpecification) {
const changedSources = {
...mapStyle.sources,
[sourceId]: source
}
return {
...mapStyle,
sources: changedSources
}
}