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

Snippet cannot access variables from script tag #2660

Open
f-elix opened this issue Jan 10, 2025 · 0 comments
Open

Snippet cannot access variables from script tag #2660

f-elix opened this issue Jan 10, 2025 · 0 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@f-elix
Copy link

f-elix commented Jan 10, 2025

Describe the bug

A cannot find name '<variable-name>' error occurs in this very specific situation:

  • A component snippet uses a variable declared in the script tag.
  • The variable has to be declared in a destructured object (or $props()).
  • There has to be a module script in the component, empty or not.

The error only shows up when running svelte-check, not in my IDE.

I was able to pinpoint the faulty version: svelte-check 4.1.2 and above. No error occurs at 4.1.1

Reproduction

You can take a look at the SnippetError.svelte component here. Run npm run check to see the error.

https://stackblitz.com/edit/sveltejs-kit-template-default-651yg3ua?description=The%20default%20SvelteKit%20template,%20generated%20with%20create-svelte&file=package.json,src/routes/+page.svelte,src/lib/SnippetError.svelte,svelte.config.js&title=SvelteKit%20Default%20Template

Expected behaviour

Snippets should be able to access all variables declared in the script tag.

System Info

  • OS: Macosx
  • IDE: VSCode (via Cursor)

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

No response

@f-elix f-elix added the bug Something isn't working label Jan 10, 2025
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants