Hacker News new | past | comments | ask | show | jobs | submit login

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.




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.


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




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: