Skip to content

fix: svelte 5 prop types#14934

Merged
florian-lefebvre merged 6 commits intowithastro:mainfrom
antonyfaris:fix/svelte-5-prop-types
Dec 5, 2025
Merged

fix: svelte 5 prop types#14934
florian-lefebvre merged 6 commits intowithastro:mainfrom
antonyfaris:fix/svelte-5-prop-types

Conversation

@antonyfaris
Copy link
Member

I'm not sure if this is the best way of solving this but it works when I tested it on vscode and with the cli 😅

Changes

Fixes the prop types for Svelte components inside Astro. Fixes #14681

Before

  • props-b-1

After

  • props-a-1
  • props-a-2

Testing

Added a new test to check the props type. I'm not sure if they are in the correct place.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Nov 30, 2025

🦋 Changeset detected

Latest commit: 217cdb0

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

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

@github-actions github-actions bot added pkg: svelte Related to Svelte (scope) pkg: integration Related to any renderer integration (scope) labels Nov 30, 2025
Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last thing and we're good to go!

Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@florian-lefebvre florian-lefebvre merged commit 4264a36 into withastro:main Dec 5, 2025
24 of 25 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Dec 5, 2025
@mikepayne02
Copy link

After updating from 7.2.2 to 7.2.3 of the svelte integration, I'm getting type errors on Svelte components whenever I add a client directive to them:

---
export const prerender = false

import BaseLayout from '@/layouts/Base.astro'
import ContactForm from '@/components/ContactForm.svelte'
---

<BaseLayout meta={{ title: 'Contact', description: 'Message me' }}>
  <ContactForm client:load />
</BaseLayout>
src/pages/contact.astro:9:4 - error ts(2322): Type '{ "client:load": true; }' is not assignable to type 'IntrinsicAttributes & Record<string, never>'.
  Type '{ "client:load": true; }' is not assignable to type 'Record<string, never>'.
    Property 'client:load' is incompatible with index signature.
      Type 'true' is not assignable to type 'never'.

9   <ContactForm client:load />
     ~~~~~~~~~~~

@florian-lefebvre
Copy link
Member

@Princesseuh what do you think? Should we try keep this approach and fix it, or revert?

@Princesseuh
Copy link
Member

It's okay like this!

@florian-lefebvre
Copy link
Member

@mikepayne02 can you open a new issue? Thank you

@antonyfaris
Copy link
Member Author

After updating from 7.2.2 to 7.2.3 of the svelte integration, I'm getting type errors on Svelte components whenever I add a client directive to them:

---
export const prerender = false

import BaseLayout from '@/layouts/Base.astro'
import ContactForm from '@/components/ContactForm.svelte'
---

<BaseLayout meta={{ title: 'Contact', description: 'Message me' }}>
  <ContactForm client:load />
</BaseLayout>
src/pages/contact.astro:9:4 - error ts(2322): Type '{ "client:load": true; }' is not assignable to type 'IntrinsicAttributes & Record<string, never>'.
  Type '{ "client:load": true; }' is not assignable to type 'Record<string, never>'.
    Property 'client:load' is incompatible with index signature.
      Type 'true' is not assignable to type 'never'.

9   <ContactForm client:load />
     ~~~~~~~~~~~

It looks like it only happens when there are no props defined in the Svelte component. I’m working on a fix for this.

@florian-lefebvre
Copy link
Member

Awesome thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope) pkg: svelte Related to Svelte (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astro doesn't aware about svelte props

4 participants