chore: bette phrasing for docs and error

Co-authored-by: Matei Trandafir <catalin_trand2@yahoo.com>
pull/15579/head
Paolo Ricciuti 8 months ago committed by GitHub
parent 42297764c5
commit 7fc930a32d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -149,7 +149,7 @@ This can improve performance with large arrays and objects that you weren't plan
## State options
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).
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).
The `onchange` function is untracked so even if you assign within an `$effect` it will not cause unwanted dependencies.

@ -88,7 +88,7 @@ export function CallExpression(node, context) {
if ((rune === '$derived' || rune === '$derived.by') && node.arguments.length !== 1) {
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
} else if (rune === '$state' && node.arguments.length > 2) {
e.rune_invalid_arguments_length(node, rune, 'zero, one or two arguments');
e.rune_invalid_arguments_length(node, rune, 'at most two arguments');
}
break;

@ -3,6 +3,6 @@ import { test } from '../../test';
export default test({
error: {
code: 'rune_invalid_arguments_length',
message: '`$state` must be called with zero, one or two arguments'
message: '`$state` must be called with at most two arguments'
}
});

Loading…
Cancel
Save