-
Notifications
You must be signed in to change notification settings - Fork 563
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 declarations? #233
Comments
Interesting idea! I think we could best do this by modifying the webidl binder in emscripten, so that as it generates all the glue C++ and JS (from the webidl file) it can also emit a TypeScript file on the side. The tool is here if someone wants to try (let me know if you have questions): https://github.com/emscripten-core/emscripten/blob/incoming/tools/webidl_binder.py |
This may be of interest: https://github.com/charto/nbind |
I've written a preliminary Node program which attempts to scrape the Bullet docs online and generate Ammo.js type declarations. It still has issues, but anecdotally it appears to get 60%-80% correct so far. |
Question: how are namespaces represented in the JS version? It seemed like, from the WebIDL docs, you can just replace |
I ended up finding that I should just strip the namespaces altogether. In its current state, this set of types more or less correctly types the terrain example script. The exceptions are |
@kripken is there any progress or plans on this? I would love to see a .d.ts coming straight from the ammo.js repository. |
There is some work in emscripten on typescript declaration support, which may eventually be relevant here, but nothing yet (emscripten-core/emscripten#7083 (comment)). |
We would definitely appreciate contributions in that area! |
thx. I've been working on a I had to make some adjustments to the idl to make it work. All steps are described in the readme. I am planning a more thorough integration check and a couple examples, maybe hosted on https://stackblitz.com However the embind approach seems to be more reasonable. I'd have a look into it too. |
so i have an example on stackblitz out now |
That's a cool idea @giniedp! That would make more sense for ammo actually, since we don't use embind. Might be worth opening an issue on emscripten as other people might be interested in this too. I'd definitely like to see something like this in emscripten myself, sounds very useful! |
Finally had some time and made progress. Here is a tool that you can use to generate declarations for emscripten modules (or browser libs if you wish) The https://github.com/giniedp/ammojs-typed project is upgraded so it uses that tool. Basically all work that |
ammojs-typed |
It would be awesome to have TypeScript declarations available. I don't know if these would have to be created manually or if they could somehow be scraped from the C++ ones, but I'd think the latter could be done at least as a starting point.
The text was updated successfully, but these errors were encountered: