fix(4048): fix declaration emit for new keyword used as property names#4052
Open
a-tarasyuk wants to merge 1 commit into
Open
fix(4048): fix declaration emit for new keyword used as property names#4052a-tarasyuk wants to merge 1 commit into
a-tarasyuk wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds coverage for declaration emit around keyword property names and adjusts type-node building to ensure a method named new is emitted as a quoted property name (not a construct signature), updating/removing related baselines.
Changes:
- Added a new compiler test case for keyword property names (
new,delete,break,continue) in object literals andas const. - Updated pseudo type-to-AST node construction to special-case method names equal to
newand emit them as string-literal property names. - Cleaned up accepted/baseline outputs related to
emitMethodCalledNew.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| testdata/tests/cases/compiler/declarationEmitKeywordPropertyNames.ts | New test to validate declaration emit for keyword property names. |
| testdata/submoduleAccepted.txt | Removes an accepted baseline diff entry that should no longer be produced. |
| testdata/baselines/reference/submoduleAccepted/compiler/emitMethodCalledNew.js.diff | Removes an obsolete accepted diff baseline. |
| testdata/baselines/reference/submodule/compiler/emitMethodCalledNew.js | Updates expected output to emit "new" instead of ["new"]. |
| testdata/baselines/reference/compiler/declarationEmitKeywordPropertyNames.* | Adds new baselines for the new keyword-property-names test. |
| internal/checker/pseudotypenodebuilder.go | Special-cases method name new to emit a string literal property name node. |
| internal/checker/nodecopy.go | Simplifies reuseName logic by removing new-specific handling and always normalizing string-literals to identifiers. |
Comments suppressed due to low confidence (1)
internal/checker/nodecopy.go:1
- The previous logic intentionally avoided normalizing the string literal
"new"into an identifier because, in method-signature contexts,new()is interpreted as a construct signature (different meaning than a method named"new"). The PR moves the special-casing intopseudoTypeToNodefor one specific path, butreuseNameis a shared helper; with this change, any other caller that reuses"new"as a method name risks emitting a construct signature again. Consider restoring an explicit guard inreuseNameto not normalize"new"(and/or introducing a context-aware helper likereusePropertyNameForMethodvsreusePropertyNameForProperty) so the invariant is enforced centrally rather than depending on individual call sites.
package checker
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in 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 #4048