Skip to content

Conversation

@Tamashoo
Copy link
Contributor

PR Checklist

Overview

This PR fixes the consistent-type-exports rule to correctly handle cases where imported types are shadowed by local value definitions.

I noticed @ntdiary mentioned working on this in the issue comments. I've submitted my approach here - maintainers, please feel free to compare both solutions and choose the one that works best, or we can collaborate to combine the best aspects of each!

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @Tamashoo!

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.

@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 493c1b2
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/6929dafd3c9c1100079fa93a
😎 Deploy Preview https://deploy-preview-11766--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 93 (🔴 down 5 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link

nx-cloud bot commented Nov 18, 2025

View your CI Pipeline Execution ↗ for commit 493c1b2

Command Status Duration Result
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 16s View ↗
nx run-many -t lint ✅ Succeeded 3m 14s View ↗
nx run-many -t typecheck ✅ Succeeded 1m 56s View ↗
nx run types:build ✅ Succeeded 2s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 2s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 1s View ↗
nx run integration-tests:test ✅ Succeeded 3s View ↗
nx run generate-configs ✅ Succeeded 7s View ↗
Additional runs (29) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-11-28 17:37:46 UTC

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Though, I'm not sure what to do given #11769. I suspect we should merge this in first, as it was sent earlier (we don't have any sort of issue claiming system), and see what's left to do with #11769 after?

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Nov 24, 2025
@ntdiary
Copy link
Contributor

ntdiary commented Nov 24, 2025

There are two small issues ATM :)

  1. should perform the value check during iteration, since there may be multi re-export, e.g
    // a.ts
    export type A = 1
    
    // b.ts
    import { A } from './a'
    const A = 1
    export { A }
    
    // c.ts
    export { A } from './b' // false positive
  2. need to handle namespace case, e.g
    // a.ts
    export type A = 1
    
    // b.ts
    import { A } from './a'
    namespace A { export const b = 2 }
    export { A }

I'd personally prefer checking SymbolFlags.Value, looks simpler and robust. However, I'm not entirely sure if it covers all cases. 😅

@Tamashoo
Copy link
Contributor Author

@JoshuaKGoldberg
Thank you for reviewing!
My understanding is that you only need to merge one of the pull requests.
Looking at #11769, it seems more efficient than this PR.

@ntdiary
According to your comment, should we add these test cases in this time, or in a separate one?

Thanks

@ntdiary
Copy link
Contributor

ntdiary commented Nov 26, 2025

@ntdiary According to your comment, should we add these test cases in this time, or in a separate one?

Eh, for now, I don't feel strongly about adding those edge cases :), mainly because:

  1. the tests I added already cover the regular cases and show that the rule works well.
  2. I'm exploring @typescript/vfs, which might change how to write multi-file test (not sure how it'll turn out or whether it'll be accepted, but it seems worth trying first)

@JoshuaKGoldberg
Copy link
Member

I'll go ahead and merge #11769 to main, as the approach is a bit more direct - then add in the added test cases from this PR.

@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(eslint-plugin): [consistent-type-exports] handle shadowed imports correctly test(eslint-plugin): [consistent-type-exports] add more shadowed imports tests Nov 28, 2025
@JoshuaKGoldberg JoshuaKGoldberg merged commit 16cf0f7 into typescript-eslint:main Nov 28, 2025
67 checks passed
@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.49%. Comparing base (bb9ba53) to head (493c1b2).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11766   +/-   ##
=======================================
  Coverage   90.49%   90.49%           
=======================================
  Files         522      522           
  Lines       53362    53367    +5     
  Branches     8913     8918    +5     
=======================================
+ Hits        48288    48293    +5     
  Misses       5059     5059           
  Partials       15       15           
Flag Coverage Δ
unittest 90.49% <ø> (+<0.01%) ⬆️

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JoshuaKGoldberg
Copy link
Member

Thanks @Tamashoo @ntdiary for working on these two PRs & the good discussion around them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: [consistent-type-exports] Importing a shadowing type breaks consistent-type-exports

3 participants