From ae43473aa6445495e583fe3eeff8499a61b256b4 Mon Sep 17 00:00:00 2001
From: Nicolas Boyer <52313840+boyer-nicolas@users.noreply.github.com>
Date: Fri, 22 Nov 2024 10:07:48 +0100
Subject: [PATCH] Added documentation about Svelte 5 (#2621)
Svelte 5 specifics including removing the "ComponentType" typescript type as components are now static.
Also merged some imports into one-liners as we don't need to import each icon in a single line.
---
docs/guide/packages/lucide-svelte.md | 177 +++++++++++++++++++++------
1 file changed, 142 insertions(+), 35 deletions(-)
diff --git a/docs/guide/packages/lucide-svelte.md b/docs/guide/packages/lucide-svelte.md
index 77e07ea6b..77877ea20 100644
--- a/docs/guide/packages/lucide-svelte.md
+++ b/docs/guide/packages/lucide-svelte.md
@@ -87,54 +87,95 @@ The package includes type definitions for all icons. This is useful if you want
### TypeScript Example
+#### Svelte 4
+
```svelte
{#each menuItems as item}
-
-
- {item.name}
-
+
+
+ {item.name}
+
+{/each}
+```
+
+
+#### Svelte 5
+Some changes are required since Svelte 5 [deprecates](https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes-Component-typing-changes) the `ComponentType` typescript type.
+
+```svelte
+
+
+{#each menuItems as item}
+ {@const Icon = item.icon}
+
+
+ {item.name}
+
{/each}
```
### JSDoc Example
+#### Svelte 4
+
```svelte
+
+{#each menuItems as item}
+
+
+ {item.name}
+
+{/each}
+```
+
+
+#### Svelte 5
+
+```svelte
+
+
+{#each menuItems as item}
+ {@const Icon = item.icon}
+
+
+ {item.name}
+
+{/each}
+
```
For more details about typing the `svelte:component` directive, see the [Svelte documentation](https://svelte.dev/docs/typescript#types-componenttype).
@@ -197,13 +289,28 @@ The example below imports all ES Modules, so exercise caution when using it. Imp
### Icon Component Example
+#### Svelte 4
+
```svelte
-
+
+```
+
+#### Svelte 5
+
+```svelte
+
+
+
```
#### Using the Icon Component