Skip to content

Add diagnostic for private identifiers in destructuring patterns - #64084

Merged
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
youngspe:pr/private-ident-in-binding-pattern
Sep 1, 2026
Merged

Add diagnostic for private identifiers in destructuring patterns#64084
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
youngspe:pr/private-ident-in-binding-pattern

Conversation

@youngspe

@youngspe Spencer Young (youngspe) commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #35942

This tripped me up when I tried to do something like this, thinking it was valid syntax:

const { #foo: foo } = this;

This change adds a diagnostic: Private identifiers cannot be used in destructuring patterns. and a baseline test for it.

This is my first contribution to the compiler, so hopefully I'm not missing anything here (for example, is there a special process for adding diagnostics?)

Copilot AI balanced review requested due to automatic review settings August 28, 2026 20:33
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a compiler diagnostic for private identifiers used in object binding patterns.

Changes:

  • Adds diagnostic TS18064 and checker validation.
  • Adds a conformance test and generated baselines.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsc/internal/checker/checker.go Reports the diagnostic for binding elements.
tsc/internal/diagnostics/diagnosticMessages.json Defines TS18064.
tsc/internal/diagnostics/diagnostics_generated.go Adds generated diagnostic mappings.
tsc/testdata/tests/cases/conformance/classes/members/privateNames/privateNamesNotAllowedAsBindingPatterns.ts Adds the compiler test case.
tsc/testdata/baselines/reference/conformance/privateNamesNotAllowedAsBindingPatterns.errors.txt Captures the expected diagnostic.
tsc/testdata/baselines/reference/conformance/privateNamesNotAllowedAsBindingPatterns.js Captures emitted JavaScript.
tsc/testdata/baselines/reference/conformance/privateNamesNotAllowedAsBindingPatterns.symbols Captures symbol information.
tsc/testdata/baselines/reference/conformance/privateNamesNotAllowedAsBindingPatterns.types Captures inferred types.
Files not reviewed (1)
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

Comment thread tsc/internal/checker/checker.go Outdated
@youngspe Spencer Young (youngspe) changed the title Add diagnostic for private identifiers used as binding patterns Add diagnostic for private identifiers in destructuring patterns Aug 28, 2026
@youngspe
Spencer Young (youngspe) requested a balanced review from Copilot August 29, 2026 02:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Sep 1, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Sep 1, 2026
Merged via the queue into microsoft:main with commit 949d816 Sep 1, 2026
25 checks passed
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Missing syntax error for destructuring with private names

4 participants