Remove, Deprecate or Alias: Choosing How to Retire an API
Sooner or later a function, option or export in your package has to go. You have three broad choices: delete it in the next major, deprecate it and delete it later, or keep it forever as a thin alias for its replacement. Each can be the right answer. This comparison sets them side by side and suggests which suits which situation.
The three approaches
Remove outright. The API disappears in the next major release, documented in the changelog's Removed section. Simple for the maintainer, abrupt for users, and only acceptable when you are confident few people use it or the replacement is obvious.
Deprecate, then remove. The API keeps working but warns, the documentation marks it deprecated, and removal happens in a later major. In JavaScript the JSDoc @deprecated tag makes editors strike the name through; in Python, warnings.warn(..., DeprecationWarning) is the conventional signal, and Python 3.13 added the warnings.deprecated decorator that type checkers also understand.
Alias permanently. The old name becomes a one-line wrapper around the new one and is never removed. Users never break; the cost is a slightly larger surface and documentation that has to explain why two names exist.
/** @deprecated Use `parseConfig` instead. Will be removed in 5.0. */
export function readConfig(path) {
warnOnce("readConfig is deprecated; use parseConfig");
return parseConfig(path);
}
Side by side
| Remove outright | Deprecate then remove | Permanent alias | |
|---|---|---|---|
| User effort at upgrade | Highest, all at once | Spread over time, guided by warnings | None |
| Maintainer effort | Lowest | Medium: warnings, docs, tracking removal | Low, but forever |
| Version bump needed | Major | Minor for deprecation, major for removal | Minor (adds the new name) |
| Risk of surprise breakage | High | Low if warnings are visible | Very low |
| Surface area over time | Shrinks | Shrinks, later | Grows |
| Works when behaviour changes, not just the name | Yes | Yes | No; an alias only fits a pure rename |
Verdict by use case
- A pure rename of a popular function: permanent alias, or deprecate with a long window. Breaking thousands of call sites over a name is rarely worth it.
- An API that is unsafe or fundamentally wrong: deprecate quickly with a loud warning, remove in the next major. An alias would preserve the problem.
- An experimental API clearly marked as such: removing it outright is fair, because the documentation never promised stability. Say so in the changelog anyway.
- Pre-1.0 packages: the semver.org specification says anything may change in 0.y.z, but users still appreciate one release of warning when it costs you little.
- Internal libraries in a single repository: remove outright and fix the callers in the same change; there is nobody external to warn.
Whichever you pick
Write down the replacement in the same sentence as the retirement, give a version number for removal if there is one, and make sure the warning appears where the user will actually see it rather than only in the docs. Our long read on package deprecation policy covers setting a standard window, and deprecating a function in a library walks through the code.