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

[email protected] breaks snippets with arguments typed as an object literal #12137

Closed
lts20050703 opened this issue Jun 22, 2024 · 11 comments
Closed

Comments

@lts20050703
Copy link

lts20050703 commented Jun 22, 2024

Describe the bug

[email protected] breaks snippets with arguments typed as an object literal

Reproduction

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

{#snippet x(obj: {a: string, b: string} )}
{/snippet}

https://www.sveltelab.dev/7y2aelivl6k6jlp

Logs

Type '(this: void, obj: { a: string; b: string; }) => void' is not assignable to type '(this: void, args_0: { a: string; b: string; }) => unique symbol & { _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\""; }'.
  Type 'void' is not assignable to type 'unique symbol & { _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\""; }'.
    Type 'void' is not assignable to type 'unique symbol'.

System Info

System:
    OS: Linux 6.5 KDE neon 6.0 6.0
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 7.72 GB / 15.40 GB
    Container: Yes
    Shell: 3.7.1 - /usr/bin/fish
  Binaries:
    Node: 22.3.0 - ~/.local/share/nvm/v22.3.0/bin/node
    npm: 10.8.1 - ~/.local/share/nvm/v22.3.0/bin/npm
    pnpm: 8.15.3 - ~/.local/share/nvm/v22.3.0/bin/pnpm
    bun: 1.1.10 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 126.1.67.119
  npmPackages:
    svelte: ^5.0.0-next.164 => 5.0.0-next.164

Severity

annoyance

@paoloricciuti
Copy link
Member

You are using the wrong syntax to declare snippers

{@render x()}
-{@snippet x()}
+{#snippet x()}
{/snippet}

@lts20050703
Copy link
Author

Sorry my bad, I have updated the description

@paoloricciuti
Copy link
Member

Sorry my bad, I have updated the description

Yeah but this works fine for me

@lts20050703
Copy link
Author

lts20050703 commented Jun 22, 2024

@paoloricciuti Sorry, I think I have found the actual root cause.

I was using typescript, and for one snippet I decide to make it one argument that's an object, something like this

{#snippet x(obj: {a: string, b: string} )}
{/snippet}

which breaks everything else. When I tried to remove that type anotation (or change the type to something else like Record<string, unknown> or string) the "cannot find name ..." errors go away

I have updated the description.

@lts20050703 lts20050703 changed the title [email protected] breaks using snippets before declaring them. [email protected] breaks snippets with arguments typed as an object literal Jun 22, 2024
@paoloricciuti
Copy link
Member

Should be already fixed in the latest version

@lts20050703
Copy link
Author

Should be already fixed in the latest version

@paoloricciuti Sorry I misunderstood your message a few hours ago. I'm not sure if https://svelte-5-preview.vercel.app is running the latest version, because the code shouldn't work on the latest version (which is [email protected]). Here's the link to the reproduction repl https://www.sveltelab.dev/7y2aelivl6k6jlp

@paoloricciuti
Copy link
Member

Should be already fixed in the latest version

@paoloricciuti Sorry I misunderstood your message a few hours ago. I'm not sure if https://svelte-5-preview.vercel.app is running the latest version, because the code shouldn't work on the latest version (which is [email protected]). Here's the link to the reproduction repl https://www.sveltelab.dev/7y2aelivl6k6jlp

Uh I think I know why!

@paoloricciuti
Copy link
Member

This is actually a problem with the language tools...i'm gonna open a PR there

@lts20050703
Copy link
Author

Thank you!

I have opened sveltejs/language-tools#2411, should I close this issue or keep this open?

@paoloricciuti
Copy link
Member

sveltejs/language-tools#2412

@paoloricciuti
Copy link
Member

@dummdidumm this can be closed too

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

3 participants