Skip to content

Commit d11556c

Browse files
committed
oops
1 parent f5f5846 commit d11556c

File tree

1 file changed

+4
-9
lines changed
  • sites/svelte-5-preview/src/routes/docs/content/01-api

1 file changed

+4
-9
lines changed

sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -556,22 +556,17 @@ let props = $props();
556556

557557
If you're using TypeScript, you can declare the prop types:
558558

559-
<!-- prettier-ignore -->
560559
```ts
561-
interface MyProps {
562-
required: string;
563-
optional?: number;
564-
partOfEverythingElse?: boolean;
565-
};
566-
567-
let { required, optional, ...everythingElse }: MyProps = $props();
560+
type MyProps = any;
561+
// ---cut---
562+
let { a, b, c, ...everythingElse }: MyProps = $props();
568563
```
569564

570565
> In an earlier preview, `$props()` took a type argument. This caused bugs, since in a case like this...
571566
>
572567
> ```ts
573568
> // @errors: 2558
574-
> let { x = 42 } = $props<{ x?: string }>();
569+
> let { x = 42 } = $props<{ x: string }>();
575570
> ```
576571
>
577572
> ...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

Comments
 (0)