Microsoft/TypeScript

`@deprecated` incorrectly marks the wrong type as deprecated when used in JavaScript.

Open

#47,652 opened on Jan 28, 2022

View on GitHub
 (5 comments) (0 reactions) (0 assignees)TypeScript (6,726 forks)batch import
BugDomain: JSDocHelp Wanted

Repository metrics

Stars
 (48,455 stars)
PR merge metrics
 (Avg merge 6d 17h) (9 merged PRs in 30d)

Description

Bug Report

🔎 Search Terms

deprecated jsdoc js

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about deprecated

⏯ Playground Link

Playground (JavaScript) Playground (TypeScript)

💻 Code

/**
 * @deprecated
 * @typedef {number | string} MyType
 */

class Foo {
    /**
     * @param {MyType} x
     *         ^^^^^^-- Not marked as deprecated
     */
    foo(x) {

    }
}

const x = new Foo();
//            ^^^--- Marked as deprecated
x.foo(5);

🙁 Actual behavior

The class Foo is marked as deprecated.

🙂 Expected behavior

The type MyType of parameter x of Foo.foo() should be marked as deprecated and the class Foo should not. Just like how it works in the TypeScript equivalent of this code.

Contributor guide