You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md
+4-9Lines changed: 4 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -556,22 +556,17 @@ let props = $props();
556
556
557
557
If you're using TypeScript, you can declare the prop types:
558
558
559
-
<!-- prettier-ignore -->
560
559
```ts
561
-
interfaceMyProps {
562
-
required:string;
563
-
optional?:number;
564
-
partOfEverythingElse?:boolean;
565
-
};
566
-
567
-
let { required, optional, ...everythingElse }:MyProps=$props();
560
+
typeMyProps=any;
561
+
// ---cut---
562
+
let { a, b, c, ...everythingElse }:MyProps=$props();
568
563
```
569
564
570
565
> In an earlier preview, `$props()` took a type argument. This caused bugs, since in a case like this...
571
566
>
572
567
> ```ts
573
568
>// @errors: 2558
574
-
>let { x =42 } =$props<{ x?:string }>();
569
+
>let { x =42 } =$props<{ x:string }>();
575
570
>```
576
571
>
577
572
> ...TypeScript [widens the type](https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwBIAHGHIgZwB4AVeAXnilQE8A+ACgEoAueagbgBQgiCAzwA3vAAe9eABYATPAC+c4qQqUp03uQwwsqAOaqOnIfCsB6a-AB6AfiA) of `x` to be `string|number`, instead of erroring.
0 commit comments