From d11556c248b2bf36da11c37d235e3d6de392a3bb Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Mon, 22 Jul 2024 14:12:09 +0200 Subject: [PATCH] oops --- .../src/routes/docs/content/01-api/02-runes.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md b/sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md index 5f0ee7c0ea..879e39e5f0 100644 --- a/sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md +++ b/sites/svelte-5-preview/src/routes/docs/content/01-api/02-runes.md @@ -556,22 +556,17 @@ let props = $props(); If you're using TypeScript, you can declare the prop types: - ```ts -interface MyProps { - required: string; - optional?: number; - partOfEverythingElse?: boolean; -}; - -let { required, optional, ...everythingElse }: MyProps = $props(); +type MyProps = any; +// ---cut--- +let { a, b, c, ...everythingElse }: MyProps = $props(); ``` > In an earlier preview, `$props()` took a type argument. This caused bugs, since in a case like this... > > ```ts > // @errors: 2558 -> let { x = 42 } = $props<{ x?: string }>(); +> let { x = 42 } = $props<{ x: string }>(); > ``` > > ...TypeScript [widens the type](https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwBIAHGHIgZwB4AVeAXnilQE8A+ACgEoAueagbgBQgiCAzwA3vAAe9eABYATPAC+c4qQqUp03uQwwsqAOaqOnIfCsB6a-AB6AfiA) of `x` to be `string | number`, instead of erroring.