If you write some TypeScript code that is typesafe and is not using third party libraries, do you still need error handling, just because who knows what may happen?
Yes. Not all errors are type-related. For instance, suppose you have a function that does (say) a
fetch from an endpoint. No amount of type information will change the fact that you need to handle the possibility that the request may fail. Similarly, if notifying a bunch of listeners of an event, no amount of type information will protect you from one of those listeners unexpectedly throwing an error.
I’d say that since I switched primarily to TypeScript, I haven’t changed the amount of error handling I do or the level at which I do it (primarily only entry points like event handlers). I have reduced the amount of type-checking I do (I don’t validate that something is a
Answered By – T.J. Crowder
Answer Checked By – Gilberto Lyons (AngularFixing Admin)