Skip to content

Commit 675e126

Browse files
committed
fix(svelte5): ensure typings are actually included in the module
1 parent f215ad8 commit 675e126

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Diff for: src/component-types.d.ts renamed to src/component-types.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import type * as Svelte from 'svelte'
23

3-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
44
type IS_MODERN_SVELTE = any extends Svelte.Component ? false : true
55

66
/** A compiled, imported Svelte component. */
7-
export type Component<P> = IS_MODERN_SVELTE extends true
8-
? Svelte.Component<P> | Svelte.SvelteComponent<P>
7+
export type Component<
8+
P extends Record<string, any>,
9+
E extends Record<string, any>,
10+
> = IS_MODERN_SVELTE extends true
11+
? Svelte.Component<P, E> | Svelte.SvelteComponent<P>
912
: Svelte.SvelteComponent<P>
1013

1114
/**
@@ -19,7 +22,7 @@ export type ComponentType<C> = C extends Svelte.SvelteComponent
1922
: C
2023

2124
/** The props of a component. */
22-
export type Props<C> = Svelte.ComponentProps<C>
25+
export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C>
2326

2427
/**
2528
* The exported fields of a component.
@@ -29,7 +32,7 @@ export type Props<C> = Svelte.ComponentProps<C>
2932
*/
3033
export type Exports<C> = C extends Svelte.SvelteComponent
3134
? C
32-
: C extends Svelte.Component<unknown, infer E>
35+
: C extends Svelte.Component<any, infer E>
3336
? E
3437
: never
3538

@@ -38,6 +41,7 @@ export type Exports<C> = C extends Svelte.SvelteComponent
3841
*
3942
* In Svelte 4, these are the options passed to the component constructor.
4043
*/
41-
export type MountOptions<C> = IS_MODERN_SVELTE extends true
42-
? Parameters<typeof Svelte.mount<Props<C>, Exports<C>>>[1]
43-
: Svelte.ComponentConstructorOptions<Props<C>>
44+
export type MountOptions<C extends Component<any, any>> =
45+
IS_MODERN_SVELTE extends true
46+
? Parameters<typeof Svelte.mount<Props<C>, Exports<C>>>[1]
47+
: Svelte.ComponentConstructorOptions<Props<C>>

0 commit comments

Comments
 (0)