Is it possible to mark something as deprecated in typescript?

TypescriptDeprecatedDeprecation WarningTypescript Definitions

Typescript Problem Overview


I'm writing typescript definitions for a Javascript API with a deprecated method. Here's an extract of the documentation (they say API but it's just about this single method):

> This API has no effect. It has been maintained for compatibility > purpose.

For compatibility purposes, I would also like to document this method in the definitions file. But if possible, I would like to communicate somehow, that it has been deprecated.

While my current issue is only about deprecation in a definitions file, I would also like to use this feature in other code. So the question is more general: How can I mark something as deprecated in typescript?

Typescript Solutions


Solution 1 - Typescript

You can use JSDoc comments to mark deprecated code:

/**
 * @deprecated The method should not be used
 */
export const oldFunc = () => {}

Also, this eslint rule can look through the deprecated methods and warn about their usage.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlhkView Question on Stackoverflow
Solution 1 - TypescriptVladyslav ZavalykhatkoView Answer on Stackoverflow