DEV Community

Discussion on: Better TypeScript... With JavaScript

Collapse
 
tshddx profile image
Thomas Shaddox

What I don't quite understand about this concept is what your code is supposed to do at runtime when it finds a runtime type error. I see that the allow library throws an Error by default and can be configured with any callback. Isn't the only advantage here that you guarantee your program to throw the error at the top of the function, instead of wherever else it would eventually throw an error in the body of the function?

That might make your error monitoring dashboard a little cleaner to look at, but it doesn't seem like it helps the people using the software. I suppose you could also display a slightly better error message, but it's not going to be significantly more useful to any visitor who has no way of resolving the error.