Skip to content

Provide better UX when an invalid file is selected for 'move to file' refactoring #54283

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

Closed
mjbvz opened this issue May 16, 2023 · 1 comment · Fixed by #54300
Closed

Provide better UX when an invalid file is selected for 'move to file' refactoring #54283

mjbvz opened this issue May 16, 2023 · 1 comment · Fixed by #54300
Assignees
Labels
Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol Fix Available A PR has been opened for this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented May 16, 2023

Bug Report

🔎 Search Terms

  • refactor
  • refactoring

🕗 Version & Regression Information

5.1.0-dev.20230509

Repo

  1. In VS code with the code:
const a = 1;
  1. Select the entire statement and run the move to file refactoring
  2. Select a invalid destination file (such as a .png)

bug
See the ugly error:

Debug Failure. Error: Debug Failure. at doChange4 (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:136348:36) at /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:136336:77 at Function.with (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:165627:5) at Object.getRefactorEditsToMoveToFile [as getEditsForAction] (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:136336:60) at Object.getEditsForRefactor (/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js:135426:31) at
...

Instead we should show a better message that says something like:

Cannot move to file, selected file is invalid
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 5.1.2 milestone May 17, 2023
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol labels May 17, 2023
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label May 18, 2023
@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol Fix Available A PR has been opened for this issue
Projects
None yet
4 participants