Skip to content

fix: svelte testing library type#16496

Merged
ematipico merged 9 commits into
withastro:mainfrom
fkatsuhiro:fix/svelte-testing-library-type
May 25, 2026
Merged

fix: svelte testing library type#16496
ematipico merged 9 commits into
withastro:mainfrom
fkatsuhiro:fix/svelte-testing-library-type

Conversation

@fkatsuhiro

@fkatsuhiro fkatsuhiro commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Changes

Close #15689

Adjusted the generated Svelte editor wrapper to avoid intersecting with the original $$Component type and instead use an explicit wrapper type with distinct Astro prop and Svelte internals call signatures. The change preserves generic inference by using GenericPropsWithClientDirectives for generic components, restores invalid prop errors in astro check, and maintains compatibility with @testing-library/svelte.

Testing Before Implementation

スクリーンショット 2026-05-23 14 04 51

Testing After Implementation

スクリーンショット 2026-05-23 14 20 11

@changeset-bot

changeset-bot Bot commented Apr 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c08c3ce

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

This PR includes changesets to release 28 packages
Name Type
@astrojs/svelte Patch
@e2e/errors Patch
@e2e/svelte-component Patch
@e2e/view-transitions Patch
@test/0-css Patch
@test/aliases-tsconfig Patch
@test/aliases Patch
@test/astro-children Patch
@test/astro-client-only Patch
@test/astro-dynamic Patch
@test/astro-slots-nested Patch
@test/component-library Patch
@test/css-dangling-references Patch
@test/fetch Patch
@test/postcss Patch
@test/server-islands-hybrid Patch
@test/server-islands-ssr Patch
@test/slots-svelte Patch
@test/svelte-component Patch
@test/vue-with-multi-renderer Patch
@test/astro-cloudflare-prerender-node-env Patch
@test/astro-cloudflare-svelte-rune-deps Patch
@test/astro-cloudflare-vite-plugin Patch
@test/astro-cloudflare-with-svelte Patch
async-rendering Patch
conditional-rendering Patch
@test/empty-class Patch
svelte-prop-types 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

@github-actions github-actions Bot added pkg: svelte Related to Svelte (scope) pkg: integration Related to any renderer integration (scope) labels Apr 27, 2026
@fkatsuhiro fkatsuhiro force-pushed the fix/svelte-testing-library-type branch from b250c9c to 59a9c0a Compare April 27, 2026 18:11
Comment thread .changeset/nine-dots-cross.md Outdated
'@astrojs/svelte': patch
---

Adjusted the generated Svelte editor wrapper to avoid intersecting with the original `$$Component` type and instead use an explicit wrapper type with distinct Astro prop and Svelte internals call signatures. The change preserves generic inference by using `GenericPropsWithClientDirectives` for generic components, restores invalid prop errors in astro check, and maintains compatibility with `@testing-library/svelte`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This changeset feels very internal and not fit for end-users. Please reword it https://contribute.docs.astro.build/docs-for-code-changes/changesets/#tips-and-examples

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, let me check this.
Thank you.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why was this added?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For separating tsconfig to create specifically for validating @testing-library/svelte compatibility.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then I think you should add a comment at the top and explain that, it's important knowledge that developers need to know

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Understood. Thank you.

@fkatsuhiro fkatsuhiro force-pushed the fix/svelte-testing-library-type branch from 59a9c0a to 642a87c Compare May 1, 2026 11:43

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One nit to address

@fkatsuhiro fkatsuhiro force-pushed the fix/svelte-testing-library-type branch 2 times, most recently from bd6a3eb to 799511f Compare May 23, 2026 06:17
@fkatsuhiro fkatsuhiro force-pushed the fix/svelte-testing-library-type branch from 799511f to c08c3ce Compare May 23, 2026 06:29
@fkatsuhiro

Copy link
Copy Markdown
Contributor Author

Refector codes and update changeset contents.
Could you check it if you are available? Thank you.

@ematipico ematipico merged commit 4d79750 into withastro:main May 25, 2026
25 checks passed
@astrobot-houston astrobot-houston mentioned this pull request May 25, 2026
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 provides types for Svelte components that are not compatible with @testing-library/svelte

2 participants