File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff 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 : {
Original file line number Diff line number Diff line change 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 } />
You can’t perform that action at this time.
0 commit comments