HACKER Q&A
📣 speedylight

Does TypeScript live up to the hype?


I’ve only ever used vanilla JavaScript ever since I got into WebDev and while it can annoying to work with at times, it’s really well rounded overall in my opinion especially the current version of ECMAScript. Combined with svelte it’s absolutely delightful.

Then I started hearing more about Typescript on Twitter and such and I got really curious because everyone had at least one good thing to say about it - mainly the data types aspect of it. Which is the only benefit that I can really wrap my head around.


  👤 marpstar Accepted Answer ✓
After using TypeScript professionally for almost 8 years now, using plain JS for anything but the most trivial of solutions feels downright dangerous.

👤 Leftium
I actually used to prefer CoffeeScript over JS because it allowed me to code more quickly and keep my code smaller.

Then I saw a video of Rich Harris demonstrating the Svelte tools in VS code. The TS typing enabled autocomplete and even automatically importing files. That's what got me to try TypeScript. Perhaps TS could be faster than CoffeeScript, now.

(By now, ECMAScript has borrowed most of the good ideas from CoffeeScript, and other devs are more likely to be familiar with JS/TS vs CoffeeScript.)

Some times TS helps catch simple mistakes, but other times I feel like I am "fighting" with the TS type errors. Overall, I think it is worth using TS.


👤 mejutoco
IMO Typescript deserves all the hype. Some programmers take pride in having to remember everything and being careful while holding the whole program in memory. I am not one of them. I want the computer to help me as much as possible to remove basic errors, basic tests, and reduce cognitive load, so I can focus on the important bits.

You can try this short guides with interactive exercises to learn about the type annotations. In 15 minutes you can get really familiar with it.

https://type-level-typescript.com/types-and-values

After that, Typescript documentation should fill any other gaps.

https://www.typescriptlang.org/docs/


👤 phendrenad2
It's a hard question to answer. TypeScript catches a certain class of bug, but requires a lot of extra work creating types and essentially over-specifying things. Personally I don't think it's worth it.

👤 matthewwolfe
Absolutely worth the hype, doubly so if your backend is also written in typescript and you can share types. I would say except for very specific cases, you don’t need the complicated parts of typescript, and what you are left with is a lot of defining interfaces/records of what object are. This takes minimal effort to write but pays dividends when you can hover a variable and see the exact type, or the compiler complains about some unintentionally null or undefined value you didn’t consider.

👤 tomjen3
Yes.

Typed languages such as C/C++ were annoying because the type system was too simple, but Typescript is much more powerful and it infers most things automatically. Plus you have structural types, so you can start converting one part of your project over at a time.

In general I don't see any reason to use Javascript without Typescript anymore, except if you are in an environment where you can't compile it for some reason.


👤 solardev
You can learn TypeScript really gradually, adding it to important things like parameters and props at first, for the simplest primitive types, then gradually expand complexity to include objects and inheritance and generics and such later.

It's really useful for providing good code hints and autocomplete, and for avoiding runtime crash bugs due to uncoerced types.

Give it a shot, a little at a time.


👤 gardenhedge
Yes, it lives to the hype. One good example, it is used by Prisma: https://www.prisma.io/typescript

I have seen types and type unions get pretty complicated though


👤 bjourne
Dynamic typing is too difficult for some developers. If you are one of them then TypeScript is for you.

👤 drakonka
I went from working mostly with Go and C# to JS last year and TypeScript has been amazing.

👤 aprdm
Where would people suggest to go to learn typescript ?