Skip to content

feat: Variadic snippets #9987

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversation

elliott-with-the-longest-name-on-github
Copy link
Contributor

Svelte 5 rewrite

This would close #9672, assuming we want it. I kind of like it!

This allows snippets to have multiple arguments in the type system. For example, you could type a component expecting a two-argument snippet as:

<script lang="ts">
  let {
    message,
    card
  } = $props<{
    message: string;
    card: Snippet<[message: string, darkMode: boolean]>;
  }>(); 
</script>

{@render card(message, false)}

It would also enable truly variadic snippets:

type MySnippet = Snippet<string[]>;

would be renderable as:

{@render snippet('as', 'many', 'strings', 'as', 'i', 'want')}

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Dec 22, 2023

🦋 Changeset detected

Latest commit: 9b01999

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 22, 2023

@tcc-sejohnson is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

@elliott-with-the-longest-name-on-github
Copy link
Contributor Author

oops, this was supposed to be a draft. It's obviously not ready, lol

Copy link

vercel bot commented Dec 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
svelte-5-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 22, 2023 9:26pm

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Svelte 5: Variadic snippets
1 participant