-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: util: isDeprecated() #22543
Comments
Instead of an API, maybe we can add a |
how would one consume this capability? if |
To me this is not a "runtime hack". I see it more as an alternative to node version checking when supporting multiple major node versions. /cc @dougwilson as he originally inquired about the right way to do this, so he may have a use case to share |
@AyushG3112 That's not as foolproof (and my current suggested solution is not either), which is why I suggested some mechanism that is more unique to node core only (e.g. an internal symbol placed on the wrapper function). Also simply using a flag on functions still requires the end user to have to manually check for deprecated properties by looking for a 'deprecated' getter/setter on parent objects. Having a single API that can work for both is much cleaner IMHO. |
Slightly different idea... expose a well-known symbol on the console.log(process.assert[util.deprecation])
// Prints: DEP0100 The key challenge with this API, of course, is that it would only be usable for a subset of our deprecations. Things that we deprecate without using the |
How would this work for non-property deprecations? |
|
Note that this does have a bit of logical overlap with the ongoing feature discovery discussion and a similar question could be asked about whether something is experimental. |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
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 hasgetset.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: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.
The text was updated successfully, but these errors were encountered: