transformers.js icon indicating copy to clipboard operation
transformers.js copied to clipboard

[Question] TypeScript rewrite

Open Lantianyou opened this issue 1 year ago • 11 comments

Hi Joshua. I found your idea is extremely exciting. I am a frontend developer who has worked on TypeScript professionally for three years. Would you mind me doing a TypeScript re-write, so this npm package can have a better DX. If I successfully transform the codebase into TypeScript and pass all the tests, would you mind merging it into main?

I just forked this repo. https://github.com/Lantianyou/transformers.js

Lantianyou avatar Aug 28 '23 08:08 Lantianyou

ts isn't the best DX, and I've been using it for 13 years, also js intellisense is always improving in IDE's

quantuminformation avatar Aug 28 '23 09:08 quantuminformation

I do not think TS is always the best solution either, however, it would be nice to have it for this project. For example, this project use BigInt, it assumes ES 2020 or later. I think TypeScript transpiler can be a great use case here.

Lantianyou avatar Aug 28 '23 10:08 Lantianyou

TS will die if js ever gets types, its at proposal stage atm

quantuminformation avatar Aug 28 '23 10:08 quantuminformation

I do not think TS is always the best solution either, however, it would be nice to have it for this project.

No, it would be as ugly as it gets, it just makes everything 200 times more complicated while not actually improving anything (actually decreasing the readability) and prevents everyone from quickly testing and making PR's because you have to fumble with a build process in different scenarious, even though you just want to test a few lines of new code.

kungfooman avatar Aug 28 '23 10:08 kungfooman

yup, why do you think I dumped ts for my flagship patterns:

https://github.com/quantuminformation/vanillajs-patterns

quantuminformation avatar Aug 28 '23 10:08 quantuminformation

I believe type proposal for ES is in a very far future.

Lantianyou avatar Aug 28 '23 10:08 Lantianyou

I give my 👍 to the rewrite this in typescript proposal. While I agree that TS config can be bit annoying - not to say a pain the a** - I do think that a simple setup is possible that works for most people checking out this repo (at least if you are not using something abstruse like Nix). I think the benefits ( type-safety, better editor auto-completion, using the language that most modern web libraries are written in, ...) far outweigh the config hiccups.

sigma-andex avatar Aug 28 '23 19:08 sigma-andex

Thank you @sigma-andex for your support.

Lantianyou avatar Aug 29 '23 00:08 Lantianyou

I think the benefits ( type-safety, better editor auto-completion, using the language that most modern web libraries are written in, ...) far outweigh the config hiccups.

You are just exposing that you don't know how current technology works. JSDoc and TypeScript use the same language server for IntelliSense.

You gain nothing but have a PITA now. you are sold

The amount of TypeScript fanboys that are convinced how much better TS is while not knowing anything about the underlying technology is really getting worrisome...

kungfooman avatar Aug 29 '23 08:08 kungfooman

TypeScript is great if you like low signal/noise ratios

quantuminformation avatar Aug 29 '23 09:08 quantuminformation

Hello - Don't think TS will die even with new JS proposal as TS does much more the proposal solves (and yes, it could be very painfull, but it's basically just about devs skills).

But rewriting the code is not a good idea as it's possible to create and maintain .d.ts file, if devs want to use types (for example @types/tramsformerjs).

I'm not sure if it makes for this library though...

marek-hanzal avatar Apr 27 '24 12:04 marek-hanzal