Skip to content

Comment on Ask HN: Is it worth it to invest in learning TypeScript?

Comments

The payoff is reduced cognitive load. Essentially you’re offloading a bunch of it to the type system at the cost of type annotations. A simple example:

    const add = (a, b) => a+b
can do quite a few surprising things depending on the types of a and b.

Whereas how this will behave:

    const add = (a: number, b: number) => a+b
is far easier to keep in your head. Multiply that effect by 100k lines and the TypeScript program becomes a lot more fun to build on because you get to spend less time thinking about edge cases.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.