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

VS Code auto imports don't work with newly created files #21558

Closed
josh-collinsworth opened this issue Dec 13, 2023 · 3 comments · Fixed by #21852
Closed

VS Code auto imports don't work with newly created files #21558

josh-collinsworth opened this issue Dec 13, 2023 · 3 comments · Fixed by #21852
Assignees
Labels
bug Something isn't working correctly lsp related to the language server

Comments

@josh-collinsworth
Copy link

josh-collinsworth commented Dec 13, 2023

Version: Deno 1.38.5 / Fresh 1.5.1

Steps to recreate:

  1. Create a new valid component file, e.g., MyNewComponent.tsx.
  2. Start adding that component to your code (not as an import; begin typing the name of the component so that the auto-complete window pops up)
  3. When you see your component, hit enter or click it to auto-complete

Result:

VS code only completes the name of the component; it doesn't add it as an import, as it would if you were importing an existing component.

CleanShot 2023-12-13 at 10 10 31

However, VS Code will automatically import the component if you close and re-open the project. Then the import is auto-added to the top of the file, as it should be, and as expected:

CleanShot 2023-12-13 at 10 17 58

This makes me think the auto-completion must not scan continuously for new components, and instead, maybe only scans once at the start of the project. (Or, perhaps, does so at irregular enough intervals that newly created components are not included.)

Ideally, it would be optimal for developer experience to have all files available for auto-import/complete.

[EDIT]: While adding a new component reliably triggers this behavior, I've also encountered it when the component already existed, too. In both cases, closing and reopening the project fixes the issue. But it's odd because in both cases, VS Code still shows the file and the path, and you can still select them; it's just that the import list is not updated in any way.

@littledivy littledivy added bug Something isn't working correctly lsp related to the language server labels Dec 14, 2023
@bartlomieju
Copy link
Member

@nayeemrmn does #21564 cover this one?

@nayeemrmn
Copy link
Collaborator

does #21564 cover this one?

I don't think so. @josh-collinsworth Is there anything printed in the output panel when this happens?

@josh-collinsworth
Copy link
Author

@nayeemrmn I see this:

Unable to get completion info from TypeScript: Error: Debug Failure. Some exportInfo should match the specified exportMapKey
    at Object.getImportCompletionAction (ext:deno_tsc/00_typescript.js:149303:13)
    at getCompletionEntryCodeActionsAndSourceDisplay (ext:deno_tsc/00_typescript.js:158366:64)
    at Object.getCompletionEntryDetails (ext:deno_tsc/00_typescript.js:158229:48)
    at Object.getCompletionEntryDetails2 [as getCompletionEntryDetails] (ext:deno_tsc/00_typescript.js:142313:37)
    at serverRequest (ext:deno_tsc/99_main_compiler.js:1035:53)
    at [ext:cli/lsp/tsc.rs:4451:26]:1:12

FWIW, this error also pops up a ton, but going solely by appearances, I don't think it's related:

Could not set npm package requirements. Error getting response at https://registry.npmjs.org/pixelmatch for package "pixelmatch": An npm specifier not found in cache: "pixelmatch", --cached-only is specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly lsp related to the language server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants