-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Ignore non-ts/js files in move to file refactor #56749
Comments
Thanks for raising this @jasonlyu123! I've only had the two reports of this issue so far, @RyanCavanaugh and @navya9singh, but if there's anything I can do on the plugin side to mitigate this, please let me know! |
I regularly encounter this while using the Astro and MDX extensions in VSCode. Are there any workarounds for this, other than disabling those extensions before running the refactor? |
Need it. I believe this situation will occur frequently in Vue projects. |
Facing same issue on all vue project π€―, TS version 5.x. |
π. I just encountered this issue when using "Move to file" in VSCode with Typescript Version 4.9.5. |
This is quite an annoying problem in Astro |
π Search Terms
move to file, has unknown extension.
β Viability Checklist
β Suggestion
In
getMoveToRefactoringFileSuggestions
, changes to usetryGetExtensionFromPath
to filter candidate files to move to. And ignore the unknown file extension. It would be nice if it could fall back or switch to usingSourceFile.scriptKind
andSourceFile.isDeclarationFile
, but ignoring unknown extensions for at least the candidates should be fine.π Motivating Example
The "Move to file" refactor currently errors if the program contains any source files with a file extension unknown to TypeScript.
Is it possible to remove this restriction? The error is because the
getMoveToRefactoringFileSuggestions
method uses theextensionFromPath
function to find candidates from all the files in the program. If any typescript plugin provides external files with non-ts/js file extension, This will result in aDebug.assert
error. For example, mrmckeb/typescript-plugin-css-modules#241Most of the other language service features don't have this restriction. At least it won't error whenever one external file is in the program. It would be nice if this feature could work with other file extensions. And even allow this feature to be used in other language servers that wrap typescript language service.
π» Use Cases
What do you want to use this for?
Using the move to file refactor in projects where a typescript plugin adds a custom module, like vue and svelte.
Workarounds I can think of
The TypeScript plugins monkey patch
program.getSourceFiles
before calling thegetMoveToRefactoringFileSuggestions
and restoring it afterwards.The text was updated successfully, but these errors were encountered: