Skip to content

Lack of Intellisense/typing with external components #2774

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

Open
stephenlrandall opened this issue Jun 3, 2025 · 4 comments
Open

Lack of Intellisense/typing with external components #2774

stephenlrandall opened this issue Jun 3, 2025 · 4 comments

Comments

@stephenlrandall
Copy link

Describe the bug

Niche issue I'm sure, but I have a setup with a number of components in an external folder, aliased to $shared. These can be imported and used without issue, but when migrating to Svelte 5, I get warnings for missing declarations on all runes. I also get incorrect type-checking, as illustrated in the reproduction.

I tried modifying my jsconfig.json with:

"include": [
    "src",
    "../shared"
]

but this didn't seem to have any effect.

Reproduction

https://github.com/stephenlrandall/svelte-lang-tools-issue

Expected behaviour

I'd expect to get the same first-class Svelte extension support in the "shared" folder, perhaps by some configuration option that I haven't figured out yet.

System Info

  • OS: macOS 15.5
  • IDE: VS Code 1.100.2
  • Svelte for VS Code: 109.8.1

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

Image Image
@stephenlrandall stephenlrandall added the bug Something isn't working label Jun 3, 2025
@jasonlyu123
Copy link
Member

jasonlyu123 commented Jun 3, 2025

This is because the language server only treats the file as a Svelte 5 component if the file is under a directory with Svelte 5 installed. And this empty shared folder isn't. You can install Svelte 5 and add a jsconfig.json in the shared directory.

@jasonlyu123 jasonlyu123 removed the bug Something isn't working label Jun 3, 2025
@stephenlrandall
Copy link
Author

That doesn't seem to work for me, but it also doesn't sound like a great option -- a user wouldn't need a second copy of Svelte to simply use those files in their project, so why should they need a second copy just for editor support?

Is there a way for the language server's file list to be augmented with files included in a project's jsconfig.json or tsconfig.json? Perhaps this issue should have been labeled as a feature request instead.

@jasonlyu123
Copy link
Member

You'll need to restart the editor after the change for it to work.

There are two parts to the problem: one is Svelte compiler diagnostics, and the other is TypeScript/JavaScript. The svelte compiler part doesn't involve tsconfig/jsconfig.json at all, so I don't think it makes sense to check the svelte version based on tsconfig with this.

a user wouldn't need a second copy of Svelte to simply use those files in their project

If you're sharing these svelte files with two projects, don't you already have two versions? If you didn't reuse these files, why can't you just move these files to the same directory? Or maybe you can try installing Svelte in the repo root. That way, you would only have one Svelte version. If we change the default Svelte version in the future, it might work again, but I don't think we'll change it anytime soon.

@stephenlrandall
Copy link
Author

stephenlrandall commented Jun 4, 2025

@jasonlyu123 You're right, the Svelte diagnostics did start to work after installing Svelte 5 in shared/ and restarting VS Code. I wasn't able to get the typing error to go away, but I'll assume that was a separate configuration issue on my end. I care a lot more about the Svelte Intellisense than the typing anyway.

If you're sharing these svelte files with two projects, don't you already have two versions?

I do -- your suggestion would be that I have three, unless I'm misunderstanding:

project1/
    node_modules
project2/
    node_modules
shared/
    node_modules

And your suggestion makes sense -- if project1/ was using Svelte 4, while project2/ was using Svelte 5, the extension wouldn't otherwise know how to tell if the components in shared/ are Svelte 4 or Svelte 5 files.

Installing Svelte at the root fixes these problems, but introduces a larger one in not being able to selectively update Svelte versions on projects.

If we change the default Svelte version in the future, it might work again, but I don't think we'll change it anytime soon.

Could I ask for a setting then, to assume that all files are Svelte 5 without looking for a version? I'm imagining a scenario like:

project1/
    node_modules (with Svelte 5)
project2/
    node_modules (with Svelte 6)
shared/
    components compatible with both Svelte 5 and 6

As is, the extension wouldn't assume that the contents of shared/ are Svelte 5+, but I don't want to install Svelte globally because project1/ and project2/ are on different versions.

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

No branches or pull requests

2 participants