ts-error is an NPM package providing an extendable Error class together with TypeScript definition files, supporting old and new style classes and compatibility even with the oldest browsers. The purpose of extendable errors classes is to be able to throw error objects that are subclasses of the built-in JavaScript Error class, which has a number of gotchas, and to then filter them with the instanceof operator in the catch clause of a try/catch block as well as potentially adding additional variables to the error object. There exist a number of similar packages on NPM, but they all have shortcomings, like not supporting TypeScript, being awkward to use with TypeScript 2, not being compatible with old browsers, not printing the stack trace when used with console.log or similar functions or not having all features I wanted. So I decided to write my own.


