You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rename symbol on a HTML tag inside of JSX globally renames all tags #7458
Open a project that uses TypeScript + JSX (with react.d.ts loaded)
Put the cursor over a common HTML tag like <div>
Hit F2 to rename symbol
Rename the div to something else (like span)
Expected: Just the matching open/close is renamed to <span>
Actual: Every div in every JSX file is now a span and even react.d.ts has had its div attribute in the HTML tag names renamed to span
This is entirely by design. The element name in a JSX expression is class/interface/function name, and renaming it renames all references to that class/interface/function, just as it would for any other symbol.
If the expectation is that we would only update the open/close tag, then that is a new feature, and not the current rename operation.
I think we need a general approach here. may not change anything "outside" your project. for instance any symbol from a .d.ts from a node package, or a Typings (@typings) folder.
Yeah this is a hard problem, I think the expected behavior is a simple tag rename in the JSX markup, but that's only because of how easy it is to fall into expecting HTML language service semantics out of a JSX file.
The reason this was particularly painful in VS Code is that it edits a ton of files with a bad change and Edit -> Undo only reverted it in the currently opened document, leaving it up to the user to manually revert many unexpected edits (hope you committed your changes recently.)
Activity
billti commentedon Mar 10, 2016
This is entirely by design. The element name in a JSX expression is class/interface/function name, and renaming it renames all references to that class/interface/function, just as it would for any other symbol.
If the expectation is that we would only update the open/close tag, then that is a new feature, and not the current
renameoperation.RyanCavanaugh commentedon Mar 10, 2016
At a minimum we should block the operation when the tag name is sourced in
IntrinsicElementsmhegazy commentedon Mar 10, 2016
I think we need a general approach here. may not change anything "outside" your project. for instance any symbol from a .d.ts from a node package, or a Typings (@typings) folder.
xirzec commentedon Mar 10, 2016
Yeah this is a hard problem, I think the expected behavior is a simple tag rename in the JSX markup, but that's only because of how easy it is to fall into expecting HTML language service semantics out of a JSX file.
The reason this was particularly painful in VS Code is that it edits a ton of files with a bad change and Edit -> Undo only reverted it in the currently opened document, leaving it up to the user to manually revert many unexpected edits (hope you committed your changes recently.)
Jack-Works commentedon Apr 17, 2020
is this fixed by #28066?
GMaiolo commentedon Nov 30, 2021
Is there news about this or a workaround?
WilsonNet commentedon Aug 30, 2022
I just discovered this bug today in the worst way possible.