Unit tests don't actively prevent type errors, but they do provide you a mechanism to execute the code you have written before the entire application is complete.
If you try to do something silly, like mistyping calculateInterest
as claculateinterest
, then that will be caught early on if you use a statically typed, compiled language like Java because the compiler will complain loudly.
If you do the same in a dynamically typed language, the error will not be noticed until that line of code actually gets executed.
If you don't write unit tests, then it can be weeks before the application is finished far enough that your feature can be executed and tested in the complete application. That is a very long turn-around time for finding such silly mistakes.
On the other hand, if you do write unit tests, then it is mere minutes between writing a module and executing it. This has the huge advantage that the code is still fresh in your mind and that you are not yet fully occupied with writing other modules.