placemark/togeojson

gpx() and kml() types aren't symmetric

jaybo opened this issue · 2 comments

jaybo commented

gpx

gpx(node: Document): FeatureCollection<Geometry, GeoJsonProperties>

kml

kml(node: Document): FeatureCollection<Geometry | null, GeoJsonProperties>  // note the null

Which means I need to write 2 more lines of code. Trivial, YES! (But it did break my build).

tmcw commented

These types are correct. KML features can lack geometries but have data. Features with null geometries are valid in KML and GeoJSON, but not something that GPX can contain.

tmcw commented

Closing - this is a bit annoying, but there's no way for the two have the same type signatures - you can expand the type for gpx to that of kml if you need a single function handle both.