Remix.run Logo
sheept 13 hours ago

One of the strengths of TypeScript besides its expressiveness is that it's compatible with the massive npm ecosystem. Most packages only ship untyped JavaScript with type declarations defining the interface,[0] so realistically you'd still need a JavaScript engine if you use any packages.

But if you're starting from scratch and know you won't be using any npm packages, you might as well use AssemblyScript.[2]

[0]: Publishing packages in TypeScript is explicitly discouraged by Node[1]. TypeScript isn't backwards compatible even in minor releases, and its compiler settings aren't portable for packages.

[1]: https://github.com/nodejs/node/blob/main/doc/api/typescript....

[2]: https://www.assemblyscript.org/

simonw 12 hours ago | parent | next [-]

> so realistically you'd still need a JavaScript engine if you use any packages.

Looks like Scriptc's solution to that problem is that it can optionally bundle a 620KB quickjs-ng JavaScript engine if you have dependencies that need to be executed that way.

skybrian 7 hours ago | parent | prev | next [-]

I would use it for a focused command-line tool that needs to share code with a larger TypeScript project, not for code with a lot of dependencies.

bbor 12 hours ago | parent | prev [-]

Those are good reasons to publish untyped libraries as a rule, sure. But the contention that those reasons outweigh the value of types kinda boggles the mind, ngl!

sroussey 11 hours ago | parent [-]

Publishing a lib as JS with .d.ts type files gives you JS compatibility and TS types for using the lib, but no TS source so no types inside.

I’ve seen people want to publish TS libs but there are issues: TS will type check the libs as well as your project. You can’t tell it to stop just because it’s going inside node modules. And the app may have tighter settings than the library and you will get type errors if your configs were setup differently. It would be interesting to standardize publishing real typescript libs but I haven’t seen it. Maybe deno tried? I haven’t looked.

skybrian 7 hours ago | parent [-]

When publishing on jsr.io, you upload the TypeScript, and if using Deno, you also download TypeScript (with import statements rewritten.) Having nearly the original source code is better for debugging.

Deno doesn’t type-check external dependencies unless you ask.

daveidol 6 hours ago | parent [-]

It’s too bad we didn’t start out with Deno