TypeScript helps to solve this problem by providing compile time Type checking. This compile time checking can be used to generate type symbols on your code and alert you, via build errors, when you introduce a simple bug.
Do you see the error? Look carefully, it is there?
Since I am using KnockoutJs here and trying to set a value on an observable I cannot set the value this way. I need to set it via method notation.
If we were to add typing to our code as below we would immediately be notified there was an error rather than at run time.
Notice how once I added the typing information to the code the TypeScript compiler was able to tell you that you have a issue in your code, red squigglies and all.
Once we fix our code, as seen below, we are golden.
Now I am not making the claim that TypeScript will fix everything. What I am saying is that by introducing typing into the code and allowing that typing information to flow through your code you will potential to create cleaner and more stable code.
Till next time,