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

Language Server: False "Cannot find name" error in nested snippet renders #2664

Closed
scirexs opened this issue Jan 16, 2025 · 0 comments · Fixed by #2668
Closed

Language Server: False "Cannot find name" error in nested snippet renders #2664

scirexs opened this issue Jan 16, 2025 · 0 comments · Fixed by #2668
Labels
bug Something isn't working

Comments

@scirexs
Copy link

scirexs commented Jan 16, 2025

Describe the bug

The language server incorrectly reports "Cannot find name" error when using {@render ...} inside snippet definitions, even though the snippet function is properly defined under specific conditions.

Reproduction

<script module lang="ts">
</script>

<script lang="ts">
  function foo() { console.log("hello") }
</script>

{#snippet test()}
  {@render renderButton()}
{/snippet}

{#snippet renderButton()}
  <button type="button" onclick={foo}>test button</button>
{/snippet}

Image

Expected behaviour

No "Cannot find name" error should be reported for properly defined snippet functions.

Image

System Info

  • OS: Windows 11
  • IDE: VSCode (Ver. 1.96.3)
  • Svelte for VS Code: 109.5.2

Which package is the issue about?

svelte-language-server

Additional Information, eg. Screenshots

I have verified this issue across multiple versions:

  • The error is present in versions 109.5.2 and 109.5.0
  • The error does not exist in version 109.4.0. The Expected behaviour screenshot was taken using this version.

The error can be eliminated by either:

  • Removing the onclick={foo} handler
  • Removing the <script module lang="ts"></script> tag

Additionally, {@render renderButton()} functions correctly when used outside of snippet definitions.

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

Successfully merging a pull request may close this issue.

1 participant