Microsoft/TypeScript

Derived class constructor parameter incorrectly inherits JSDoc from parent class's field of the same name

Open

#62,069 opened on Jul 15, 2025

View on GitHub
 (0 comments) (1 reaction) (0 assignees)TypeScript (48,455 stars) (6,726 forks)batch import
BugDomain: JSDocHelp Wanted

Description

🔎 Search Terms

inheritance, JSDoc,

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play/?ssl=11&ssc=55&pln=11&pc=56#code/MYGwhgzhAEBCkFNoG8BQ0PQPQCofXU2nwBUALASxiujGgBMEJgAnCgBwBcKB7AO2g8AZtAAGEHgFsEAMQoIQ9UdAoDOZJKPgQEy0JAgA6QpnwmM+AAKN2LBMDCcE9AkWJZzE6XIX0AXNAQnGx8AObQALzQAOQA7mSOCABuCCzRANyoAL6oqPpQ0AAiqRQpLggAHk589DDaSGhEWFjQ5DTiUrLyisoJMHw86qrhnDwMY7EU6mJeXb7KqtDqSABGiND5EAA05s2BY1OBZDwArorQA5wqfBpsV1MwAFIAyoU8wMZEwPxBLCfAoxYAApZj5FAFfsMAJQocxECAndipIFQzJuTDfPgSEAIQwgHihEGdMH0VHmHJZIA

💻 Code

class Base {
    /** 
     * This is a description of `someField` in the `Base` class.
     * 
     * @deprecated 
     */
    someField: string = 'whatever';
}

class Derived extends Base {
    // This `someField` has nothing to do with `someField` in the base class,
    // so it should not inherit its JSDoc.
    constructor(someField: string) {
        super();
        console.log(someField);
    }
}

🙁 Actual behavior

Hovering shows the JSDoc from the parent class

🙂 Expected behavior

Hovering should not show any JSDoc description

Additional information about the issue

This impacts https://github.com/typescript-eslint/typescript-eslint/issues/11394, since we look for @deprecated JSDoc attributes via the API, which are showing up spuriously in this case.

Contributor guide