News for hackers. Stuff that matters.
Re:First look: adding type annotations to JavaScript by danielvaughn on Thursday March 10, 2022 @11:22AM (#30628663)
I'm on the fence about this one. On the one hand I would love strong typing in JS.

But the reason I never adopted TS is because one time I spent months converting Coffeescript back into JS once it fell out of favor. This was back when a bunch of Ruby developers decided that JS should look like Ruby.

If I'm writing Javascript, I'm writing Javascript, not something that pretends to be something else.

Re:First look: adding type annotations to JavaScript by vosper on Thursday March 10, 2022 @11:53AM (#30629099)
You can convert TS to JS at the drop of a hat. This is part of what’s required to get it to run a browser, which doesn’t understand native TS. It’s different to Coffeescript which was different syntax for JS. TS is additional, type-specific syntax but you are still writing JS.

I ran a team that had to maintain a large Coffee codebase, that we could never get the resources to move off. So I know that pain. TS is different, both in how it works and the level of adoption. Coffeescript was always niche, and some benefits were there but they weren’t game-changing for (eg) writing correct code or maintaining large codebases.

Re:First look: adding type annotations to JavaScript by recursive on Thursday March 10, 2022 @11:53AM (#30629094)
You can generally migrate out of TS very easily if it was the wrong choice. You can mostly use the compiler output as a drop-in replacement for your source code. Depending on compiler options, it's quite readable.
Re:First look: adding type annotations to JavaScript by neurotrace on Thursday March 10, 2022 @12:02PM (#30629230)
One of the benefits of TypeScript is that it literally is just JavaScript plus some. You can literally run `tsc` and it will spit out JavaScript written the same way as you wrote it but without any of the types. The only things that might look out of place is things like enums or decorators but you can choose not to use them.
Re:First look: adding type annotations to JavaScript by Bilal_io on Thursday March 10, 2022 @11:38AM (#30628864)
The good news is that you can take your time with it, only start using typescript in new files while converting older ones slowly. And even if you never do that, typescript tooling provides hints and autocompletion to vanilla J's files as well.