Skip to content

Commit a583b96

Browse files
committed
tweaks
1 parent c1036c7 commit a583b96

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

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

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -597,39 +597,18 @@ export declare const MyComponent: Component<{
597597

598598
To declare that a component of a certain type is required:
599599

600-
```svelte
601-
<script lang="ts">
602-
import type { ---SvelteComponent--- +++Component+++ } from 'svelte';
603-
import {
604-
ComponentA,
605-
ComponentB
606-
} from 'component-library';
607-
608-
---let component: typeof SvelteComponent<{ foo: string }>---
609-
+++let component: Component<{ foo: string }>+++ = $state(
610-
Math.random() ? ComponentA : ComponentB
611-
);
612-
</script>
613-
614-
<svelte:component this={component} foo="bar" />
615-
```
616-
Or using the [new syntax](#svelte:component-is-no-longer-necessary):
600+
```js
601+
import { ComponentA, ComponentB } from 'component-library';
602+
---import type { SvelteComponent } from 'svelte';---
603+
+++import type { Component } from 'svelte';+++
617604

618-
```svelte
619-
<script lang="ts">
620-
import type { Component } from 'svelte';
621-
import {
622-
ComponentA,
623-
ComponentB
624-
} from 'component-library';
625-
let Component: Component<{ foo: string }> = $state(
626-
Math.random() ? ComponentA : ComponentB
627-
);
628-
</script>
629-
<Component foo="bar" />
605+
---let C: typeof SvelteComponent<{ foo: string }> = $state(---
606+
+++let C: Component<{ foo: string }> = $state(+++
607+
Math.random() ? ComponentA : ComponentB
608+
);
630609
```
631610
632-
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 }>`).
611+
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 (i.e. `ComponentType<SvelteComponent<{ prop: string }>>` is equivalent to `Component<{ prop: string }>`).
633612
634613
### bind:this changes
635614
@@ -658,7 +637,7 @@ This is no longer true in Svelte 5:
658637
<Thing />
659638
<svelte:component this={Thing} />
660639
```
661-
While migrating, keep in mind that your user-defined component's name should be capitalized (`Thing`) to distinguish it from a normal HTML element and avoid incorrect types.
640+
While migrating, keep in mind that your component's name should be capitalized (`Thing`) to distinguish it from elements, unless using dot notation.
662641
663642
### Dot notation indicates a component
664643

0 commit comments

Comments
 (0)