Doesn't this code break the expected behavior of class hierarchy/polymorphism?
const Boom = require('@hapi/boom').Boom;
undefined
class A extends Boom{};
undefined
class B extends A{};
undefined
const a = new A();
undefined
a instanceof B;
true
I see that removing that part of the Boom class doesn't fix the problem, since the Boom constructor actually returns a decorated Error and not an instance of itself. It's a bit strange.
It took me a while to figure out why instanceof for a subclass wasn't behaving like all other javascript classes, maybe it would just be worth adding something to the docs explaining the implications of extending Boom?
Support plan
Context
How can we help?
https://github.com/hapijs/boom/blob/80528a674af77703cb8d0be15b50a655225d5cae/lib/index.js#L92
Doesn't this code break the expected behavior of class hierarchy/polymorphism?
I see that removing that part of the Boom class doesn't fix the problem, since the Boom constructor actually returns a decorated Error and not an instance of itself. It's a bit strange.
It took me a while to figure out why instanceof for a subclass wasn't behaving like all other javascript classes, maybe it would just be worth adding something to the docs explaining the implications of extending Boom?