Skip to content

Fix renameTo changing shorthand object property keys with ObjectProperty parsers - #753

Open
sebxt wants to merge 1 commit into
meta:mainfrom
sebxt:fix/renameto-shorthand-objectproperty
Open

sebxt wants to merge 1 commit into
meta:mainfrom
sebxt:fix/renameto-shorthand-objectproperty

Conversation

@sebxt

@sebxt sebxt commented Oct 18, 2026

Copy link
Copy Markdown

renameTo expands shorthand properties ({ foo } to { foo: newFoo }) only when the parent node is a Property. The babylon, ts and tsx parsers produce ObjectProperty, so shorthand stayed true and recast printed { newFoo }, which changes the object's key.

This applies the same expansion to ObjectProperty.

Test plan: added a test that parses var foo = 42; var obj = { foo }; with the babylon parser, renames foo, and checks the printed output is var newFoo = 42; var obj = { foo: newFoo };. It fails on main (prints { newFoo }) and passes with the change. yarn test passes. Includes a changeset.

Fixes #752

…rty parsers

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
@changeset-bot

changeset-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 033f1ce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
jscodeshift Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 18, 2026

Copy link
Copy Markdown

@auraseb is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

renameTo changes the key of shorthand object properties with the babylon, ts and tsx parsers

1 participant