mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
refactor(client): type both trip map renderers against one MapViewProps contract
MapViewAuto took props: any and the Leaflet MapView destructured any, so a prop one renderer learned and the other never heard of went unnoticed. components/Map/mapViewContract.ts holds MapViewProps, derived from the GL renderer's props and what the callers pass; MapView and the GL bindings in glLazy declare satisfies ComponentType against it, and the GL renderer extends it with its engine. The file imports types only, so check:gl-split is not affected. Types only, no runtime change. The types show two known gaps, recorded in the contract rather than papered over: onMapReady is called by the GL renderer only, and callers pass pins without trip_id (assignment and collection places) while both renderers type their pins as Place; MapViewAuto bridges the latter with one commented cast.
This commit is contained in:
@@ -209,6 +209,7 @@ vi.mock('./gcj02Crs', () => ({
|
||||
}))
|
||||
|
||||
import { MapView } from './MapView'
|
||||
import type { RouteVia } from '../../types'
|
||||
|
||||
// Helper: build a place with the extra fields MapView uses (category_name/color/icon)
|
||||
// that exist on joined DB rows but are not in the base Place TypeScript type.
|
||||
@@ -1025,7 +1026,9 @@ describe('MapView explore POIs', () => {
|
||||
})
|
||||
|
||||
describe('MapView plugin route vias', () => {
|
||||
const via = (overrides: Record<string, any> = {}) => ({ lat: 48.5, lng: 2.5, tone: 'default', ...overrides })
|
||||
// Cast, not typed: one case hands in a tone outside RouteVia's union on purpose.
|
||||
const via = (overrides: Partial<Record<keyof RouteVia, unknown>> = {}) =>
|
||||
({ lat: 48.5, lng: 2.5, tone: 'default', ...overrides }) as RouteVia
|
||||
|
||||
it('FE-COMP-MAPVIEW-037: draws a tone dot for each via point', () => {
|
||||
render(<MapView routeVias={[via({ tone: 'success' }), via({ tone: 'danger', lat: 48.7 })]} />)
|
||||
|
||||
Reference in New Issue
Block a user