-
Notifications
You must be signed in to change notification settings - Fork 978
Typescript #1145
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 #1145
Conversation
Utter fanboy ignorance. You will destroy the ease you can test PR's with right now with nothing but ESM and an importmap, hence overcomplicating everything through a chain of useless intermediary tools like TSC and putting the entire project at the mercy of "I hope the build chain works with my setup". I've tested so many TS projects over time and if they are written in TS, it's highly likely the build process broke somewhere. Just fix the JSDoc types, if there are some issues. Also, we had this discussion several times... |
As stated above, there is no reason to rewrite this in TypeScript, because this library already has type safety through JSDoc. Your time would be better spent improving the current documentation comments to improve the type safety. |
To clarify, I never meant to offend with my comments. I just didn't want you to spend anymore time translating anything else into TypeScript when there is already a type system in place. Without digging into the code myself, I'm not 100% sure why the IDE doesn't work properly for Processors - I am sure there are comments. The work you did here is fantastic, and your comments are thorough and in-depth; I am confident in saying that your pull requests will be greatly appreciated again in future. |
Thank you! I really do appreciate that. To be clear it wasn't your comment that I was referencing. I'll do some more digging and see if there isn't a solution for JSDoc, and will submit a PR if I find anything :) |
Hi @xenova and team,
First off, I want to say how much I’ve been enjoying Transformers.js! I’ve been using it for a couple of months now, and it’s truly an incredible library. Thank you for all the work you’ve put into it!
That said, I’ve encountered some challenges related to types, auto-complete, and error handling while working with the library. To help address these and improve the overall developer experience, I’d love to embark on a bigger project: rewriting Transformers.js in TypeScript.
The benefits of this rewrite would be substantial—it would make the library even more robust while greatly enhancing DX. It also presents a great opportunity to revisit some core code, tackle any outstanding TODOs, and adopt modern JavaScript patterns, such as using typed objects instead of maps/dicts where appropriate.
To get things rolling, I’ve started with a few files in the utils directory, but I’d like to submit my work on RawImage
image.ts
first to ensure the approach aligns with everyone’s expectations before proceeding further.Additionally, I’ve implemented consistent error handling using try/catch. Errors will still throw as before but will now pass through console.error to log them first. This addresses a gap where some existing error statements weren’t getting logged, leading to crashes without feedback.
Importantly, the goal of this TypeScript rewrite is not to break anything. We’re maintaining the existing methods and inputs unless absolutely necessary, so nothing currently in production should be affected.
Thanks, and looking forward to making this library even better!