@@ -24,7 +24,7 @@ declare module 'svelte' {
24
24
( Props extends { children ?: any }
25
25
? { }
26
26
: Slots extends { default : any }
27
- ? { children ?: Snippet < [ ] > }
27
+ ? { children ?: Snippet }
28
28
: { } ) ;
29
29
30
30
/**
@@ -321,15 +321,7 @@ declare module 'svelte' {
321
321
* If you don't need to interact with the component after mounting, use `mount` instead to save some bytes.
322
322
*
323
323
* */
324
- export function createRoot < Props extends Record < string , any > , Exports extends Record < string , any > | undefined , Events extends Record < string , any > > ( component : {
325
- new ( options : ComponentConstructorOptions < Props & ( Props extends {
326
- children ?: any ;
327
- } ? { } : { } | {
328
- children ?: ( ( this : void ) => unique symbol & {
329
- _ : "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"" ;
330
- } ) | undefined ;
331
- } ) > ) : SvelteComponent < Props , Events , any > ;
332
- } , options : {
324
+ export function createRoot < Props extends Record < string , any > , Exports extends Record < string , any > | undefined , Events extends Record < string , any > > ( component : ComponentType < SvelteComponent < Props , Events , any > > , options : {
333
325
target : Node ;
334
326
props ?: Props | undefined ;
335
327
events ?: Events | undefined ;
@@ -346,15 +338,7 @@ declare module 'svelte' {
346
338
* If you need to interact with the component after mounting, use `createRoot` instead.
347
339
*
348
340
* */
349
- export function mount < Props extends Record < string , any > , Exports extends Record < string , any > | undefined , Events extends Record < string , any > > ( component : {
350
- new ( options : ComponentConstructorOptions < Props & ( Props extends {
351
- children ?: any ;
352
- } ? { } : { } | {
353
- children ?: ( ( this : void ) => unique symbol & {
354
- _ : "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"" ;
355
- } ) | undefined ;
356
- } ) > ) : SvelteComponent < Props , Events , any > ;
357
- } , options : {
341
+ export function mount < Props extends Record < string , any > , Exports extends Record < string , any > | undefined , Events extends Record < string , any > > ( component : ComponentType < SvelteComponent < Props , Events , any > > , options : {
358
342
target : Node ;
359
343
props ?: Props | undefined ;
360
344
events ?: Events | undefined ;
@@ -1734,17 +1718,7 @@ declare module 'svelte/legacy' {
1734
1718
* @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
1735
1719
*
1736
1720
* */
1737
- export function asClassComponent < Props extends Record < string , any > , Exports extends Record < string , any > , Events extends Record < string , any > , Slots extends Record < string , any > > ( component : SvelteComponent < Props , Events , Slots > ) : {
1738
- new ( options : ComponentConstructorOptions < Props & ( Props extends {
1739
- children ?: any ;
1740
- } ? { } : Slots extends {
1741
- default : any ;
1742
- } ? {
1743
- children ?: ( ( this : void ) => unique symbol & {
1744
- _ : "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"" ;
1745
- } ) | undefined ;
1746
- } : { } ) > ) : SvelteComponent < Props , Events , Slots > ;
1747
- } & Exports ;
1721
+ export function asClassComponent < Props extends Record < string , any > , Exports extends Record < string , any > , Events extends Record < string , any > , Slots extends Record < string , any > > ( component : SvelteComponent < Props , Events , Slots > ) : ComponentType < SvelteComponent < Props , Events , Slots > & Exports > ;
1748
1722
// This should contain all the public interfaces (not all of them are actually importable, check current Svelte for which ones are).
1749
1723
1750
1724
/**
@@ -1770,7 +1744,7 @@ declare module 'svelte/legacy' {
1770
1744
( Props extends { children ?: any }
1771
1745
? { }
1772
1746
: Slots extends { default : any }
1773
- ? { children ?: Snippet < [ ] > }
1747
+ ? { children ?: Snippet }
1774
1748
: { } ) ;
1775
1749
1776
1750
/**
@@ -1859,6 +1833,34 @@ declare module 'svelte/legacy' {
1859
1833
$set ( props : Partial < Props > ) : void ;
1860
1834
}
1861
1835
1836
+ /**
1837
+ * Convenience type to get the type of a Svelte component. Useful for example in combination with
1838
+ * dynamic components using `<svelte:component>`.
1839
+ *
1840
+ * Example:
1841
+ * ```html
1842
+ * <script lang="ts">
1843
+ * import type { ComponentType, SvelteComponent } from 'svelte';
1844
+ * import Component1 from './Component1.svelte';
1845
+ * import Component2 from './Component2.svelte';
1846
+ *
1847
+ * const component: ComponentType = someLogic() ? Component1 : Component2;
1848
+ * const componentOfCertainSubType: ComponentType<SvelteComponent<{ needsThisProp: string }>> = someLogic() ? Component1 : Component2;
1849
+ * </script>
1850
+ *
1851
+ * <svelte:component this={component} />
1852
+ * <svelte:component this={componentOfCertainSubType} needsThisProp="hello" />
1853
+ * ```
1854
+ */
1855
+ type ComponentType < Comp extends SvelteComponent = SvelteComponent > = ( new (
1856
+ options : ComponentConstructorOptions <
1857
+ Comp extends SvelteComponent < infer Props > ? Props : Record < string , any >
1858
+ >
1859
+ ) => Comp ) & {
1860
+ /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */
1861
+ element ?: typeof HTMLElement ;
1862
+ } ;
1863
+
1862
1864
const SnippetReturn : unique symbol ;
1863
1865
1864
1866
/**
0 commit comments