I mean, the answer is just, more tests. If you choose a dynamic language over a compiled one, then you've in essence chosen to eliminate type definitions in code and replace them with type verifications in tests. Of course, if you switch to a typed language that doesn't have nil types, that doesn't help...