Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broken build for node #8

Closed
jfgodoy opened this issue Jul 1, 2021 · 2 comments · Fixed by #9
Closed

broken build for node #8

jfgodoy opened this issue Jul 1, 2021 · 2 comments · Fixed by #9

Comments

@jfgodoy
Copy link

jfgodoy commented Jul 1, 2021

Hi @tmcw, I got here after deprecation of @mapbox/geojsonhint, so thank you for creating this replacement.

I tried this very basic example in node, but it throws invalid_type.

const {check} = require('@placemarkio/check-geojson');

const examplePoint = {
  type: 'Point',
  coordinates: [0, 1],
};

check(JSON.stringify(examplePoint));

The example works perfectly fine in your tests, so I tracked the problem and found that the typescript build generates an invalid code.

look at this:

in file dist/type.d.ts

import { GeoJSON } from 'geojson';
export declare type GeoJSONTypeSet = Set<GeoJSON['type']>;
export declare const GEOJSON_FEATURE_TYPE: Set<"Point" | "MultiPoint" | "LineString" | "MultiLineString" | "Polygon" | "MultiPolygon" | "GeometryCollection" | "Feature" | "FeatureCollection">;
export declare const GEOJSON_GEOMETRY_TYPES: Set<"Point" | "MultiPoint" | "LineString" | "MultiLineString" | "Polygon" | "MultiPolygon" | "GeometryCollection" | "Feature" | "FeatureCollection">;
export declare const GEOJSON_GEOMETRY_TYPES_EX_GEOMETRY_COLLECTION: Set<"Point" | "MultiPoint" | "LineString" | "MultiLineString" | "Polygon" | "MultiPolygon" | "GeometryCollection" | "Feature" | "FeatureCollection">;
export declare const GEOJSON_TYPES: Set<"Point" | "MultiPoint" | "LineString" | "MultiLineString" | "Polygon" | "MultiPolygon" | "GeometryCollection" | "Feature" | "FeatureCollection">;

in file dist/check-geojson.cjs.development.js

var GEOJSON_FEATURE_TYPE = /*#__PURE__*/new Set(['Feature']);
var GEOJSON_GEOMETRY_TYPES = /*#__PURE__*/new Set(['Point', 'MultiPoint', 'Polygon', 'MultiPolygon', 'LineString', 'MultiLineString', 'GeometryCollection']);
var GEOJSON_GEOMETRY_TYPES_EX_GEOMETRY_COLLECTION = /*#__PURE__*/new Set(['Point', 'MultiPoint', 'Polygon', 'MultiPolygon', 'LineString', 'MultiLineString']);
var GEOJSON_TYPES = /*#__PURE__*/new Set( /*#__PURE__*/[].concat(GEOJSON_GEOMETRY_TYPES, ['Feature', 'FeatureCollection']));

The variable GEOJSON_TYPES concats a Set and an Array, which causes the variable to not hold the expected values.

> console.log(GEOJSON_TYPES)
Set(3) {
  Set(7) {
    'Point',
    'MultiPoint',
    'Polygon',
    'MultiPolygon',
    'LineString',
    'MultiLineString',
    'GeometryCollection'
  },
  'Feature',
  'FeatureCollection'
}

I only know basic stuff in typescript, so I don't know if this is a config problem

@tmcw
Copy link
Contributor

tmcw commented Jul 2, 2021

Odd! Thanks, I'll look into it.

@tmcw
Copy link
Contributor

tmcw commented Jul 2, 2021

Okay! This is a oft-reported issue in tsdx's Babel configuration. They have a recommended workaround, compiling for node, which also removes all fo the annoying Babel transform stuff.

@tmcw tmcw mentioned this issue Jul 2, 2021
@tmcw tmcw closed this as completed in #9 Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants