Skip to content

Commit 20079aa

Browse files
Cleanup types
1 parent 23d3aab commit 20079aa

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

src/layers/layerDefinitions.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import BaseLayer from "ol/layer/Base";
2-
import { TileCoord } from "ol/tilecoord";
3-
import { pickRandom } from "../utils/random";
41
import RenderEvent from "ol/render/Event";
2+
import { type TileCoord } from "ol/tilecoord";
3+
import { pickRandom } from "../utils/random";
54

65
export interface BaseLayerDefinition {
76
name: string;
@@ -61,7 +60,7 @@ export const layerDefinitions: TileLayerDefinition[] = [
6160
description: "Terrain relief overlay",
6261
type: 'overlay',
6362
defaultVisible: true,
64-
prerender: e => e.context.canvas.getContext('2d').globalCompositeOperation = 'multiply',
63+
prerender: e => e.context!.canvas.getContext('2d')!.globalCompositeOperation = 'multiply',
6564
minZoom: 10,
6665
url: 'https://tiles-cdn.koordinates.com/services;key=d0772bed2204423f87157f7fb1223389/tiles/v4/layer=50765/EPSG:3857/{z}/{x}/{y}.png'
6766
}

src/layers/mountains.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default {
4545
const data = await this.getData();
4646
const points = Object.values(data).filter(a => a.latlng);
4747
return points.map(mountain => {
48-
const coords = fromLonLat([mountain.latlng[1], mountain.latlng[0]]);
48+
const coords = fromLonLat([mountain.latlng![1], mountain.latlng![0]]);
4949
const feature = new Feature(new Point(coords));
5050
feature.setId(mountain.link)
5151
return feature;
@@ -59,7 +59,7 @@ export default {
5959

6060
fragment.update(value => ({
6161
...value,
62-
page: `mountains/${encodeURIComponent(originalFeature.getId())}`
62+
page: `mountains/${encodeURIComponent(originalFeature.getId()!)}`
6363
}))
6464

6565
}

src/search/places.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const getPlaces = () => {
2222
huts.getData,
2323
() => mountains.getData()
2424
.then(r => Object.entries(r)
25-
.filter(([,m]) => m.latlng?.length && m.name)
26-
.map(([url, m]) => ({ name: m.name, lat: m.latlng[0], lon: m.latlng[1], type: 'peak', href: url }))),
25+
.filter(([, m]) => m.latlng?.length && m.name)
26+
.map(([url, m]) => ({ name: m.name, lat: m.latlng![0], lon: m.latlng![1], type: 'peak', href: url }))),
2727
() => fetch(placesUrl).then(r => r.json() as Promise<Place[]>),
2828
])
2929
}

src/stores/mountains.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { writable } from "svelte/store";
2-
import type MountainsJson from '../../public/data/mountains.json'
32

4-
export type Mountain = typeof MountainsJson[keyof typeof MountainsJson] & { routes: Route[] };
3+
export type Mountain = {
4+
link: string;
5+
name: string,
6+
altitude: string,
7+
description: string | null,
8+
latlng?: [number, number],
9+
routes: Route[],
10+
places: Mountain[],
11+
image: string | null,
12+
images: string[]
13+
}
514
export type Mountains = {
615
[href: string]: Mountain
716
}

0 commit comments

Comments
 (0)