Closed frnsys closed 12 months ago
I ran into the same issue. It looks to me as if the types declaration is wrong - it claims that Quadtree is a named export, whereas it is actually the default export. I managed to hack around this by editing node_modules/@timohausmann/quadtree-ts/types/index.esm.d.ts
to properly reflect this
i.e., replace the first two lines with:
import { Quadtree } from './Quadtree';
export default Quadtree;
Thanks for the info, I will try to find the time to test and fix this. This entire umd/cjs/esm bundling is so weird.
Hey there. I recently migrated my project to Typescript and noticed the same issue. Any luck on finding the root cause?
You need to change "browser": "dist/quadtree.umd.full.js", to "browser": "dist/quadtree.esm.js" in the package.json of this lib.
The idea is to use named exports only. I could recreate the issue with Webpack 5.
I found this "export" property for webpack and added it to package.json: https://webpack.js.org/guides/package-exports/#providing-different-versions-depending-on-target-environment
I tested again and it seems to work now.
npm install -S @timohausmann/quadtree-ts@latest
Please let me know if the issue persists.
The latest version is able to work!
@yar2001 awesome, thanks for your feedback!
Hi,
I'm still having issue mentionned above:
MapGen.tsx:83 Uncaught TypeError: (0 , _quadtreeTs.Quadtree) is not a constructor
I'm using version @timohausmann/quadtree-ts@2.2.2
with parcel builder.
Any idea?
Note that if I use default import as someone suggested before, it seems to fix my issue..
import Quadtree from "@timohausmann/quadtree-ts";
Thank you for this library. I'm having a strange issue where the imports are undefined after I import them.
I'm just doing:
and the TypeScript compiler is fine with it. However, when I actually load the page I get the following error:
and
Quadtree
is undefined.If I import the default export:
Quadtree
is no longer undefined and looks like the correctQuadtree
class. However TypeScript then complains and won't compile since I guess the type definition doesn't declare it as a class.