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

Intellisense for never before imported libraries doesnt work #2193

Closed
EldinHb opened this issue Nov 5, 2023 · 7 comments
Closed

Intellisense for never before imported libraries doesnt work #2193

EldinHb opened this issue Nov 5, 2023 · 7 comments
Labels
feature request New feature or request Fixed Fixed in master branch. Pending production release.

Comments

@EldinHb
Copy link

EldinHb commented Nov 5, 2023

Describe the bug

When you install a Svelte library and then try to use a Svelte component in any .svelte file the intellisense cant find the library. When you add import {} from 'library'; in any other file intellisense is able to find any component of said library.

Screenshots with https://tabler.io/docs/icons/svelte as the library. Could also reproduce with https://www.skeleton.dev/.

No intellisense for any icon.
image

Intellisense works with import {} from '@tabler/icons-svelte'; in same file.
image

Intellisense works with import {} from '@tabler/icons-svelte'; in another unused .svelte file.
image

Reproduction

Create new sveltekit project.

Pick empty project with typescript and no other libraries.

Install https://tabler.io/docs/icons/svelte

See the screenshots in the above description.

Expected behaviour

Intellisense to work with never before imported libraries.

System Info

  • OS: macOS
  • IDE: vscode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

@EldinHb EldinHb added the bug Something isn't working label Nov 5, 2023
@jasonlyu123 jasonlyu123 added feature request New feature or request and removed bug Something isn't working labels Nov 6, 2023
@jasonlyu123
Copy link
Member

This is expected because the type definition is only loaded if there is an import to it. Loading arbitrary d.ts files from node_modules might cause some performance problems. In TypeScript projects, the auto-import also behaves like this.

But in the js projects, the automatic type acquisition will also discover some of the direct dependencies in a child process. This is a feature that we didn't support, so I am marking this issue as a feature request instead of a bug.

@EldinHb
Copy link
Author

EldinHb commented Nov 6, 2023

Do you mean in regular typescript projects that aren't svelte projects? I've never seen this in regular typescript projects or react projects. It works smoothly and I haven't seen performance issues in those projects.

@jasonlyu123
Copy link
Member

Yes. It's the same. I tried in a ts file in a plain typescript project with only a tsconfig and in a SvelteKit project. They both don't provide auto-import for newly installed packages.

js projects, i.e. those without tsconfig.json or those with a jsconfig.json. Those are provided by automatic type acquisition running in another process. And we don't support that.

@EldinHb
Copy link
Author

EldinHb commented Nov 6, 2023

Thats weird because I dont experience the same in projects/files that dont use the Svelte LSP. Both are newly created with freshly installed packages.

image
image

Edit:

It also works in .ts files in a sveltekit project. The only place it doesnt work is in .svelte files.
image

@jasonlyu123
Copy link
Member

Hmm. That's weird. That's different from what I saw in both Windows and Ubuntu WSL. Maybe you have some extension or config that changes the default behaviour?

@jasonlyu123
Copy link
Member

Ah. Found it. It's https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#smarter-auto-imports. From the implementation notes. devDependencies is excluded from this discovery. That's why I kept not getting it. This is indeed not provided by automatic type acquisition. But unfortunately, this is a TypeScript internal API, and it's not something we can switch on easily. It's still a feature request that needs quite some work to enable.

@EldinHb
Copy link
Author

EldinHb commented Nov 6, 2023

Glad you found it! Luckily the "workaround" is fairly simple and it has little impact on our project as a whole.

dummdidumm pushed a commit that referenced this issue Jan 11, 2024
Add `typescript-auto-import-cache` to more cache auto imports more reliably
#2232
#2193
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

3 participants