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
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -473,6 +473,15 @@ type MyProps = any;
473
473
let { a, b, c, ...everythingElse }:MyProps=$props();
474
474
```
475
475
476
+
> In an earlier preview, `$props()` took a type argument. This caused bugs, since in a case like this...
477
+
>
478
+
> ```ts
479
+
>// @errors: 2558
480
+
>let { x =42 } =$props<{ x:string }>();
481
+
>```
482
+
>
483
+
> ...TypeScript [widens the type](https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwBIAHGHIgZwB4AVeAXnilQE8A+ACgEoAueagbgBQgiCAzwA3vAAe9eABYATPAC+c4qQqUp03uQwwsqAOaqOnIfCsB6a-AB6AfiA) of `x` to be `string|number`, instead of erroring.
484
+
476
485
Props cannot be mutated, unless the parent component uses `bind:`. During development, attempts to mutate props will result in an error.
0 commit comments