@typescript-eslint/no-deprecated

Disallow using code marked as @deprecated

needs types

Also called typescript-eslint/no-deprecated, typescript/no-deprecated

A @deprecated tag in a doc comment says that a function, class, property or type is going away, and usually what to use instead. Editors strike the name through, but nothing stops new code from using it. This rule reports every use, and repeats the text after the tag so you know what to switch to.

It works for your own code, for packages and for the built-in types. The declaration itself and the import aren't reported, only the places where the name is used. If only one overload of a function is deprecated, only calls to that overload are reported.

Configure#

Off by default. This rule needs types, so turning it on makes bun lint type check your code first.

bunfig.toml
[lint.rules]
"@typescript-eslint/no-deprecated" = "error" # or "warn"

Every option, set to its default:

bunfig.toml
[lint.rules]
"@typescript-eslint/no-deprecated" = ["error", {
  allow = [], # list of strings or objects
}]

Examples#

example.ts2 problems
/** @deprecated Use `fetchUser` instead. */
function getUser(id: number) {}

interface Options {
  /** @deprecated */
  legacy?: boolean;
}

getUser(1);

function start(options: Options) {
  return options.legacy;
}

Built-in methods count too:

example.ts1 problem
const year = "2026-01-01".substr(0, 4);
example.tsNo problems
/** @deprecated Use `fetchUser` instead. */
function getUser(id: number) {}

function fetchUser(id: number) {}

fetchUser(1);

const year = "2026-01-01".slice(0, 4);

Only the deprecated overload:

example.ts1 problem
/** @deprecated Pass a number. */
function load(id: string): void;
function load(id: number): void;
function load(id: string | number): void {}

load("1");
load(1);

Options#

OptionDefaultWhat it does
allow[]Deprecated names that you can keep using.

Each allow entry is a name, or an object that also says where the name comes from:

EntryWhat it matches
"getUser"Anything with that name.
{ "from": "file", "name": "getUser" }A name declared in your project. Add "path" to name the file.
{ "from": "lib", "name": "substr" }A name from the built-in TypeScript types.
{ "from": "package", "name": "exists", "package": "fs" }A name from a package.

name can also be a list of names.

example.tswith { "allow": [{ "from": "file", "name": "getUser" }] }No problems
/** @deprecated Use `fetchUser` instead. */
function getUser(id: number) {}

getUser(1);
example.tswith { "allow": [{ "from": "lib", "name": "substr" }] }No problems
const year = "2026-01-01".substr(0, 4);