My TypeScript workflow
TypeScript can slow the development down if not used properly. You may ask how? It can do it by making you think about the compilation errors when you have just started coding a project.
While building something the most important thing is quickly applying the ideas that you have in your mind to see a working prototype. If you go and start fixing those compilation errors it's a huge mental burden and it takes you in a different direction where you are just fixing those errors.
How I use TypeScript to push me faster in the right direction
- Don't use TypeScript everywhere. If you feel it is a decently complex codebase, then use it.
- Remember that with TypeScript's
checkJs
and allowJs
options, JS files can have Type Safety using JSDoc which can be added on a need basis.
- I use TypeScript in strict mode. I want it to be the harshest critique of my code.
- I think of TypeScript as automation tests with a super bonus of IDE auto-completion and documentation generation.
- If a test is failing while I am building something, I would like to be aware of it but not immediately work on fixing it. The same is with TypeScript.
- It doesn't mean that I would only fix those TypeScript compilation errors only after the entire project is done. NO. It defeats the purpose of using TypeScript.
- Identify small milestones and then fix those compilation errors. e.g. a function(say addComment) has been written and its implementation is done. At this moment, I would make it fully TypeScript compliant, so that whenever I have to make a change in it in future(very near, near or far), my TypeScript tests are there to save me.