208

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?

lhk
  • 27,458
  • 30
  • 122
  • 201

1 Answers1

372

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.

Vladyslav Zavalykhatko
  • 15,202
  • 8
  • 65
  • 100