-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[no-unused-vars] False positive when declaring modules #2523
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
Where is your |
We are running into a very similar situation, and yes, it is happening inside a |
If you're running the latest version, then there should be no way that it's reporting in a Could you provide more information please? A comment with no context is counter productive to helping me investigate. A repro repo is always a great way to help the volunteer maintainers investigate. |
In my case |
Not sure if this is the same or slightly different - in my case, I'm using declaration merging with a namespace from
|
This comment has been minimized.
This comment has been minimized.
I see the same issue upgrading to v4.1.0 from 4.0.1, in a .ts file:
error 'global' is defined but never used @typescript-eslint/no-unused-vars |
I see the same problem when defining custom Jest matchers: declare global { // <-- 'global' is defined but never used (@typescript-eslint/no-unused-vars)
namespace jest {
interface Matchers<R> { // <-- 'Matchers' is defined but never used (@typescript-eslint/no-unused-vars)
toBeSeven: () => R;
}
}
}
expect.extend({
toBeSeven(value): jest.CustomMatcherResult {
if (value !== 7) {
return { pass: false, message: (): string => `Expected seven, but got ${value}` };
}
return { pass: true, message: (): string => 'Expected non-seven' };
},
});
it('is seven', () => {
expect(7).toBeSeven();
}); As others have noted, this is in the main |
…ules Fixes #2523 - `declare global` should never be marked as unused. - namespaces within declared namespaces all ambiently export their children
declare namespace Cypr_something_I_cant_see {
interface Chainable<Subject = any> {
toggleDarkMode(): void;
clearLocalStorageForReal(): void;
}
} This case is not a false-positive - the generic is unused. The other cases of:
will be fixed in the next version. |
It isn't required, so the proper fix is to change the code (in this case, just TypeScript will still correctly merge the definitions if one has no generics (or only some of the generics). I confirmed that when I changed Thanks for the fix! |
Ah, learn something new every day - thanks, @davidje13 and @bradzacher! |
I also tried canary versions.
Repro
Expected Result
I didn't expect any error.
Actual Result
'global' is defined but never used.
'arg' is defined but never used.
Versions
@typescript-eslint/eslint-plugin
4.1.0
@typescript-eslint/parser
4.1.0
TypeScript
4.0.2
ESLint
7.8.1
node
12.18.1
The text was updated successfully, but these errors were encountered: