Add diagnostic for private identifiers in destructuring patterns - #64084
Open
Spencer Young (youngspe) wants to merge 2 commits into
Open
Add diagnostic for private identifiers in destructuring patterns#64084Spencer Young (youngspe) wants to merge 2 commits into
Spencer Young (youngspe) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
注册 for free
to join this conversation on GitHub.
Already have an account?
登录 to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #35942
This tripped me up when I tried to do something like this, thinking it was valid syntax:
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?)