Fix merging auto-imports with existing import statements #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wasn't able to come up with a way to get
tsserver
to produce merged imports itself, but this should fix #1.An unfortunate side effect of the intermediary transformed modules we use in
@glint/tsserver-plugin
means that from TypeScript's perspective, there's never an existing import for the non-transformed module to merge with, and the logic that generates import completions is completely private within the TypeScript codebase, so we can't reuse it.Having to maintain this code ourselves would be one point in favor of using a separate file extension + standalone language server for files with embedded templates, but it's not clear that outweighs all the other advantages we get from the current approach. The whole "
tsserver
plugin vs standalone language server" issue is likely worth a writeup on its own to capture the tradeoffs inherent in each approach.