Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lilnasy
Copy link

@lilnasy lilnasy commented Oct 23, 2025

PR Checklist

Overview

To fix the issue, implicit variables are mutated as the global scope is being populated.

I admittedly did not spend much time thinking of a proper solution. Though it was tricky to pinpoint, the fix is simple. I imagine the "correct" location for the fix is a matter of maintainer preference.

Direct commits from maintainers welcome.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @lilnasy!

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 Oct 23, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit d78359d
🔍 Latest deploy log https://app.netlify.com/projects/typescript-eslint/deploys/69122d5be699de00084adf96
😎 Deploy Preview https://deploy-preview-11715--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: 98 (🟢 up 2 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.

@lilnasy lilnasy changed the title fix(scope manager): reconcile type-value distinction for implicit globals across libs fix(scope-manager): reconcile type-value distinction for implicit globals across libs Oct 23, 2025
@nx-cloud
Copy link

nx-cloud bot commented Oct 23, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit d78359d

Command Status Duration Result
nx run-many -t typecheck ❌ Failed 1m 54s View ↗
nx test eslint-plugin --coverage=false ✅ Succeeded 5m 9s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 2s View ↗
nx run integration-tests:test ✅ Succeeded 6s View ↗
nx test eslint-plugin-internal --coverage=false ✅ Succeeded 10s View ↗
nx run types:build ✅ Succeeded 5s View ↗
nx run generate-configs ✅ Succeeded 8s View ↗
nx run-many --target=build --parallel --exclude... ✅ Succeeded 26s View ↗
Additional runs (28) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-11-10 18:34:10 UTC

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.66%. Comparing base (843f144) to head (d78359d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11715   +/-   ##
=======================================
  Coverage   90.66%   90.66%           
=======================================
  Files         518      518           
  Lines       52454    52464   +10     
  Branches     8694     8698    +4     
=======================================
+ Hits        47558    47568   +10     
- Misses       4882     4883    +1     
+ Partials       14       13    -1     
Flag Coverage Δ
unittest 90.66% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/scope-manager/src/scope/ScopeBase.ts 96.04% <100.00%> (+0.12%) ⬆️
.../scope-manager/src/variable/ImplicitLibVariable.ts 87.50% <100.00%> (ø)
🚀 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.

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

instead of mutating the variable here -- could we instead do it higher.

eg:

In the GlobalScope class (which calls ScopeBase.defineVariable):

public defineImplicitVariable(
name: string,
options: ImplicitLibVariableOptions,
): void {
this.defineVariable(
new ImplicitLibVariable(this, name, options),
this.set,
this.variables,
null,
null,
);
}

Or in the Referencer class (which calls GlobalScope.defineImplicitVariable):

// This loop is guaranteed to see each included lib exactly once
for (const [name, variable] of lib.variables) {
globalScope.defineImplicitVariable(name, variable);
}

I think the latter would be better as we could pre-aggregate the variable definitions to deduplicate and merge them before even calling defineImplicitVariable.

@lilnasy
Copy link
Author

lilnasy commented Nov 8, 2025

@bradzacher I'm thinking it would be even better to go one level higher.

The first year-wise occurrence of the globals I glimpsed at seems to always be TYPE_VALUE. If that holds true for all, we could simply ensure the iteration is in chronological order at runtime and it would work. The test could be made more comprehensive to prevent regressions.

@lilnasy
Copy link
Author

lilnasy commented Nov 10, 2025

I have a branch where I flatten the lib references at codegen time instead of at runtime, fixing the bug right there. It increases the package size a little but reduces ScopeManager instantiation time.

I can move forward with whichever approach maintainers prefer.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scope Manager fails to pick up references to implicit globals

2 participants