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

Cannot find name 'svelteHTML' / Cannot find name '__sveltets_2_any', .... #2584

Closed
mysolo opened this issue Nov 13, 2024 · 22 comments
Closed
Labels
awaiting submitter bug Something isn't working

Comments

@mysolo
Copy link

mysolo commented Nov 13, 2024

Describe the bug

bug on a version 109.2.2 , 109.2.1.
no bug on a version 109.2.0

use "svelte": "3.52.0" in a project.

VSCode return a multiple error on a

=> Cannot find name 'svelteHTML' on a each => Cannot find name '__sveltets_2_ensureArray' on a component => Cannot find name '__sveltets_2_any'

etc...

Reproduction

simple

Screenshot 2024-11-13 at 15 59 21 Screenshot 2024-11-13 at 15 59 29

Expected behaviour

No error on a code

System Info

  • OS: Mac os X
  • IDE: VSCode Version: 1.95.2
  • Svelte for VS Code v109.2.2

Which package is the issue about?

Svelte for VS Code extension, svelte-language-server

Additional Information, eg. Screenshots

No response

@mysolo mysolo added the bug Something isn't working label Nov 13, 2024
@dummdidumm
Copy link
Member

I am unable to reproduce this. Please provide a reproduction repository.

@mysolo
Copy link
Author

mysolo commented Nov 14, 2024

[email protected]:mysolo/vsc-svelte-debug.git

I replace version for svelte/sveltekit/typescript.

clone repos
cd repos
vsc .

open page.svelte

@anders-hard
Copy link

anders-hard commented Nov 15, 2024

I also got this after some VSCode upgrade(?) sometime over the last week.
OSX, Svelte 4.0.5, cursor 0.42.5, VSCode 1.93.1, Svelte for VSCode 109.2.2

image

@dummdidumm
Copy link
Member

dummdidumm commented Nov 15, 2024

I am unable to reproduce this. Wondering if this is OS-dependent; I'm on Windows.

I suspect this came in as a result of #2561. Can you check

  • whether or not there's a .svelte2tsx-language-server-files folder inside your node_modules?
  • if yes what files does it contain?
  • if yes what are the file contents? (they should not be empty)

@anders-hard
Copy link

Yes, I have three files. The svelte-html.d.ts is empty, the others are not.

image

@anders-hard
Copy link

I managed to get rid of the error by removing the node_modules folder, upgrading svelte and re-installing node modules. That removes the svelte-html.d.ts file (it would re-create if I deleted it before).

dummdidumm added a commit that referenced this issue Nov 15, 2024
- throw an error if writing didn't work (ts doesn't throw itself)
- fix html path logic

#2584
@dummdidumm
Copy link
Member

I was able to reproduce this for the early Svelte 4 versions and fixed the bug related to that. Still not able to reproduce this for Svelte 3, but added some extra checks. @mysolo could you try with the latest version of the extension?

@mysolo
Copy link
Author

mysolo commented Nov 15, 2024

@mysolo could you try with the latest version of the extension?

I still have the problem with version 109.2.3

@mysolo
Copy link
Author

mysolo commented Nov 15, 2024

I am unable to reproduce this. Wondering if this is OS-dependent; I'm on Windows.

I suspect this came in as a result of #2561. Can you check

* whether or not there's a `.svelte2tsx-language-server-files` folder inside your `node_modules`?

yes

* if yes what files does it contain?

ls -al node_modules/.svelte2tsx-language-server-files git:(feat/posthog|…12⚑13
total 168
drwxr-xr-x 5 mysolo staff 160 Nov 9 01:39 .
drwxr-xr-x 82 mysolo staff 2624 Nov 9 01:39 ..
-rw-r--r-- 1 mysolo staff 64575 Nov 15 15:29 svelte-jsx.d.ts
-rw-r--r-- 1 mysolo staff 964 Nov 9 01:39 svelte-native-jsx.d.ts
-rw-r--r-- 1 mysolo staff 14526 Nov 15 15:29 svelte-shims.d.ts

* if yes what are the file contents? (they should _not_ be empty)

they not be empty

@dummdidumm
Copy link
Member

This is truly strange. This means they are properly copied over into the hidden folder, but then not actually loaded or picked up, for whatever reason. I'm not sure how to investigate this further. @jasonlyu123 do you have any ideas how to help @mysolo debug this / any ideas why this could happen?

@dummdidumm
Copy link
Member

@reskume mentioned this happens on case sensitive file systems, which may hint at what the problem is

@jasonlyu123
Copy link
Member

So it might be something to do with inconsistent case sensitivity handling. Is the extension installed in the case-insensitive part of the system, while the project directory is in the case-sensitive part? But why is the write file work but read file doesn't? And why isn't that affecting normal files in the project?

@mysolo, can you confirm if you formatted part of your file system as case-sensitive? Though we are still not sure how this happened at least we can confirm if it's the same issue.

@mysolo
Copy link
Author

mysolo commented Nov 17, 2024

@mysolo, can you confirm if you formatted part of your file system as case-sensitive? Though we are still not sure how this happened at least we can confirm if it's the same issue.

yes, all my dev projects are on a case-sensitive partition. Applications are on the standard os x partition.

dummdidumm pushed a commit that referenced this issue Nov 20, 2024
#2584

Use original casing here: people could have their VS Code extensions in a case insensitive folder but their project in a case sensitive one; and if we copy the shims into the case sensitive part it would break when canonicalizing it.
@dummdidumm
Copy link
Member

@mysolo / @reskume can you check if this still happens with the latest version of the extension?

@reskume
Copy link

reskume commented Nov 22, 2024 via email

@mysolo
Copy link
Author

mysolo commented Nov 23, 2024

it's ok for me :)

@Alex6357
Copy link

Alex6357 commented Jan 16, 2025

I still encountered this issue with extension v109.5.2, but it was resolved after restarting VSCode. Just a report.

Image

These files are not empty.

@blaine
Copy link

blaine commented Jan 21, 2025

I've also seen this issue intermittently. Restarting the Svelte language server seems to resolve the issue, but it seems to creep back. I've only noticed this in a svelte 5 project, not in my legacy svelte 4 projects.

@Oliver-Piorun
Copy link

Oliver-Piorun commented Jan 25, 2025

Can confirm. The issue still exists 👍

Context:

  • Svelte 5 project
  • The files visible on @Alex6357 screenshot are also present in my node_modules folder
  • Extension version: 109.5.2

@dummdidumm
Copy link
Member

Please provide a reproduction repository along with steps how to reproduce

@Oliver-Piorun
Copy link

Oliver-Piorun commented Jan 25, 2025

So today:

  • Opened the project -> No error
  • Deleted the node_modules folder and the pnpm-lock.yaml file
  • Ran pnpm install
  • Navigated to a *.svelte file
  • Mentioned error is back again
    • The .svelte2tsx-language-service-files folder is missing

-> Restarting the Svelte LSP fixed this particular issue. It kicked in and created the mentioned folder.

^ Is this by design? If yes: I would love to not having to restart the LSP/VSCode when performing the listed steps.

I am not sure if this issue is related to the ones we observed in the past because the relevant folder was definitely present while the errors were displayed.

Thanks for your help 😊

@jasonlyu123
Copy link
Member

I would recommend you always close the editor before deleting and reinstalling. There are all sorts of things that might get cached in different extensions. If you're reinstalling you obviously don't want some cache not being invalidated. It also doesn't make sense to trigger lots of file-watcher events in a short time reflecting changes that might be a total waste of time and might even slow down the reinstalling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants