Microsoft/TypeScript

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

Open

#62.069 aperta il 15 lug 2025

Vedi su GitHub
 (0 commenti) (1 reazione) (0 assegnatari)TypeScript (6726 fork)batch import
BugDomain: JSDocHelp Wanted

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

🔎 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.

Guida contributor