LSP: file extension changed from `.ts` to `.js` after renaming
Take the following project:
// a.ts
import "./b.ts";
// b.ts
console.log("foo");
// c.ts
import "./a.ts";
- Open this project and VS Code, select file
a.tsin the sidebar and Rename (F2 on Linux). Rename the file tod.ts. - VS Code asks whether I want to let extensions apply fixes. Select yes.
- See the following output:
// d.ts
import "./b.js";
// b.ts
console.log("foo");
// c.ts
import "./d.ts";
This is nearly correct. c.ts was updated correctly, but a.ts was not. The specifiers there were changed from .js to .ts specifiers.
It should have been:
// d.ts
import "./b.ts";
Version: Deno 1.39.2+be888c0
I can't reproduce on release or main. If you move a file within the same dir, the imports in that file shouldn't be touched. When I try moving to a different dir, the extension is correctly preserved.
I can confirm that this is still an issue. Just ran into it a few minutes ago, but I'm unable to narrow it down to a small reproduction case.
Occasionally renaming of the files does flip .ts to .js in imports for me as well.
Are you guys still able to reproduce with other extensions disabled?
I am only able to reproduce this when I have the MDX extension enabled in VS Code.
When I perform the rename VSCode notifies there are two plugins trying to make modifications.
Possibly relevant: https://github.com/mdx-js/mdx-analyzer/blob/16a3240fe083a8a7254201179fc1204a9a260f3d/packages/language-server/index.js#L55
I also have the MDX extension enabled. Is it doing that?
You can try setting "typescript.updateImportsOnFileMove.enabled": "never" to disable Deno's renames, and seeing if it still happens. Unless mdx refers to the same setting..
@marvinhagemeister @king8fisher Do you also have the MDX extension, or something else that could be causing these renames?
@marvinhagemeister Now as you say that I confirm that I do have that extension enabled. Disabling it to see if that helps to narrow down the issue.
This will probably require a setting to disable this on the MDX extension. Closing for now unless there's something we can do to alleviate it from here.