Skip to content

Commit adc3f7a

Browse files
committed
bindable location fix + test
1 parent 6ea89a3 commit adc3f7a

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

packages/svelte/src/compiler/phases/2-analyze/validation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,8 @@ export const validation_runes_js = {
891891
error(node, 'invalid-rune-args-length', rune, [0, 1]);
892892
} else if (rune === '$props') {
893893
error(node, 'invalid-props-location');
894+
} else if (rune === '$bindable') {
895+
error(node, 'invalid-bindable-location');
894896
}
895897
},
896898
AssignmentExpression(node, { state }) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
error: {
5+
code: 'invalid-bindable-location',
6+
message: '$bindable() can only be used inside a $props() declaration'
7+
}
8+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
const { a = $bindable() } = $state();
3+
</script>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const { a = $bindable() } = $state();

0 commit comments

Comments
 (0)