-
-
Notifications
You must be signed in to change notification settings - Fork 35.1k
Description
Prior discussion: #22524
It would be useful to have a public API for reliably detecting deprecated methods and properties upfront.
As I mentioned in the referenced issue, end users can currently check func.name === 'deprecated' or for properties, check for a getter and/or setter that has getset.name === 'deprecated', however this isn't necessarily something that is guaranteed to always work. I propose we have some API(s) for doing a more reliable check within core (possibly utilizing internal symbols on the deprecated function wrapper?).
Perhaps the API would be something like util.isDeprecated(objOrFunc[, propertyName]) so you could do:
util.isDeprecated(os.tmpDir);
// or alternatively
util.isDeprecated(os, 'tmpDir');
// or for non-function properties
util.isDeprecated(crypto, 'DEFAULT_ENCODING');This won't work for all possible deprecation scenarios though (e.g. deprecated function parameters, options, etc.), but at least it'd be something useful for many other cases.