Convenience type to get the type of a Svelte component. Useful for example in combination with dynamic components using <svelte:component>.
<svelte:component>
Example:
<script lang="ts"> import type { ComponentType, SvelteComponent } from 'svelte'; import Component1 from './Component1.svelte'; import Component2 from './Component2.svelte'; const component: ComponentType = someLogic() ? Component1 : Component2; const componentOfCertainSubType: ComponentType<SvelteComponent<{ needsThisProp: string }>> = someLogic() ? Component1 : Component2;</script><svelte:component this={component} /><svelte:component this={componentOfCertainSubType} needsThisProp="hello" /> Copy
<script lang="ts"> import type { ComponentType, SvelteComponent } from 'svelte'; import Component1 from './Component1.svelte'; import Component2 from './Component2.svelte'; const component: ComponentType = someLogic() ? Component1 : Component2; const componentOfCertainSubType: ComponentType<SvelteComponent<{ needsThisProp: string }>> = someLogic() ? Component1 : Component2;</script><svelte:component this={component} /><svelte:component this={componentOfCertainSubType} needsThisProp="hello" />
Optional
The custom element version of the component. Only present if compiled with the customElement compiler option
customElement
Convenience type to get the type of a Svelte component. Useful for example in combination with dynamic components using
<svelte:component>
.Example: