haxiomic / dts2hx

Converts TypeScript definition files (d.ts) to haxe externs (.hx) via the TypeScript compiler API
MIT License
131 stars 8 forks source link

Type not found : global.XRFrameRequestCallback #128

Closed ConfidantCommunications closed 6 months ago

ConfidantCommunications commented 6 months ago

When I attempt a build on the "three" example, I get:

/Users/alland/Documents/haXe/dts2hx/examples/three/.haxelib/three/0,160,0/three/WebGLRenderer.hx:149: characters 42-71 : Type not found : global.XRFrameRequestCallback

If I comment out that line then compile I get Type not found : global.XRPlane. Note: This is after upgrading three to the 0.160.0 version.

So I'm guessing I need to generate externs for those global items and possibly others. Sorry for the noob question but how should I do that? I attempted npx dts2hx three --global but that didn't fix it. The error just changed to "Type not found : XRFrameRequestCallback".

FlashTang commented 6 months ago

Seems this is a bug ? I just fixed by delete the global. For me , add --globalPackageName "" fixed the issue

ConfidantCommunications commented 6 months ago

It seems that anything in the Three "internal" classes got excluded and I had to manually create those externs. There were a half dozen or so.

ConfidantCommunications commented 6 months ago

So I modified the package.json file like so: "postinstall": "dts2hx --modular three three/examples/jsm/controls/OrbitControls --globalPackageName \"\" "

After I deleted the package-lock.json and did npm install, it installed fine. However when I attempted to build (haxe build.xml) I got the error: dist/main.js:64:70: error: Could not resolve "three/examples/jsm/controls/OrbitControls"

I had to edit the file at /dts2hx/examples/three/node_modules/three/package.json in the exports section after line 14: "./examples/jsm/controls/OrbitControls": "./examples/jsm/controls/OrbitControls.js",

Finally the build worked and I could run the index.html file!