Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect variable renaming when two default exports in a file #57754

Closed
ahkhanjani opened this issue Mar 12, 2024 · 3 comments
Closed

Incorrect variable renaming when two default exports in a file #57754

ahkhanjani opened this issue Mar 12, 2024 · 3 comments
Labels
Not a Defect This behavior is one of several equally-correct options

Comments

@ahkhanjani
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.87.2 (user setup)
  • OS Version: Windows_NT x64 10.0.22631

I accidentally came across this bug. Although this is not valid JavaScript code but the way VS Code handles it is unexpected.

Steps to Reproduce:

  1. Create a .js/.ts file.
  2. Create two functions with distinct names, both with default export.
export default function a() {}
export default function b() {}
  1. Go to the second function and globally rename it using F2.

Instead of the function we were trying to rename, the first default export gets renamed.

@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 12, 2024
@mjbvz mjbvz removed their assignment Mar 12, 2024
@mjbvz
Copy link
Contributor

mjbvz commented Mar 12, 2024

The code is invalid so I'm not sure there is a correct behavior for rename. In TS or with JS error reporting, you'll see

Image

@RyanCavanaugh RyanCavanaugh added the Not a Defect This behavior is one of several equally-correct options label Mar 12, 2024
@ahkhanjani
Copy link
Author

The code is invalid so I'm not sure there is a correct behavior for rename. In TS or with JS error reporting, you'll see

Yes. I just found it a bit strange. I would expect it to at least error with something like this:

Screenshot 2024-03-13 005934

Or... perhaps rename the actual function?

@typescript-bot
Copy link
Collaborator

This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a Defect This behavior is one of several equally-correct options
Projects
None yet
Development

No branches or pull requests

4 participants