Skip to content

Feature request: util: isDeprecated() #22543

@mscdex

Description

@mscdex

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.staleutilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions