News for hackers. Stuff that matters.
Re:First look: adding type annotations to JavaScript by sanitycheck on Thursday March 10, 2022 @10:28AM (#30627960)
I've got (too many) years of JS experience too, and I started a project in TS last November to see what the fuss is all about.

I have to say I'm a convert. Not so much because it's catching a ton of errors for me, more that it brings such a massive improvement in IDE autocomplete behaviour. TypeScript in VS Code starts to feel almost like C# in 'real' visual studio. (The errors it does catch in my code are usually potential null references which would probably have been fine, but I'm sure it's avoided a few bugs.)

The most interesting thing for me is that it allows me to feel safe doing things I would avoid in plain JS, like using literal union types (which would be magic numbers/strings without the typing).

I still write JS for small stuff, but when you're next starting a new project that'll go over a few thousand lines of code I definitely recommend giving it a try.

Re:First look: adding type annotations to JavaScript by claytongulick on Thursday March 10, 2022 @11:36AM (#30628849)
Have you tried type annotations in jsdoc?

Inline /* @type */ statements and jsdoc type declarations coupled with .d.ts files for complex types achieves the same thing for me without the extra compilation step.

Re:First look: adding type annotations to JavaScript by LAC-Tech on Thursday March 10, 2022 @02:24PM (#30631262)
Yeah that's what I do as well. I actually find TS uglier now. It ends up being full of really long lines like:

    const myFunction(a: Long<TypeName>, b: Another<LongType>): FooBar