Skip to content

Add diagnostic for private identifiers in destructuring patterns - #64084

Open
Spencer Young (youngspe) wants to merge 2 commits into
microsoft:mainfrom
youngspe:pr/private-ident-in-binding-pattern
Open

Add diagnostic for private identifiers in destructuring patterns#64084
Spencer Young (youngspe) wants to merge 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

注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

Status: Not started

Development

Successfully merging this pull request may close these issues.

Missing syntax error for destructuring with private names

2 participants