Skip to content

F2/Renaming a .ts file to a .svelte.ts does not update imports in VS Code #2734

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

Open
newsve opened this issue Apr 8, 2025 · 5 comments
Open
Labels
bug Something isn't working

Comments

@newsve
Copy link

newsve commented Apr 8, 2025

Describe the bug

Updating myImport.ts to myImport.svelte.ts, should update all imports of myImport.ts in other files (either by prompting or automatically depending on your VS Code settings).

Reproduction

Rename any .ts file to a .svelte.ts file and watch how imports get ignored.

If you uninstall the VS Code Svelte plugin you get at least the imports of your renamed file in the .ts files but not in the .svelte files updated.

Expected behaviour

Updating all imports.

System Info

VS Code 1.98.2 on Ubuntu

Plugins installed:
(TS-plugin is enabled)

Image

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

@newsve newsve added the bug Something isn't working label Apr 8, 2025
@jasonlyu123
Copy link
Member

The update-import functions are split between the TypeScript and Svelte extensions to avoid duplicate edits. When there is a duplicated edit between TypeScript and the Svelte extension, it might cause a race condition and break the code. I think what happens in your case is that you haven't opened any Svelte files, so the Svelte extension hasn't started yet. That is why it is missing part of the functionality. Can you check if it works after you opened a svelte files?

@newsve
Copy link
Author

newsve commented Apr 9, 2025

Interesting idea, so I've just tried:

Image

  • Closed all open files in VS Code
  • Closed VS Code
  • Restarted VS Code
  • Opened a .svelte file
  • Opened a .svelte.ts file
  • Clicked on a .ts file in the explorer pane
  • Pressed F2
  • Changed name to .svelte.ts

Still the same, just that .ts file got renamed (I checked the git tab), no prompt no nothing.

FWIW, tried the same in Cursor with the same outcome.

If you have more ideas let me know, happy to try more!

Edit: BTW, this has worked flawlessly on March 19, where a renaming affected 9 files. I would have reported it then already if it hadn't worked then.

@jasonlyu123
Copy link
Member

There is a separate config svelte.plugin.svelte.rename.enable for the Svelte extension part. Can you check if it's enabled? If it's, can you check if this happens to specific files or all the files?

@newsve
Copy link
Author

newsve commented Apr 9, 2025

It's enabled:

Image

If it's, can you check if this happens to specific files or all the files?

Now, it is getting weird, I redid the entire process above but change another .ts file's (let's call it b.ts) name to .svelte.ts in the same folder.

This time, while VS Code didn't prompt, at least it opened all affected files and changed their imports properly and left the file unsaved/dirty.

Now, I did the same for the og file (let's call it a.ts) and it worked there too.

Since, I couldn't believe my eyes, I tried close VS Code, redid everything and got the same result, I got unsaved files with all affected imports.

Now, I tried this a third time but again with the og file a.ts first and it worked too.

Totally confused...

@newsve
Copy link
Author

newsve commented Apr 11, 2025

Update: It is definitely not about if a .svelte or .svelte.ts file is open, it feels rather erratically.

I just had open 14 files, all kind of files, many .svelte and many .svelte.ts.

I renamed one .ts file to a .svelte.ts file which affects imports in three more files. Nothing had happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants