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

fix: workaround for move to file refactor restriction #2227

Merged
merged 2 commits into from
Dec 12, 2023

Conversation

jasonlyu123
Copy link
Member

@jasonlyu123 jasonlyu123 commented Dec 10, 2023

#2222

When using the move to existing file refactor, TypeScript currently throws a Debug.assert error when any file in the program is not a supported file extension. Working around it by monkey patching the program.getSourceFiles method during the getMoveToRefactoringFileSuggestions function call. Let's hope we can convince the TypeScript team to remove this restriction, and we'll no longer need this workaround.

@jasonlyu123
Copy link
Member Author

jasonlyu123 commented Dec 10, 2023

Find one problem. What if other ts-plugins were returning a new language service and didn't support getProjectVersion? That way, the program object might be updated so that the workaround won't work, and we might also patch the new program with the old getSourceFiles. Might need to find a way to detect that.

@jasonlyu123 jasonlyu123 marked this pull request as draft December 10, 2023 04:48
@jasonlyu123
Copy link
Member Author

Ok. It shouldn't happen. The getSourceFiles function will only be used to check if existing files are updated. So, fewer files here won't change the up-to-date check results. And the "patch the new program with the old getSourceFile" won't happen either because the new program will be a new object. It won't happen if we patch the one stored in a variable.

@jasonlyu123 jasonlyu123 marked this pull request as ready for review December 11, 2023 01:59
@dummdidumm dummdidumm merged commit 3f7f27b into sveltejs:master Dec 12, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants