Repository navigation
Respect parameter-initializer scope for body function declarations - #65299
Ryan Cavanaugh (RyanCavanaugh) merged 4 commits into
Conversation
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
|
TypeScript Bot (@typescript-bot) test it |
|
Hey Ryan Cavanaugh (@RyanCavanaugh), the results of running the DT tests are ready. Everything looks the same! |
|
Ryan Cavanaugh (@RyanCavanaugh) Here are the results of running the user tests with tsc comparing Everything looks good! |
|
Ryan Cavanaugh (@RyanCavanaugh) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Ryan Cavanaugh (@RyanCavanaugh) Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the parameter-initializer scope fix.
No open issues 🎉
What changed in this PR
Fixes #65090 by making the native compiler’s name resolution respect parameter-initializer scope: body function declarations no longer shadow outer bindings referenced by default parameters.
Changes:
- Extends the existing parameter-scope filter to function symbols.
- Adds regression coverage for direct defaults, closures, destructuring, and missing outer bindings, while preserving body, parameter, and named-function lookup.
- Records expected symbol resolution, types, diagnostics, and JavaScript output.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/defaultParameterBodyFunctionScope.ts |
Adds parameter-initializer scope regression cases. |
tsc/testdata/baselines/reference/compiler/defaultParameterBodyFunctionScope.types |
Records expected inferred types. |
tsc/testdata/baselines/reference/compiler/defaultParameterBodyFunctionScope.symbols |
Records references resolving to the correct declarations. |
tsc/testdata/baselines/reference/compiler/defaultParameterBodyFunctionScope.js |
Records emitted JavaScript for the test cases. |
tsc/testdata/baselines/reference/compiler/defaultParameterBodyFunctionScope.errors.txt |
Records the missing-name diagnostic when no outer binding exists. |
tsc/internal/binder/nameresolver.go |
Applies parameter-scope filtering to function symbols. |
Review effort: Balanced
Fixes #65090
Analysis
Parameter-initializer scope filtering covered variables but excluded function symbols, allowing body functions to shadow outer bindings in checker API results.
The initializer’s
stylesshould resolve to the outer variable, matching runtime behavior.Fix
Copilot Checklist
I successfully ran the applicable command at the end of my session, and it completed without error: