@@ -39,7 +39,7 @@ export async function fetchGeoJson(mapId: string): Promise<object> {
3939 // If it's TopoJSON, convert to GeoJSON
4040 if ( 'objects' in data ) {
4141 console . debug ( `[GeoJSON] Converting TopoJSON to GeoJSON for ${ mapId } ` ) ;
42- return convertTopoJsonToGeoJson ( data as topojson . Topology ) ;
42+ return convertTopoJsonToGeoJson ( data as unknown ) ;
4343 }
4444
4545 return data ;
@@ -83,20 +83,25 @@ async function tryFetchMap(mapId: string, ext: string): Promise<unknown> {
8383 }
8484}
8585
86- function convertTopoJsonToGeoJson (
87- topoData : topojson . Topology
88- ) : Record < string , unknown > {
86+ function convertTopoJsonToGeoJson ( topoData : unknown ) : object {
8987 try {
88+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89+ const topo = topoData as any ;
90+ if ( ! topo . objects ) {
91+ throw new Error ( 'Invalid TopoJSON: missing objects property' ) ;
92+ }
93+
9094 // Get the first object from the topology (usually 'features' or a similar key)
91- const objectKey = Object . keys ( topoData . objects ) [ 0 ] ;
95+ const objectKey = Object . keys ( topo . objects ) [ 0 ] ;
9296 if ( ! objectKey ) {
9397 throw new Error ( 'TopoJSON has no objects' ) ;
9498 }
9599
96100 // Convert the topology object to GeoJSON FeatureCollection
97- const geoJson = topojson . feature ( topoData , topoData . objects [ objectKey ] ) ;
101+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102+ const geoJson = topojson . feature ( topo , topo . objects [ objectKey ] ) as any ;
98103 console . debug ( `[GeoJSON] Converted TopoJSON with key "${ objectKey } "` ) ;
99- return geoJson ;
104+ return geoJson as object ;
100105 } catch ( error ) {
101106 console . error ( `[GeoJSON] TopoJSON conversion failed:` , error ) ;
102107 throw new Error ( `Failed to convert TopoJSON: ${ error } ` ) ;
0 commit comments