Skip to content

Commit 7fc930a

Browse files
chore: bette phrasing for docs and error
Co-authored-by: Matei Trandafir <[email protected]>
1 parent 4229776 commit 7fc930a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

documentation/docs/02-runes/02-$state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ This can improve performance with large arrays and objects that you weren't plan
149149

150150
## State options
151151

152-
Both `$state` and `$state.raw` can optionally accept a second argument. This argument allow you to specify an `onchange` function that will be called synchronously whenever the object change (for `$state` it will also be called for deep mutations).
152+
Both `$state` and `$state.raw` can optionally accept a second argument. This allows you to specify an `onchange` function that will be called synchronously whenever the state value changes (for `$state` it will also be called for deep mutations).
153153

154154
The `onchange` function is untracked so even if you assign within an `$effect` it will not cause unwanted dependencies.
155155

packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function CallExpression(node, context) {
8888
if ((rune === '$derived' || rune === '$derived.by') && node.arguments.length !== 1) {
8989
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
9090
} else if (rune === '$state' && node.arguments.length > 2) {
91-
e.rune_invalid_arguments_length(node, rune, 'zero, one or two arguments');
91+
e.rune_invalid_arguments_length(node, rune, 'at most two arguments');
9292
}
9393

9494
break;

packages/svelte/tests/compiler-errors/samples/runes-wrong-state-args/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { test } from '../../test';
33
export default test({
44
error: {
55
code: 'rune_invalid_arguments_length',
6-
message: '`$state` must be called with zero, one or two arguments'
6+
message: '`$state` must be called with at most two arguments'
77
}
88
});

0 commit comments

Comments
 (0)