Skip to content
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

fix(eslint-plugin): [no-unused-vars] correct detection of unused vars in a declared module with export = #2505

Merged
merged 1 commit into from Sep 6, 2020

Conversation

bradzacher
Copy link
Member

If a declare module has an export = in its body, then TS will only export that.
If it doesn't have an export =, then all things are implicitly exported.

This adds handling to correctly detect this case.

declare module 'foo' {
  type T = 1; // T is unused and not exported
  const x = 2;
  export = x;
}

declare module 'bar' {
  type T = 1;
  const x = 2;
  // T and x are both implicitly exported
}

… in a declared module with `export =`

If a `declare module` has an `export =` in its body, then TS will only export that.
If it doesn't have an `export =`, then all things are ambiently exported.

This adds handling to correctly detect this case.
@bradzacher bradzacher added the bug Something isn't working label Sep 6, 2020
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

codecov bot commented Sep 6, 2020

Codecov Report

Merging #2505 into master will decrease coverage by 0.00%.
The diff coverage is 88.88%.

@@            Coverage Diff             @@
##           master    #2505      +/-   ##
==========================================
- Coverage   92.80%   92.79%   -0.01%     
==========================================
  Files         290      290              
  Lines        9436     9451      +15     
  Branches     2642     2647       +5     
==========================================
+ Hits         8757     8770      +13     
  Misses        323      323              
- Partials      356      358       +2     
Flag Coverage Δ
#unittest 92.79% <88.88%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...t-plugin/src/rules/adjacent-overload-signatures.ts 93.33% <ø> (ø)
packages/eslint-plugin/src/rules/indent.ts 90.47% <ø> (ø)
packages/eslint-plugin/src/rules/no-unused-vars.ts 92.85% <85.71%> (-1.20%) ⬇️
packages/scope-manager/src/scope/ScopeBase.ts 91.71% <100.00%> (+0.04%) ⬆️

@bradzacher bradzacher merged commit 3d07a99 into master Sep 6, 2020
@bradzacher bradzacher deleted the no-unused-vars-module-decl branch September 6, 2020 20:20
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant