Normalize reused string-literal property names to identifiers in declaration emit#3965
Open
Copilot wants to merge 4 commits into
Open
Normalize reused string-literal property names to identifiers in declaration emit#3965Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/7d1adf6f-bbb8-49ca-88de-d1ae13f7a91b Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/7d1adf6f-bbb8-49ca-88de-d1ae13f7a91b Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix property names quoting in inferred type
Normalize reused string-literal property names to identifiers in declaration emit
May 18, 2026
RyanCavanaugh
approved these changes
May 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Normalizes declaration emit output so that reused string-literal property names that are valid identifiers are emitted as identifiers, eliminating inconsistent quoting between rebuilt vs reused nested object types.
Changes:
- Normalize reused
StringLiteralproperty names toIdentifier(except"new") inreuseName. - Update/clean up submodule baselines to match upstream exactly (remove accepted
.diffartifacts). - Add a new compiler test case and baselines covering nested reused object type property-name consistency.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/checker/nodecopy.go | Normalizes reused string-literal property names to identifiers during node reuse, with a special-case for "new". |
| testdata/tests/cases/compiler/declarationEmitStringNamedPropertyConsistency.ts | Adds regression test reproducing inconsistent quoting and asserting consistent identifier emit. |
| testdata/submoduleAccepted.txt | Removes now-unneeded accepted baseline diff entry. |
| testdata/baselines/reference/submoduleAccepted/compiler/escapedReservedCompilerNamedIdentifier.js.diff | Deletes accepted diff file now matching upstream. |
| testdata/baselines/reference/submodule/conformance/jsDeclarationsPackageJson(target=es2015).types.diff | Deletes accepted diff file now matching upstream. |
| testdata/baselines/reference/submodule/conformance/jsDeclarationsPackageJson(target=es2015).types | Updates baseline output to reflect normalized property-name emit. |
| testdata/baselines/reference/submodule/compiler/escapedReservedCompilerNamedIdentifier.js | Updates baseline output to reflect normalized property-name emit. |
| testdata/baselines/reference/compiler/declarationEmitStringNamedPropertyConsistency.* | Adds baselines for the new regression test. |
weswigham
reviewed
May 19, 2026
| @@ -1249,7 +1249,6 @@ compiler/es5ExportEqualsDts(target=es2015).js.diff | |||
| compiler/declarationEmitNameConflicts.js.diff | |||
|
|
|||
| ## Properties with __proto__-like names now quoted in declaration emit (it's quoted in the originating sourcefile) | |||
weswigham
approved these changes
May 19, 2026
Member
weswigham
left a comment
There was a problem hiding this comment.
Honestly, if the user uses a string we should probably respect that (which may have some minor significant for stringy numeric names w.r.t keyof), but this matches strada so 🤷♂️
Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/d6a1d4ec-7a23-4a30-a8ac-03066beec6ad Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
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 #2400
Analysis
In tsgo, when emitting a declaration for a type whose nested object type was reused from a source-position node (via the pseudo-checker /
pseudoTypeToNodepath), property names that the user wrote as string literals were preserved verbatim — even when their text was a valid identifier. Meanwhile, the same property name produced by the freshly-constructedtypeToTypeNodepath (which usescreatePropertyNameNodeForIdentifierOrLiteral) would emit as a plain identifier.This caused inconsistent output like:
Fix
reuseNameininternal/checker/nodecopy.go(only used for property names by the pseudo type node builder) now normalizes a reusedStringLiteralwhose text is a valid identifier into anIdentifier, matching the behavior ofcreatePropertyNameNodeForIdentifierOrLiteral. The name"new"is intentionally excluded so that"new"(): voidon a method signature isn't rewritten into a construct signature — mirroring the existingisMethodNamedNewguard.The result is consistent output, aligned with the TypeScript reference baselines (two existing submodule baselines now match strada exactly, so their
.difffiles were removed).Copilot Checklist
reuseNameto normalize string-literal property names with identifier-valid text"new"to preserve method signaturessubmoduleAccepted.txt