RobLoach / node-raylib

Node.js bindings for Raylib
https://robloach.github.io/node-raylib/
Other
237 stars 20 forks source link

Automatically Build TypeScript Definitions from raylib_api.json #96

Open twuky opened 2 years ago

twuky commented 2 years ago

In another issue I tried manually putting together some typescript definitions (with doc strings) from the old typescript branch, with some updates where i could fit them. Obviously manually generating definitions may not be ideal.

But recently I found the repo for raylib itself keeps a JSON file with type information on its structs, functions and enums. I thought I would try to parse that into a typescript definitions file.

Included in this gist is a script I wrote to pull the JSON definitions from the raylib repo and generate a typescript def file out of them. There are a few things I am unsure of about this process for generating bindings though:

It seems like something like this could be used in the build/dist process, or to just create a @types/raylib repo seperately. This may be a better solution (at least at this moment) than relying on the binding library itself to generate definitions.

RobLoach commented 2 years ago

I'd love using that!