props-bindable
Simon Holthausen 2 years ago
parent 4d92bfb7b0
commit b0a8aaf855

@ -640,7 +640,16 @@ export function get_prop_source(binding, state, name, initial) {
flags |= PROPS_IS_RUNES; 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; flags |= PROPS_IS_BINDABLE;
} }

@ -282,7 +282,7 @@ export interface Binding {
scope: Scope; scope: Scope;
/** For `legacy_reactive`: its reactive dependencies */ /** For `legacy_reactive`: its reactive dependencies */
legacy_dependencies: Binding[]; 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; prop_alias: string | null;
/** /**
* If this is set, all references should use this expression instead of the identifier name. * If this is set, all references should use this expression instead of the identifier name.

@ -1,5 +1,5 @@
<script> <script>
let { ...properties } = $props(); let { value: _, ...properties } = $props();
let { value } = $props.bindable(); let { value } = $props.bindable();
</script> </script>

Loading…
Cancel
Save