From b0a8aaf8551f3720495622b996a15b4f2b7379c2 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Mon, 18 Mar 2024 17:43:39 +0100 Subject: [PATCH] more fixes --- .../src/compiler/phases/3-transform/client/utils.js | 11 ++++++++++- packages/svelte/src/compiler/types/index.d.ts | 2 +- .../samples/bind-and-spread/button.svelte | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/utils.js b/packages/svelte/src/compiler/phases/3-transform/client/utils.js index 604bfdff6a..836ecaf8d0 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/utils.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/utils.js @@ -640,7 +640,16 @@ export function get_prop_source(binding, state, name, initial) { flags |= PROPS_IS_RUNES; } - if (binding.kind === 'bindable_prop') { + if ( + binding.kind === 'bindable_prop' || + // Make sure that + // let { foo: _, ...rest } = $props(); + // let { foo } = $props.bindable(); + // marks both `foo` and `_` as bindable to prevent false-positive runtime validation errors + [...state.scope.declarations.values()].some( + (d) => d.kind === 'bindable_prop' && d.prop_alias === name + ) + ) { flags |= PROPS_IS_BINDABLE; } diff --git a/packages/svelte/src/compiler/types/index.d.ts b/packages/svelte/src/compiler/types/index.d.ts index 9f82c014c8..68a9751efb 100644 --- a/packages/svelte/src/compiler/types/index.d.ts +++ b/packages/svelte/src/compiler/types/index.d.ts @@ -282,7 +282,7 @@ export interface Binding { scope: Scope; /** For `legacy_reactive`: its reactive dependencies */ legacy_dependencies: Binding[]; - /** Legacy props: the `class` in `{ export klass as class}` */ + /** Legacy props: the `class` in `{ export klass as class}`. $props(): The `class` in { class: klass } = $props() */ prop_alias: string | null; /** * If this is set, all references should use this expression instead of the identifier name. diff --git a/packages/svelte/tests/runtime-runes/samples/bind-and-spread/button.svelte b/packages/svelte/tests/runtime-runes/samples/bind-and-spread/button.svelte index 8f5dd0395f..988f4f4186 100644 --- a/packages/svelte/tests/runtime-runes/samples/bind-and-spread/button.svelte +++ b/packages/svelte/tests/runtime-runes/samples/bind-and-spread/button.svelte @@ -1,5 +1,5 @@