Skip to content

Bug: [no-deprecated] Forbids using the name of a deprecated class member in a child classes constructor #11394

Open
@TheBlue-1

Description

@TheBlue-1

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.8.2&fileType=.tsx&code=LAKApgHgDg9gTgFwAQGMA2BDAzlpAFDOMAOwQGFMckBvUJJAegComkABAEzCiJQwTAckTBnSRQArgCM0ASxRIAboVkYZYAFxIsCOLOIBzJAB8kE4lwBm%2BwQG5QYyTPlJiYAO4A1FWrSbtuvpGpuZWNhz2II7ScgooMMQ6cBIoCPAAFMp6vv5JQQCUNGL0CAAWslgAdG5ePupIALxKdX6R9AC%2BoJ1R4NDwyOjYuGTlaBwUQ0iQAha4BESkE1S0IPROsaijHN7Z6lp5hiZmFmDWbhHRznEJSSlpcJktuYGGhSv09FgSUGAPWarqfJtD5lCqVFBbHYAvyNZq7VpibrdIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oBNFjpEZAIb5E3dFETRoHaJHBgAviEVA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

export class ParentClass {
  /** @deprecated */
  public variable: string | undefined;

  public newVariable: string | undefined;

  public constructor(variable: string) {
    this.newVariable = variable;
  }
}

export class ChildClass extends ParentClass {
  public childVariable: string | undefined;
  public constructor(variable: string) {
    super(variable); // reports usage of deprecated member "varaible"
    this.childVariable = variable; // reports usage of deprecated member "varaible"
  }
}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-deprecated": "error"
  },
};

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

I expect to be allowed to reuse the name of a deprecated member of my parent class in my child classes constructor, because it doesnt use the this keyword like this.variable.

Actual Result

The usage of my funcrtion scope variable gets forbidden by the rule.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexternalThis issue is with another package, not typescript-eslint itselfpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy