Skip to content

Commit dc134fa

Browse files
fix: resolve TypeScript build errors in map layer expression constants
Add explicit ExpressionSpecification type annotations to MapLibre expression arrays in GccWatchLayer and MilitaryBasesLayer. Removing `as const` from the arrays caused them to be inferred as `(string | string[])[]` which is incompatible with MapLibre's mutable tuple type. Annotating with `ExpressionSpecification` satisfies the type checker and produces a clean production build. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 48c9d31 commit dc134fa

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

client/src/modules/monitor/components/GccWatchLayer.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useMemo } from 'react';
22
import { Source, Layer } from 'react-map-gl/maplibre';
3+
import type { ExpressionSpecification } from 'maplibre-gl';
34
import {
45
GCC_COUNTRIES,
56
useGccCountryAlerts,
@@ -40,7 +41,7 @@ const REGION_CENTROIDS: Record<string, [number, number]> = {
4041
'al-wusta': [56.82, 21.53],
4142
};
4243

43-
const FILL_COLOR = [
44+
const FILL_COLOR: ExpressionSpecification = [
4445
'case',
4546
['==', ['get', 'alertSeverity'], 'warning'],
4647
'rgba(239, 68, 68, 0.18)',
@@ -49,9 +50,9 @@ const FILL_COLOR = [
4950
['==', ['get', 'alertSeverity'], 'advisory'],
5051
'rgba(234, 179, 8, 0.12)',
5152
'rgba(96, 165, 250, 0.06)',
52-
] as const;
53+
];
5354

54-
const OUTLINE_COLOR = [
55+
const OUTLINE_COLOR: ExpressionSpecification = [
5556
'case',
5657
['==', ['get', 'alertSeverity'], 'warning'],
5758
'rgba(239, 68, 68, 0.75)',
@@ -60,25 +61,25 @@ const OUTLINE_COLOR = [
6061
['==', ['get', 'alertSeverity'], 'advisory'],
6162
'rgba(234, 179, 8, 0.60)',
6263
'rgba(148, 163, 184, 0.20)',
63-
] as const;
64+
];
6465

65-
const HALO_COLOR = [
66+
const HALO_COLOR: ExpressionSpecification = [
6667
'case',
6768
['==', ['get', 'alertSeverity'], 'warning'],
6869
'rgba(239, 68, 68, 0.14)',
6970
['==', ['get', 'alertSeverity'], 'watch'],
7071
'rgba(251, 146, 60, 0.12)',
7172
'rgba(234, 179, 8, 0.10)',
72-
] as const;
73+
];
7374

74-
const DOT_COLOR = [
75+
const DOT_COLOR: ExpressionSpecification = [
7576
'case',
7677
['==', ['get', 'alertSeverity'], 'warning'],
7778
'rgba(239, 68, 68, 0.92)',
7879
['==', ['get', 'alertSeverity'], 'watch'],
7980
'rgba(251, 146, 60, 0.92)',
8081
'rgba(234, 179, 8, 0.90)',
81-
] as const;
82+
];
8283

8384
function CountryLayer({ country }: { country: GccCountry }) {
8485
const { data: alerts } = useGccCountryAlerts(country);

client/src/modules/monitor/components/MilitaryBasesLayer.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { useMemo } from 'react';
22
import { Source, Layer } from 'react-map-gl/maplibre';
3+
import type { ExpressionSpecification } from 'maplibre-gl';
34
import { useMilitaryBases } from '../hooks/useMilitaryBases';
45
import { useMilitaryBasesStore } from '../militaryBases.store';
56

67
export const MILITARY_BASES_LAYER_IDS = ['military-bases-halo', 'military-bases-dot'];
78

89
// MapLibre expression — color by category
9-
const CATEGORY_COLOR = [
10+
const CATEGORY_COLOR: ExpressionSpecification = [
1011
'match',
1112
['get', 'category'],
1213
'air',
@@ -16,9 +17,9 @@ const CATEGORY_COLOR = [
1617
'ground',
1718
'#4ade80', // green-400
1819
'#fbbf24', // amber-400 (hq / default)
19-
] as const;
20+
];
2021

21-
const CATEGORY_HALO = [
22+
const CATEGORY_HALO: ExpressionSpecification = [
2223
'match',
2324
['get', 'category'],
2425
'air',
@@ -28,7 +29,7 @@ const CATEGORY_HALO = [
2829
'ground',
2930
'rgba(74, 222, 128, 0.15)',
3031
'rgba(251, 191, 36, 0.15)',
31-
] as const;
32+
];
3233

3334
/**
3435
* Renders global military installations on the map,

0 commit comments

Comments
 (0)