class Foo extends Error { type: string; constructor(type: string, message: string) { super(message); // Clean up the changes made by super() this.constructor = Foo; if ((Object as any).setPrototypeOf) { (Object as any).setPrototypeOf(this, Foo.prototype); } else { (this as any).__proto__ = Foo.prototype; } // Only reference props on this after this point for safety this.type = type; } doStuff() { return "I am a " + this.type + " type of error." } } let e = new Foo("dramatic", "Goodbye, cruel world"); console.clear(); console.log('e instanceof Error', e instanceof Error); console.log('e instanceof Foo ', e instanceof Foo); console.log('e.type ', e.type); console.log('typeof e.doStuff ', typeof e.doStuff); console.log('');