Skip to content

Fix identifier unicode escaping for parameter props#3188

Open
jakebailey wants to merge 1 commit intomainfrom
jabaile/fix-id-escaping
Open

Fix identifier unicode escaping for parameter props#3188
jakebailey wants to merge 1 commit intomainfrom
jabaile/fix-id-escaping

Conversation

@jakebailey
Copy link
Member

The original code was:

        // TODO(rbuckton): Does this need to be parented?
        const propertyName = setParent(setTextRange(factory.cloneNode(name), name), name.parent);
        setEmitFlags(propertyName, EmitFlags.NoComments | EmitFlags.NoSourceMap);

        // TODO(rbuckton): Does this need to be parented?
        const localName = setParent(setTextRange(factory.cloneNode(name), name), name.parent);
        setEmitFlags(localName, EmitFlags.NoComments);

To answer the TODO... yes, apparently.

Copilot AI review requested due to automatic review settings March 21, 2026 17:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a codegen discrepancy in the TypeScript runtime-syntax transformer where cloned identifier nodes for parameter properties lost their parent pointers, causing the printer to emit normalized identifier text instead of preserving original unicode escape sequences.

Changes:

  • Set Parent on cloned propertyName/localName identifiers emitted for parameter-property constructor assignments.
  • Update the escapedIdentifiers reference baseline to reflect preserved unicode escapes in this.<prop> = <param> assignments.
  • Remove the now-unnecessary escapedIdentifiers.js.diff baseline diff file.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/transformers/tstransforms/runtimesyntax.go Ensures cloned parameter-property identifiers are parented so the printer can recover escaped source text.
testdata/baselines/reference/submodule/compiler/escapedIdentifiers.js Updates expected emit output to keep unicode escapes for parameter-property assignments.
testdata/baselines/reference/submodule/compiler/escapedIdentifiers.js.diff Removes the diff baseline since the outputs now match.

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.

2 participants