Skip to content

Commit a9db435

Browse files
committed
Update test wrapper component to Svelte 5
1 parent ff2a1b3 commit a9db435

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default defineConfig(
2323
'eslint.config.js',
2424
'svelte.config.js',
2525
'**/vite.*.ts',
26+
'./test/utils/ContextWrapper.svelte',
2627
]),
2728
{
2829
languageOptions: {

test/utils/ContextWrapper.svelte

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
<script lang="ts">
1+
<script lang="ts" generics="TComponent extends Component<any>">
22
// Wrapper component to test Svelte components that use the Context API.
33
// See https://github.com/svelte-society/recipes-mvp/blob/master/testing.md#testing-the-context-api
4-
import { type ComponentType, setContext } from 'svelte';
4+
import type { Component, ComponentProps } from 'svelte';
5+
import { setContext } from 'svelte';
56
6-
// Component
7-
export let Component: ComponentType;
8-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9-
export let Props: Record<string, any>;
7+
interface Props {
8+
// Component
9+
Component: TComponent;
10+
Props: ComponentProps<TComponent>;
11+
12+
// Context
13+
Context: Record<string, any>;
14+
}
15+
16+
let { Component: WrappedComponent, Props, Context }: Props = $props();
1017
11-
// Context
12-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13-
export let Context: Record<string, any>;
1418
for (const [key, value] of Object.entries(Context)) {
1519
setContext(key, value);
1620
}
1721
</script>
1822

19-
<svelte:component this={Component} {...Props} />
23+
<WrappedComponent {...Props} />

0 commit comments

Comments
 (0)