util: allow deprecate on classes by vdeturckheim · Pull Request #7690 · nodejs/node

@nodejs-github-bot added the util

Issues and PRs related to the built-in util module.

label

Jul 12, 2016

@vdeturckheim

Classes objects cannot be called without new. util.deprecate executes
'fn.apply'.

Therefore, classes cannot be deprecated with util.deprecate.

This uses 'new.target' to detect (when process is defined) calls to
constructor to allow deprecate on class.

cjihrig pushed a commit that referenced this pull request

Aug 4, 2016
Classes cannot be instantiated without new, but util.deprecate()
uses Function.prototype.apply(). This commit uses new.target to
detect constructor calls, allowing classes to be deprecated.

PR-URL: #7690
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

cjihrig pushed a commit that referenced this pull request

Aug 10, 2016
Classes cannot be instantiated without new, but util.deprecate()
uses Function.prototype.apply(). This commit uses new.target to
detect constructor calls, allowing classes to be deprecated.

PR-URL: #7690
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>