Skip to content

Commit 82dbdc4

Browse files
committed
adjust
1 parent afda88c commit 82dbdc4

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

documentation/docs/07-misc/03-typescript.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@ Using it together with dynamic components to restrict what kinds of component ca
197197

198198
> [!LEGACY] In Svelte 4, components were of type `SvelteComponent`
199199
200-
## Component helper types
201-
202-
### ComponentProps
203-
204-
`ComponentProps` extracts the properties a component expects.
200+
To extract the properties from a component, use `ComponentProps`.
205201

206202
```ts
207203
import type { Component, ComponentProps } from 'svelte';
@@ -217,19 +213,17 @@ function withProps<TComponent extends Component<any>>(
217213
withProps(MyComponent, { foo: 'bar' });
218214
```
219215

220-
### ComponentExports
221-
222-
`ComponentExports` extracts the exports of a component, in other words you can use it to declare its instance type:
216+
To declare that a variable expects the constructor or instance type of a component:
223217

224218
```svelte
225219
<script lang="ts">
226-
import type { ComponentExports } from 'svelte';
227-
import { Component } from './Component.svelte';
220+
import MyComponent from './MyComponent.svelte';
228221
229-
let component: ComponentExports<typeof Component>;
222+
let componentConstructor: typeof MyComponent = MyComponent;
223+
let componentInstance: MyComponent;
230224
</script>
231225
232-
<Component bind:this={component} />
226+
<MyComponent bind:this={componentInstance} />
233227
```
234228

235229
## Enhancing built-in DOM types

documentation/docs/07-misc/07-v5-migration-guide.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -614,20 +614,6 @@ To declare that a component of a certain type is required:
614614
<svelte:component this={component} foo="bar" />
615615
```
616616

617-
To declare the instance type of a component, or in other words its exports:
618-
619-
```svelte
620-
<script lang="ts">
621-
+++import type { ComponentExports } from 'svelte';+++
622-
import { Component } from './Component.svelte';
623-
624-
---let component: Component;---
625-
+++let component: ComponentExports<typeof Component>;+++
626-
</script>
627-
628-
<Component bind:this={component} />
629-
```
630-
631617
The two utility types `ComponentEvents` and `ComponentType` are also deprecated. `ComponentEvents` is obsolete because events are defined as callback props now, and `ComponentType` is obsolete because the new `Component` type is the component type already (e.g. `ComponentType<SvelteComponent<{ prop: string }>>` == `Component<{ prop: string }>`).
632618

633619
### bind:this changes

0 commit comments

Comments
 (0)