Repository navigation
Remove util.inherits usage internally? #24395
Copy link
Copy link
Closed
Labels
good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
Description
Currently, util.inherits does this:
Lines 300 to 318 in e1aa730
| function inherits(ctor, superCtor) { | |
| if (ctor === undefined || ctor === null) | |
| throw new ERR_INVALID_ARG_TYPE('ctor', 'Function', ctor); | |
| if (superCtor === undefined || superCtor === null) | |
| throw new ERR_INVALID_ARG_TYPE('superCtor', 'Function', superCtor); | |
| if (superCtor.prototype === undefined) { | |
| throw new ERR_INVALID_ARG_TYPE('superCtor.prototype', | |
| 'Function', superCtor.prototype); | |
| } | |
| Object.defineProperty(ctor, 'super_', { | |
| value: superCtor, | |
| writable: true, | |
| configurable: true | |
| }); | |
| Object.setPrototypeOf(ctor.prototype, superCtor.prototype); | |
| } |
Most of the code seems unnecessary for our internal use. Essentially we can just replace all the internal util.inherits usage with Object.setPrototypeOf(ctor.prototype, superCtor.prototype)
Unless someone is relying on that ctor._super property existing on our internal types..
Any thoughts?
Reacted by Refael Ackermann, Marvin Hagemeister, ZYSzys, Weijia Wang, Ben Noordhuis, Sindre Sorhus, Ouyang Yadong, Yury and Ruben Bridgewater
Metadata
Metadata
Assignees
Labels
good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.
Activity
refack commentedon Nov 16, 2018
I'm +1 on writing a PR and running CitGM on it, then have it in nightlies go get some feedback. Otherwise we won't know.
(Ohh, and run a query on Gzemnid)
lib: remove `inherits()` usage
lib: remove `inherits()` usage
joyeecheung commentedon Mar 9, 2019
This is still open, can probably be used as code-and-learn tasks
cjihrig commentedon Mar 12, 2019
@peanutenthusiast check out #26546 for an updated version of this issue.
BridgeAR commentedon Mar 31, 2019
Closing as resolved. There is no usage internal usage left in core.