Typescript prevents you from prototyping



I tend to prototype things in JavaScript, then re-write them in TypeScript for production. A guy on Reddit

or

Flow is better than Typescript because it doesn't prevent you from prototyping. Without @flow annotation there is no compile errors. A guy at a conference

I hear this quite often, and I can’t agree on that.

First of all, javascript is emitted despite compile errors. That is default behaviour unless you have explicitly told the compiler to --noEmitOnError .

Secondly, Typescript is never a complication for me. Actually, I start prototyping by defining objects’ shapes, messages’ types, constants and adding libraries’ type definitions. And that gives me control over the things I’m doing.

Typescript is not just a transpiler (even though it can be used just for modern-to-old transformation). There are a lot more things included. It’s a type checker and, what’s the most important, great toolbox and IDE.

While prototyping entities often change its meaning, so I have to rename them or move to a more suitable place. These operations are safe as long as you provide type information to the compiler. Names and types are being automatically imported while you type it. Enum’s and object’s properties are auto-completed. And it works the way you expect it. As a Javascript developer, I never was so confident about my code, and especially about refactorings’ safety. I can go to bed without being afraid to forget everything by next morning.

Once you have that experience, there is no way back.