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.
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:
can do quite a few surprising things depending on the types of a and b.Whereas how this will behave:
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.