@ -195,7 +195,9 @@ Using it together with dynamic components to restrict what kinds of component ca
<DynamicComponentprop="foo"/>
<DynamicComponentprop="foo"/>
```
```
Closely related to the `Component` type is the `ComponentProps` type which extracts the properties a component expects.
> [!LEGACY] In Svelte 4, components were of type `SvelteComponent`
To extract the properties from a component, use `ComponentProps`.
```ts
```ts
import type { Component, ComponentProps } from 'svelte';
import type { Component, ComponentProps } from 'svelte';
@ -211,6 +213,19 @@ function withProps<TComponent extends Component<any>>(
withProps(MyComponent, { foo: 'bar' });
withProps(MyComponent, { foo: 'bar' });
```
```
To declare that a variable expects the constructor or instance type of a component:
```svelte
<scriptlang="ts">
import MyComponent from './MyComponent.svelte';
let componentConstructor: typeof MyComponent = MyComponent;
let componentInstance: MyComponent;
</script>
<MyComponentbind:this={componentInstance}/>
```
## Enhancing built-in DOM types
## Enhancing built-in DOM types
Svelte provides a best effort of all the HTML DOM types that exist. Sometimes you may want to use experimental attributes or custom events coming from an action. In these cases, TypeScript will throw a type error, saying that it does not know these types. If it's a non-experimental standard attribute/event, this may very well be a missing typing from our [HTML typings](https://github.com/sveltejs/svelte/blob/main/packages/svelte/elements.d.ts). In that case, you are welcome to open an issue and/or a PR fixing it.
Svelte provides a best effort of all the HTML DOM types that exist. Sometimes you may want to use experimental attributes or custom events coming from an action. In these cases, TypeScript will throw a type error, saying that it does not know these types. If it's a non-experimental standard attribute/event, this may very well be a missing typing from our [HTML typings](https://github.com/sveltejs/svelte/blob/main/packages/svelte/elements.d.ts). In that case, you are welcome to open an issue and/or a PR fixing it.