Skip to content

fix(language-server): rewrite Astro component auto-import names#15908

Open
FelmonFekadu wants to merge 5 commits intowithastro:mainfrom
FelmonFekadu:fix/image-import-conflict-language-tools
Open

fix(language-server): rewrite Astro component auto-import names#15908
FelmonFekadu wants to merge 5 commits intowithastro:mainfrom
FelmonFekadu:fix/image-import-conflict-language-tools

Conversation

@FelmonFekadu
Copy link

@FelmonFekadu FelmonFekadu commented Mar 13, 2026

Summary

  • keep generated AstroComponent suffixes in the internal TSX output used by the language server
  • rewrite .astro auto-import completion labels and resolved import edits back to the expected component name
  • add regression coverage for the .astro auto-import completion path and the shared import-text rewrite helpers

Fixes #14683.

Testing

  • pnpm -C packages/language-tools/language-server build
  • pnpm -C packages/language-tools/ts-plugin build
  • pnpm -C packages/language-tools/language-server exec astro-scripts test "test/{typescript/completions.test.ts,typescript/diagnostics.test.ts,units/utils.test.ts}" --teardown-test ./test/misc/teardown.ts --tsx true --setup ./test/setup.js
  • pnpm -C packages/language-tools/language-server test (fails locally in existing AstroCheck fixture tests because @astrojs/svelte and @astrojs/vue are not installed in this environment; the TypeScript/completion suites above pass)

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: ddf73d3

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the proper way to do it, because changing the component name will cause auto import to return something unexpected. Instead, we should always return the AstroComponent suffixes, but patch auto-import to not add it. You can use the Vue language-tools as reference, IIRC they still do it.

@FelmonFekadu
Copy link
Author

Implemented the rework you asked for.

This keeps the generated AstroComponent suffixes in the internal TSX output and rewrites the language-server .astro auto-import completion labels plus resolved import edits back to the expected component name instead.

I also dropped the ts-plugin-side rename and updated the language-server coverage around the completion path.

@FelmonFekadu FelmonFekadu changed the title fix(language-tools): avoid Image component name collisions fix(language-server): rewrite Astro component auto-import names Mar 14, 2026
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.

Bug: experimental assets: Import declaration conflicts with local declaration of 'Image'.

2 participants