-
Notifications
You must be signed in to change notification settings - Fork 78
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
TypeScript regression #63
Comments
Thanks for the bug report. We probably need to add a check in Travis CI to catch this kind of issue. |
Will this be addressed in any upcoming releases? Would love to have type enforcement when using this library in TypeScript (I'm stuck on Thanks! |
Yes, I'd like to fix it in the next release. I'm not as familiar with TS as I ought to be - is there a standard type-checking step we could do in CI that would catch this? |
Nothing off-the-shelf AFAIK, but it's simple enough to add a script in "scripts": {
// ...
"type-check": "tsc dist/types.d.ts"
// ...
} I'm guessing you do an WorkMac:h3-js sanj$ tsc dist/types.d.ts
dist/types.d.ts:80:75 - error TS2314: Generic type 'Array<T>' requires 1 type argument(s).
80 function h3ToGeoBoundary(h3Index: H3Index, formatAsGeoJson: boolean): Array[];
~~~~~
dist/types.d.ts:137:36 - error TS2314: Generic type 'Array<T>' requires 1 type argument(s).
137 function polyfill(coordinates: Array[], res: number, isGeoJson: boolean): H3Index[];
~~~~~
dist/types.d.ts:149:83 - error TS2314: Generic type 'Array<T>' requires 1 type argument(s).
149 function h3SetToMultiPolygon(h3Indexes: H3Index[], formatAsGeoJson: boolean): Array[];
~~~~~
dist/types.d.ts:228:93 - error TS2314: Generic type 'Array<T>' requires 1 type argument(s).
228 function getH3UnidirectionalEdgeBoundary(edgeIndex: H3Index, formatAsGeoJson: boolean): Array[];
~~~~~
Found 4 errors. |
Thanks, this is perfect. |
#55 added auto-generated TypeScript types, but it seems like some of the functions (e.g.
h3ToGeoBoundary
) that return an array of arrays (i.e.Array[]
) don't type-check properly in TypeScript, since the compiler expects the outerArray
to have a type parameter:h3-js/lib/h3core.js
Line 566 in c5f653f
The fix is likely to specify the inner-most type explicitly (e.g.
Number[][]
) in the JSDoc.The text was updated successfully, but these errors were encountered: