withastro / language-tools

Language tools for Astro
MIT License
270 stars 54 forks source link

🐛 BUG: losing intellisense on typescript imports inside .astro files until editor reload #958

Open lee-arnold opened 1 month ago

lee-arnold commented 1 month ago

Describe the Bug

MacOS VS Code extension: 2.14.2 Npm: 10.8.3 Node: 22.9.0 VS Code: 1.93.1

Intelisense in frontmatter imports doesn't seem to be working as expected when dealing with new typescript files. Sometimes I can get it to work for the first instance of a file, but then it fails to import any other files. Either way, reloading the editor after creating any new files fixes the issue.

Steps to Reproduce

  1. npm create astro@latest (4.15.9 as of today)
  2. open the project in vscode
  3. create anything.ts with the contents export const anything = "anything";
  4. create another.ts with the contents export const another = "another";
  5. open index.astro and try to import the exported const.
  6. while typing import anyt... I would expect the import to be listed at the top of the autocomplete list, however it does not appear there.
  7. reload the vscode window and the imports now appear on the autocomplete list

Link to Minimal Reproducible Example

https://github.com/lee-arnold/astro-issue-example

Princesseuh commented 1 month ago

Everything works as expected for me when following your instructions:

https://github.com/user-attachments/assets/abb57f4e-2d48-46ac-b2f5-28f36d43f34e

I'm not sure how to debug this further.

lee-arnold commented 1 month ago

Hey, thanks for the response. Can I ask what OS and versions you're using? I haven't had a chance to test any others yet.

Princesseuh commented 1 month ago

This is on macOS, 2.14.2 of the Astro extension, VS Code 1.93.1.

Arttii commented 1 month ago

I am having this same problem, but on Ubuntu 22.04 with VS Code 1.92.1

lee-arnold commented 3 weeks ago

I've noticed with further use that it also fails to recognise new exported functions in files that already existed, again resolved by restarting the language server.