Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Does TypeScript live up to the hype?
12 points by speedylight on Dec 20, 2022 | hide | past | favorite | 24 comments
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.

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

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.

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.


After that, Typescript documentation should fill any other gaps.


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.

but requires a lot of extra work

That's not my experience at all. I've found that you get most of the benefits via type inference with very little additional work. Although if you try to be super strict and forbid any use of "any" or casting, then that could get annoying and possibly counterproductive.

Unless you are integrating typescript into an existing codebase, having the strictest feature set is great. I’ve never felt the need to use any/unknown, except for very occasionally when working with a library that has spotty typescript support.

Yeah, almost everyone forbids "any". It's the default in most linter configs too.

> Although if you try to be super strict and forbid any use of "any" or casting,

Why would you ever want to use any if you could avoid it? It completely undermines the benefits of TS. Most of the time you really want unknown or generics.

After maintaining a slowly rotting JavaScript codebase developed by a few developers, I converted it to typescript and maintaining it was easier. I found some typing problems challenging and fun. I think it’s worth it if you enjoy types.

Well that's the thing, I don't want to choose tools based on my personal preferences, I want them to work and get the job done. No "enjoying" for me.

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.


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.

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.

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

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

It's error prone and frankly silly when there is a superior option. It's more difficult because it's bad, not because it requires higher skill levels or is more complex and powerful. Why would you use something more difficult yet less effective? Using JS is foolish when you have TS.

Dynamic typing is "difficult" in the same way that a microwave is "difficult" to someone only used to fireplaces. Some never get used to it, but that doesn't mean that microwaves are "bad".

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

Where would people suggest to go to learn typescript ?

Don't go anywhere, read a book, do it properly :).


These days, I always start with the free official docs. They are usually pretty good.

I hope so, most times I'm really not sure if it's worth it, or read intro and then just reference.

Depends on your MO but doing stuff trumps reading. And doing stuff interlaced with a bit of learning between is unbeatable.

Typescript docs are fantastic.

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