Skip to content

Fix binding element phantom error#3288

Merged
ahejlsberg merged 2 commits intomainfrom
fix-3276
Mar 29, 2026
Merged

Fix binding element phantom error#3288
ahejlsberg merged 2 commits intomainfrom
fix-3276

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

@ahejlsberg ahejlsberg commented Mar 28, 2026

Removes an incorrect reuse of cached types for binding element parents as suggested here.

Fixes #3276.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an intermittent type-checking error involving optional destructuring parameters by tightening when the checker reuses cached resolvedType values for binding element parents (avoiding reuse when the cached type may have included optionality).

Changes:

  • Adjust getTypeForBindingElementParent to avoid reusing valueSymbolLinks.resolvedType for optional declarations under strictNullChecks.
  • Add a compiler repro test covering the previously intermittent phantom error scenario.
  • Add/update reference .types and .symbols baselines for the new test.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/checker/checker.go Prevents reuse of cached parent types for binding patterns when optionality could be baked into the cached type, fixing the phantom error.
testdata/tests/cases/compiler/bindingPatternOptionalParameterCached.ts Adds a minimal repro that should typecheck without errors (regression test for #3276).
testdata/baselines/reference/compiler/bindingPatternOptionalParameterCached.types Records expected type baseline output for the new test.
testdata/baselines/reference/compiler/bindingPatternOptionalParameterCached.symbols Records expected symbol baseline output for the new test.

@ahejlsberg ahejlsberg added this pull request to the merge queue Mar 29, 2026
Merged via the queue into main with commit 3b211e2 Mar 29, 2026
25 checks passed
@ahejlsberg ahejlsberg deleted the fix-3276 branch March 29, 2026 11:42
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.

Intermittent typecheck error on optional inline object method parameter

3 participants