The Shocking Secret About Static Types
Eric Elliott
3.6K91

Totally agree that using types doesn’t mean you can ignore tests.

However, after trying typescript after dismissing it as an angular 2 or big project tool I feel that typescript improves the speed at which I can write code on a small project with fewer bugs for a few reasons:

  • I am much faster at documenting as I go leading to less confusion down the road on what props my react component wants or the arguments to a function are in which order. Code tools are not just nice to haves but these helpful hints reduce the need to jump around code to check function signatures and add to programming flow. Bugs of wrong or misspelled params are almost gone
  • In the same line, promises, chained observable and d3 data types are all much simpler to use the correct type which again leads to fewer iterations on getting tests right
  • Api calls can also share types so you ensure both client and server calls are using the same signatures
  • Apis of popular libraries have types defined leading to using them correctly without constantly having to check the docs.

Most of these bugs are just typo related but it’s one less cognitive load on my admittedly tiny monkey brain, leaving a little more space for fixing real bugs.

I for one am happy for having typescript even if just “spellcheck for programming ” and do feel it helps reduce those slap your forehead bugs among other great uses.

Like what you read? Give Alex Chan a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.