-
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
Determine if a method is deprecated in code #22524
Comments
Currently, for functions you could just check Similarly for non-function properties you could do something like: var getter = Object.getOwnPropertyDescriptor(obj, 'property').get;
if (getter && getter.name === 'deprecated')
// ... Having a core API for determining all of this might be a good idea though. |
Seems like another potential use case for #22302 (cc: @MylesBorins) |
Ah, thanks @mscdex! I will work on a PR to add that to the util.deprecate docs 👍 |
in some carnation of adding esm to the builtin modules I had a WeakSet of all the deprecated functions (incl. getters) which worked fairly well. |
I retract my offer to do this change. I'm going to stay away from Node.js core. |
I'm looking for a method in which use-land Node.js code can determine if a method in Node.js has been marked deprecated or not prior to calling it. It looks like this is typically done with
util.deprecate
. It seems like from an issue discussion the method to do this is to use.propertyIsEnumerable
. Is this the correct way to go about this type of detection?If this is the agreeable way to detect the deprecated things in Node.js, I can volunteer to make a pull request to update the
util.deprecate
documentation and add a test to the test suite to validate things fromutil.deprecate
work this way. I just wanted to make sure I'm understanding correctly and this is the right path for user-land detection prior to opening a PR 👍Edit: I opened this as it's own issue so conversation wouldn't get lost in an unrelated PR.
The text was updated successfully, but these errors were encountered: