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

bugfix: correctly auto fix when there are multiple export specifiers #13

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

kazushisan
Copy link
Contributor

This PR will fix the behavior of ts-remove-unused's auto-fix when there are multiple export specifiers that need to be removed

const d = 'd';
const unused = 'unused';
const unused2 = 'unused2';
export { d, unused, unused2 };

Cause

ts-remove-unused calculates the necessary text change ranges using the same ts.SourceFile obtained at the beginning of the modification. For most cases this is sufficient however when there are multiple export specifiers, the text change range conflicts with each other. For such case, I've added a step to abort getTextChanges and update ts.SourceFile in the language service before continuing with the modification

@kazushisan kazushisan self-assigned this Sep 10, 2024
@kazushisan kazushisan added the bug Something isn't working label Sep 10, 2024
@kazushisan kazushisan merged commit 16fc7ea into main Sep 11, 2024
1 check passed
@kazushisan kazushisan deleted the fix/multiple-export-specifier branch September 11, 2024 05:56
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

Successfully merging this pull request may close these issues.

1 participant