News for hackers. Stuff that matters.
Re:From TypeScript to ReScript by capableweb on Wednesday January 12, 2022 @06:24AM (#29904925)
> It's easy to just strip the TS metadata and you're left with working JS.

Compared to what? JSDoc made it even easier, you didn't even need to strip anything, as the "types" were just comments. This comes with its own problems, who want to program with comments? But it didn't require any changes to use for us who want nothing to do with TS.

Re:From TypeScript to ReScript by moonchrome on Wednesday January 12, 2022 @08:19AM (#29905962)
What are the changes for people who don't want to use TS when they consume TS from JS ? The packages are shipped as JS with additional definitions.

The stripping part is just a fallback option if you decide to move away from TS, you never actually use that in practice.

Re:From TypeScript to ReScript by verve_rat on Wednesday January 12, 2022 @07:15AM (#29905318)
If you don't want to use Typescript... then don't?
Re:From TypeScript to ReScript by capableweb on Wednesday January 12, 2022 @08:19AM (#29905966)
Yeah, duh. The argument is that there is a group of people who wants types and write libraries. Before they used JSDoc, which is effortless to use from JS, as it's just actually vanilla JS. Some of those started using TypeScript now for everything, including libraries. If I want to use those libraries, I need to fork the project and rewrite them to vanilla JS, something that was not needed before. Or find a different library/write it myself.
Re:From TypeScript to ReScript by elevader on Wednesday January 12, 2022 @08:28AM (#29906050)
You actually don't, that's the nice part. NPM Typescript modules are shipped as transpiled js modules with d.ts files. Those d.ts files contain the type informations for consuming TS projects but they are completely optional and you can simply ignore them if you write a plain js project.

You can see this in the babel project, for example. It is written in typescript but used by a lot of js projects that don't care (and don't have to care) about this.

Re:From TypeScript to ReScript by smt88 on Wednesday January 12, 2022 @08:33AM (#29906090)
It sounds like you either don't use npm and are trying to use libraries' source files or you don't actually have this issue. This doesn't and can't happen with npm.
Re:From TypeScript to ReScript by mynegation on Wednesday January 12, 2022 @08:37AM (#29906117)
> If I want to use those libraries, I need to fork the project and rewrite them to vanilla JS

Why? If you want to just use, npm packages give you “compiled” vanilla JS and type definition files that you can ignore. Alternatively you can compile them yourself, if you vendor them in.

Re:From TypeScript to ReScript by datagram on Wednesday January 12, 2022 @01:05PM (#29910565)
> who want to program with comments?

TypeScript supports providing types via JSDoc comments[1]. This gets you use all the IDE language features you'd get using TS, including highlighting type errors. I actually use this all the time, since I have plenty of scripts that are complex enough that I want type checking but not complex enough to warrant a compilation step.

There's also Google's Closure Compiler[2], which uses JSDoc for its JS type annotations.

[1]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported...

[2]: https://developers.google.com/closure/compiler

Re:From TypeScript to ReScript by Aldo_MX on Wednesday January 12, 2022 @08:32AM (#29906081)
Comments have the potential to get forgotten and become incorrect. Type annotations not.
Re:From TypeScript to ReScript by cxr on Wednesday January 12, 2022 @12:45PM (#29910212)
Corollary: we should invest in systems that allow us to mechanically verify correctness of comments as readily as type checkers do with type specifiers.
Re:From TypeScript to ReScript by ponyous on Wednesday January 12, 2022 @10:11AM (#29907391)
> Good luck doing that with a new language.

Compared to a new language...