diff --git a/lib/util.js b/lib/util.js index ae2295533df3ef..8eaf62f0abbdd5 100644 --- a/lib/util.js +++ b/lib/util.js @@ -285,7 +285,11 @@ function inherits(ctor, superCtor) { throw new ERR_INVALID_ARG_TYPE('superCtor.prototype', 'Function', superCtor.prototype); } - ctor.super_ = superCtor; + Object.defineProperty(ctor, 'super_', { + value: superCtor, + writable: true, + configurable: true + }); Object.setPrototypeOf(ctor.prototype, superCtor.prototype); } diff --git a/test/parallel/test-util-inherits.js b/test/parallel/test-util-inherits.js index d37cb6bf8b73e4..9bbb4352dc3853 100644 --- a/test/parallel/test-util-inherits.js +++ b/test/parallel/test-util-inherits.js @@ -18,7 +18,15 @@ function B(value) { inherits(B, A); B.prototype.b = function() { return this._b; }; -assert.strictEqual(B.super_, A); +assert.deepStrictEqual( + Object.getOwnPropertyDescriptor(B, 'super_'), + { + value: A, + enumerable: false, + configurable: true, + writable: true + } +); const b = new B('b'); assert.strictEqual(b.a(), 'a');