Imagine you are writing a code that packs you a bag to go for hiking or walking tour. Code has to gather different things in the bag for hiking. let’s say:

– sneakers
– jacket against wind
– some knife, probably
– raincoat
– torch
and a long list of other things…
bag for hiking

Now the thing is – JavaScript is loosely typed, so it can not distinguish very well things, so to say, in the moment of writing code. So it is easy to make some mistake or tiny typo and for example, the code can pack instead of raincoat a bag for garbage…

Without enough testing of all corner cases, you can make a dozen tests for your code and everything will be fine. You can test:
walking on the sunny weather
gather some flowers
walk in the night with a torch

Also, it is not very easy to cover all the corner cases and all the environments(at least for me), or you can simply don’t have enough time, or sometimes there can be some really “niche” cases, like going on the beach after rain where sneakers will not be a very good choice.

In all the tests you made everything is OK, so you decide to push it to production…

Everything will be OK and no user will notice an issue: your users will go for a walk OK at first and for most of them, it will be very good(sunny weather, small rain when the jacket is enough). Until one day there will be heavy rain for some user for whom code packed things, and he will find out that instead of protection against rain he has the bag for garbage, let God protect us against such situations… Not very nice UX…

Now I am not a TypeScript expert and I don’t have huge experience and sometimes I make horrible code and I made quite a few mistakes like that.

But I know that TypeScript is very helpful since it can catch a lot of these things when you write code. And TypeScript can warn you saying: “hay, you have taken garbage bug and you need protection against the rain”.