News for hackers. Stuff that matters.
Re:JSR first impressions: a JavaScript package manager by th... by spankalee on Saturday February 17, 2024 @07:48PM (#39414996)
Publishing and importing TypeScript is a huge mistake.

Packages should just compile TypeScript to JS and publish that as they do now.

Re:JSR first impressions: a JavaScript package manager by th... by paulgb on Saturday February 17, 2024 @07:58PM (#39415061)
Why? I’m not primarily a JS/TS dev, but when I’m dealing with the JS ecosystem, operating across two languages is one of the pain points (e.g. clicking a function in my editor and getting the typedef instead of the code). Now that runtimes like Deno and Bun support TS natively, why shouldn’t we avoid that completely?
Re:JSR first impressions: a JavaScript package manager by th... by usrusr on Sunday February 18, 2024 @04:21AM (#39417538)
Perspective from another not primarily js/ts dev: in this context, js is the equivalent of a .jar full of .class files. Instead of a -sources.jar you'd have a sourcemap. The original typescript would be more like a repository dump, and chances are the build depends heavily on an exotic fork of python or something equally unexpected.
Re:JSR first impressions: a JavaScript package manager by th... by paulgb on Sunday February 18, 2024 @04:51AM (#39417687)
I get the analogy, but I don’t see what this actually solves in the JS/TS case.

The jvm can’t run Java source files directly and needs a build step, so to the extent that the build step is not portable, it makes sense to ship the built version. Jars are also used for dynamic imports where doing the build at runtime would be expensive.

By comparison, runtimes like Deno can run TS directly now. There is no separate build step required. After all, it’s a scripting language! The fact that it has a compile step at all is just baggage at this point.

Re:JSR first impressions: a JavaScript package manager by th... by usrusr on Sunday February 18, 2024 @08:47PM (#39425424)
Can run one specific version of TS, and JS that has been compiled from any version of TS.

That ability might be very valuable for the development loop, but it cannot be intended for dependencies because source compatibility is very low in the priorities list of TS.

In JVM words: where scala seems to have given up on cross-version compatibility of the complied code, forcing cross building upon library authors and dependency registries but succeeds in sufficient source compatibility to enable that cross building, TS, due to being bound to baseline JS as output anyways, does the inverse. The output works across versions (how could it not, when it's meant to work across languages), but with that a given it can take its liberties with input (source) compatibility.

Re:JSR first impressions: a JavaScript package manager by th... by postalrat on Saturday February 17, 2024 @10:05PM (#39415782)
Publish just js or js and types?
Re:JSR first impressions: a JavaScript package manager by th... by DinoCoder99 on Sunday February 18, 2024 @12:24AM (#39416458)
Why? To whose benefit?
Re:JSR first impressions: a JavaScript package manager by th... by golergka on Sunday February 18, 2024 @02:09AM (#39416887)
Do you enjoy having to search for the TS source of the stacktrace that ends up in some third-party library compiled TS? Because I don't.
Re:JSR first impressions: a JavaScript package manager by th... by baq on Sunday February 18, 2024 @03:04AM (#39417141)
Yeah, no. JS should be banned for new packages. Only TS or WASM should be allowed.

The mistake was to allow multiple half-assed implementations of JS modules in the ecosystem.