Skip to content

Commit 6ea89a3

Browse files
committed
args validation
1 parent 62c39ee commit 6ea89a3

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ export const validation_runes = merge(validation, a11y_validators, {
10701070
// TODO some of this is duplicated with above, seems off
10711071
if ((rune === '$derived' || rune === '$derived.by') && args.length !== 1) {
10721072
error(node, 'invalid-rune-args-length', rune, [1]);
1073-
} else if (rune === '$state' && args.length > 1) {
1073+
} else if ((rune === '$state' || rune === '$bindable') && args.length > 1) {
10741074
error(node, 'invalid-rune-args-length', rune, [0, 1]);
10751075
} else if (rune === '$props') {
10761076
if (state.has_props_rune) {
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-rune-args-length',
6+
message: '$bindable can only be called with 0 or 1 arguments'
7+
}
8+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
const { foo = $bindable(1, 2) } = $props();
3+
</script>

0 commit comments

Comments
 (0)