Skip to content

Normalize reused string-literal property names to identifiers in declaration emit#3965

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-property-names-quoting
Draft

Normalize reused string-literal property names to identifiers in declaration emit#3965
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-property-names-quoting

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

Declaration emit produced inconsistent property-name quoting when a nested object type was reused from source: top-level properties (rebuilt via typeToTypeNode) emitted as identifiers, while nested properties (reused via pseudoTypeToNode) preserved the user's string-literal form even when the text was a valid identifier.

export const platformSlice = createSlice({
    "query": { "search": "", "user": "" },
});

// Before
export declare const platformSlice: {
    query: {
        "search": string;
        "user": string;
    };
};

// After
export declare const platformSlice: {
    query: {
        search: string;
        user: string;
    };
};

Changes

  • internal/checker/nodecopy.goreuseName now normalizes a reused StringLiteral whose text is a valid identifier into an Identifier, matching createPropertyNameNodeForIdentifierOrLiteral used on the fresh-construction path. The name "new" is excluded so reused "new"(): void method signatures aren't rewritten into construct signatures (mirroring the existing isMethodNamedNew guard).
  • Baselines — Two existing submodule baselines (escapedReservedCompilerNamedIdentifier.js, jsDeclarationsPackageJson(target=es2015).types) now match strada exactly; their .diff files and the corresponding submoduleAccepted.txt entry were removed.
  • New testtestdata/tests/cases/compiler/declarationEmitStringNamedPropertyConsistency.ts covers the reported repro.

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
Copilot AI requested a review from jakebailey May 18, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Property names are quoted one level deep in inferred type

3 participants