"export 'FlatCompassDirection' was not found in 'honeycomb-grid'
guillaume-alvarez opened this issue · 8 comments
Hi,
I'm using this (very useful) library with typescript and webpack and run into this warning
"export 'FlatCompassDirection' was not found in 'honeycomb-grid'
for this code
import { Hex, Point, FlatCompassDirection } from 'honeycomb-grid';
...
const neighbors = grid.neighborsOf(hex, [
FlatCompassDirection.SE, FlatCompassDirection.S, FlatCompassDirection.SW,
FlatCompassDirection.NW, FlatCompassDirection.N, FlatCompassDirection.NE,
]);
It results in this error at runtime:
TypeError: honeycomb_grid__WEBPACK_IMPORTED_MODULE_14__.FlatCompassDirection is undefined
It looks a lot like this webpack issue, that seem to indicate you can fix the issue by changing the way it is declared.
Many answers on stackoverflow seem to imply it could also work by declaring the enum as 'const' in the types declaration file.
Would this solve your issue:
import type { Hex, Point, FlatCompassDirection } from 'honeycomb-grid';
Source: webpack/webpack#7378 (comment)
Not, because the issue here is that the value is not imported. :-(
that seem to indicate you can fix the issue by changing the way it is declared
Can you point me to an example of that? And can you also supply an example of:
Many answers on stackoverflow seem to imply it could also work by declaring the enum as 'const' in the types declaration file
Ok, could you test if this solves your issue (by replacing the existing enum in your local honeycomb.d.ts with this):
export const enum FlatCompassDirection {
SE = 'SE',
S = 'S',
SW = 'SW',
NW = 'NW',
N = 'N',
NE = 'NE',
}
Sure I can (I did not think you could touch theses files).
It solves the issue!
You can change those files, but they'll be overridden when you run npm install
(and there's a change in the file).
Anyway, great! I'll publish a new version later today.
Fixed in 3.1.7
Please let me know if you have any more questions.