mirror of
https://github.com/maputnik/editor.git
synced 2026-06-14 19:27:25 +00:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user