@@ -24,7 +24,7 @@ declare module 'svelte' {
2424 ( Props extends { children ?: any }
2525 ? { }
2626 : Slots extends { default : any }
27- ? { children ?: Snippet < [ ] > }
27+ ? { children ?: Snippet }
2828 : { } ) ;
2929
3030 /**
@@ -321,15 +321,7 @@ declare module 'svelte' {
321321 * If you don't need to interact with the component after mounting, use `mount` instead to save some bytes.
322322 *
323323 * */
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 : {
333325 target : Node ;
334326 props ?: Props | undefined ;
335327 events ?: Events | undefined ;
@@ -346,15 +338,7 @@ declare module 'svelte' {
346338 * If you need to interact with the component after mounting, use `createRoot` instead.
347339 *
348340 * */
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 : {
358342 target : Node ;
359343 props ?: Props | undefined ;
360344 events ?: Events | undefined ;
@@ -1734,17 +1718,7 @@ declare module 'svelte/legacy' {
17341718 * @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
17351719 *
17361720 * */
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 > ;
17481722 // This should contain all the public interfaces (not all of them are actually importable, check current Svelte for which ones are).
17491723
17501724 /**
@@ -1770,7 +1744,7 @@ declare module 'svelte/legacy' {
17701744 ( Props extends { children ?: any }
17711745 ? { }
17721746 : Slots extends { default : any }
1773- ? { children ?: Snippet < [ ] > }
1747+ ? { children ?: Snippet }
17741748 : { } ) ;
17751749
17761750 /**
@@ -1859,6 +1833,34 @@ declare module 'svelte/legacy' {
18591833 $set ( props : Partial < Props > ) : void ;
18601834 }
18611835
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+
18621864 const SnippetReturn : unique symbol ;
18631865
18641866 /**
0 commit comments