Skip to content

Can't pass strings to typed Svelte components after upgrading to @astrojs/svelte 7.2.3 #15040

@Nickersoft

Description

@Nickersoft

Astro Info

Astro                    v5.16.6
Node                     v20.19.0
System                   macOS (arm64)
Package Manager          bun
Output                   static
Adapter                  @astrojs/vercel
Integrations             @astrojs/svelte
                         @astrojs/mdx
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Since updating to @astro/svelte 7.2.3, astro check now produces a sea of errors in every place I am passing a raw string to my components (like this: <Example>Test</Example>). Every error looks something like:

Text in JSX has the type 'string', but the expected type of 'children' is 'Snippet<[]> | undefined'.

This only happens when I declare a Props type in my component and use it to type my props, like this:

<script lang="ts">
interface Props {
  children: Snippet<[]>
}

const { children }: Props = $props();
</script>

I imagine there may be an issue with how Astro is passing children to Svelte components, as all children in Svelte components are inherently Snippets so a framework like SvelteKit would never complain about this.

What's the expected result?

I'd expect Astro to resolve the types correctly and not produce errors, as it did before

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-7uehawcs

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: svelteRelated to Svelte (scope)regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions