woutervh- / typescript-is

MIT License
959 stars 35 forks source link

feature request: set custom error class in AssertType #129

Open ZeeD opened 2 years ago

ZeeD commented 2 years ago

Hi. I just found your project, witch is cool, and could let me avoid a lot of manual checks (I have a lot of class autogenerated by .proto files, and I wanted something to leverage the checks automatically) so, thanks for your project :) I found the decorator @AssertType() very useful, but I was wondering if there is some way to let it know that it need to throws a custom Error, not TypeGuardError. Moreover, as I'm not sure 100% on "how" it works, I didn't found an obvious way to wrap the decorator in a try { ... } catch { ... } block to convert the error itself.