You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(cli): the restore guard resolves module aliases by binding and ends an alias at its reassignment #587
The static mock-restore guard (packages/cli/test/helpers/mock-restore-guard-scan.ts) tracks module-object aliases by identifier name, and keeps guarded-global and module-object aliases after their binding is reassigned to a local value. Both make it over-report: a member assignment onto a local object (a parameter that shadows an imported namespace, or an alias rebound to a local value) is required to go through patchShared. Neither makes it miss a patch of shared state.
The fix: resolve module-object aliases by binding (the TypeScript checker's symbol, as the guarded-global analysis does) instead of by name, and end an alias at the assignment that rebinds it. Tests: a parameter named like an imported namespace is not reported; an alias rebound to a local object is not reported after the rebinding but is reported before it; every existing red fixture stays red.
Closing as not planned. The attempt in #588 showed that removing these over-reports safely needs control-flow and call analysis: a position-ordered alias end misses rebindings inside branches, never-run functions, hoisted calls and no-op ??=, and binding-based resolution misses a shadowing parameter that is passed the real module. The over-reports fail closed and none occur in the current test tree, so the guard keeps them. Reopen if a real test trips one.
Activity
tps-flint commentedon Oct 10, 2026
Closing as not planned. The attempt in #588 showed that removing these over-reports safely needs control-flow and call analysis: a position-ordered alias end misses rebindings inside branches, never-run functions, hoisted calls and no-op
??=, and binding-based resolution misses a shadowing parameter that is passed the real module. The over-reports fail closed and none occur in the current test tree, so the guard keeps them. Reopen if a real test trips one.