Skip to content

Bug: [no-deprecated] Erroneous lint errors when @deprecated is applied to a nested namespace declaration #9902

@ashvinsrivatsa

Description

@ashvinsrivatsa

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.5.4&fileType=.tsx&code=CYUwxgNghgTiAEA7KBbEBnADlMCCCAdAELwDeAsAFDzxgD2i6ALvAJ4Bc8zMAlogOYBuKgF8qVAPQAqKfAACoTHDBQmIYPCkSqoSLATI0WHPgIBhMlRr1GLAF6dufIaPGUb6OhBAEIdfgAUhEQErACUgkA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oBNFjpEZAIb5E3dFETRoHaJHBgAviEVA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

declare namespace A.B {
  const y: string;
}

/** @deprecated */
declare namespace A.C {
  const z: string;
}

console.log(A.B.y);

ESLint Config

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

tsconfig

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

Expected Result

No lint errors on the line console.log(A.B.y), because none of the elements A, A.B, or A.B.y are marked @deprecated.

Actual Result

A @typescript-eslint/no-deprecated lint error appears on that line:

`A` is deprecated. 10:13 - 10:14

Additional Info

A real-world example of this is in the @types/chrome package, which provides typing for browser-specific APIs exposed by Chrome for use in Chrome Apps and Chrome Extensions. There are a bunch of specific APIs that are deprecated, such as:

/**
 * @deprecated Part of the deprecated Chrome Apps platform
 */
declare namespace chrome.socket {
  // ...
}

But this results in the linter raising a @typescript-eslint/no-deprecated at every usage site of chrome (not just chrome.socket - also other things like chrome.tabs, chrome.runtime, etc, which aren't deprecated).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions