TypeScript 2.1 introduced a number of breaking changes, among them that “Extending built-ins like Error, Array, and Map may no longer work”.
For a subclass like the following:
class FooError extends Error { constructor(m: string) { super(m); } sayHello() { return "hello " + this.message; } } methods may be undefined on objects returned by constructing these subclasses, so calling sayHello will result in an error. instanceof will be broken between instances of the subclass and their instances, so (new FooError()) instanceof FooError will return false.
Custom Errors in TypeScript 2.1 · Chris Hager
TypeScript 2.1 introduced a number of breaking changes, among them that “Extending built-ins like Error, Array, and Map may no longer work”. For a subclass like the following: class FooError extends Error { constructor(m: string) { super(m); } sayHello() { return "hello " + this.message; } } methods may be undefined on objects returned by constructing these subclasses, so calling sayHello will result in an error. instanceof will be broken between instances of the subclass and their instances, so (new FooError()) instanceof FooError will return false.
https://www.metachris.com/2017/01/custom-errors-in-typescript-2.1/