Skip to main content

no-deprecated

Disallow using code marked as @deprecated.

💭

This rule requires type information to run.

The JSDoc @deprecated tag can be used to document some piece of code being deprecated. It's best to avoid using code marked as deprecated. This rule reports on any references to code marked as @deprecated.

note

TypeScript recognizes the @deprecated tag and visualizes deprecated code with a strikethrough. However, TypeScript doesn't report type errors for deprecated code on its own.

.eslintrc.cjs
module.exports = {
"rules": {
"@typescript-eslint/no-deprecated": "error"
}
};

Try this rule in the playground ↗

Examples

/** @deprecated Use apiV2 instead. */
declare function apiV1(): Promise<string>;

declare function apiV2(): Promise<string>;

await apiV1();
Open in Playground
import { parse } from 'node:url';

// 'parse' is deprecated. Use the WHATWG URL API instead.
const url = parse('/foo');
Open in Playground

Options

This rule is not configurable.

When Not To Use It

If portions of your project heavily use deprecated APIs and have no plan for moving to non-deprecated ones, you might want to disable this rule in those portions.


Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting. See Troubleshooting > Linting with Type Information > Performance if you experience performance degredations after enabling type checked rules.

Resources