MartinP460 / react-denmark-map

Customizable plug-and-play map of Denmark for visual presentation🗺️
https://react-denmark-map.vercel.app/
MIT License
21 stars 4 forks source link

[V2] Provide explicit type values for the fields in the different area types #14

Closed MartinP460 closed 10 months ago

MartinP460 commented 10 months ago

Description

It would be nice if the area objects in each of the maps were to include explicit values of all the fields. For example, the type of a region in the Region map should be:

type RegionType = {
  id: "syddanmark" | "sjaelland" // ...
  display_name: "Syddanmark" | "Hovedstaden" // ...
  // ...
}

instead of just a string for each of the properties. This would improve intellisense and mean that some equality checks would not throw a type error due to unknown properties.

Proposed solution

Casting the array of area data to const (using as const after the definition of the array) and using a generic to construct the correct type.