-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: [no-deprecated] Erroneous lint errors when @deprecated is applied to a nested namespace declaration #9902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Does it? See this code in the TypeScript playground: namespace A.B {
/** @deprecated */
export const x = "x";
export const y = "y"
}
/** @deprecated */
namespace A.C {
export const z = "z";
}
console.log(A.B.x);
console.log(A.B.y); On the two |
Yeah I'd agree here. Your code is really ambiguous. /** @deprecated */
namespace Foo.Bar {} What's meant to be deprecated here? Add to that what Josh has found -- TS is even unsure what you meant! So the recommendation is that you need to disambiguate your code. namespace Foo {
/** @deprecated */
export namespace Bar {}
} Or in the context of your example: declare namespace A.B {
const y: string;
}
declare namespace A {
/** @deprecated */
namespace C {
const z: string;
}
}
console.log(A.B.y); // no error
console.log(A.C.z); // errors |
In this case it's from |
Filed microsoft/TypeScript#59792 -- we'll see what they say. |
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.5.4&fileType=.tsx&code=CYUwxgNghgTiAEA7KBbEBnADlMCCCAdAELwDeAsAFDzxgD2i6ALvAJ4Bc8zMAlogOYBuKgF8qVAPQAqKfAACoTHDBQmIYPCkSqoSLATI0WHPgIBhMlRr1GLAF6dufIaPGUb6OhBAEIdfgAUhEQErACUgkA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oBNFjpEZAIb5E3dFETRoHaJHBgAviEVA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
No lint errors on the line
console.log(A.B.y)
, because none of the elementsA
,A.B
, orA.B.y
are marked@deprecated
.Actual Result
A
@typescript-eslint/no-deprecated
lint error appears on that line: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:But this results in the linter raising a
@typescript-eslint/no-deprecated
at every usage site ofchrome
(not justchrome.socket
- also other things likechrome.tabs
,chrome.runtime
, etc, which aren't deprecated).The text was updated successfully, but these errors were encountered: