transformers.js
transformers.js copied to clipboard
Typescript Support
Hi,
I love this library and I use it a lot, thank you for the effort. Is there a plan to add types to this package? I t could help us understand how to use and configure the different pipelines. Is there other documentation? Since the HuggingFace one is more general and less specific about this lib.
Hi! Yes, we do plan to add typescript support!
The library is extremely new, and I agree that the documentation needs some work! 😬 In general, we are trying to keep the usage very similar to the python library.
Anyway, both things are on the TODO list!
Best way to add types is adding JSDoc first... then use the TypeScript compiler to generate a transformers.d.ts declaration file.
I happen to work a bit with types and e.g. PlayCanvas is using JSDoc like this:
https://github.com/playcanvas/engine/blob/main/src/framework/entity.js
You can check the build script aswell (first and last line): https://github.com/playcanvas/engine/blob/537c43d7a92eb78c954dbd49ea3837c32193e29e/package.json#L118-L128
I wouldn't actually use TypeScript, but for the declaration file generation it's good.
I would also remove WebPack, only using <script type="module"> for modern ES6 directly in the browser using import instead of require.
Thanks for the resources and suggestions! I'm trying to get to everything on the TODO list haha. If you have time and want to contribute, you can always make a PR and I'll be happy to review + merge it!