Typing and tests definitely help, but nothing works better than having well-factored, decoupled code, so a change in one place doesn’t impact the rest of the code base in unexpected ways. Unfortunately I don’t know of a good way to do that outside of experience + vigilance.
Another measure I use for code quality is: how afraid am I of breaking something when I make changes? This is where typing and tests shine.