Skip to content

Commit cda50c4

Browse files
committed
update messages
1 parent f00a403 commit cda50c4

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

documentation/docs/98-reference/.generated/compile-errors.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Attribute values containing `{...}` must be enclosed in quote marks, unless the
8787
### bind_invalid_expression
8888

8989
```
90-
Can only bind to an Identifier or MemberExpression
90+
Can only bind to an Identifier or MemberExpression or a `{get, set}` pair
9191
```
9292

9393
### bind_invalid_name
@@ -100,6 +100,12 @@ Can only bind to an Identifier or MemberExpression
100100
`bind:%name%` is not a valid binding. %explanation%
101101
```
102102

103+
### bind_invalid_parens
104+
105+
```
106+
`bind:%name%={get, set}` must not have surrounding parentheses
107+
```
108+
103109
### bind_invalid_target
104110

105111
```
@@ -436,12 +442,6 @@ Imports of `svelte/internal/*` are forbidden. It contains private runtime code w
436442
The arguments keyword cannot be used within the template or at the top level of a component
437443
```
438444

439-
### invalid_bind_directive
440-
441-
```
442-
Bind directive getter/setter values (`bind:thing={ getter, setter }`) must be two JavaScript expressions separated by a single comma and enclosed in curly braces
443-
```
444-
445445
### js_parse_error
446446

447447
```

packages/svelte/messages/compile-errors/template.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@
5656
5757
## bind_invalid_expression
5858

59-
> Can only bind to an Identifier or MemberExpression
59+
> Can only bind to an Identifier or MemberExpression or a `{get, set}` pair
6060
6161
## bind_invalid_name
6262

6363
> `bind:%name%` is not a valid binding
6464
6565
> `bind:%name%` is not a valid binding. %explanation%
6666
67+
## bind_invalid_parens
68+
69+
> `bind:%name%={get, set}` must not have surrounding parentheses
70+
6771
## bind_invalid_target
6872

6973
> `bind:%name%` can only be used with %elements%
@@ -180,10 +184,6 @@
180184

181185
> `<%name%>` does not support non-event attributes or spread attributes
182186
183-
## invalid_bind_directive
184-
185-
> Bind directive getter/setter values (`bind:thing={ getter, setter }`) must be two JavaScript expressions separated by a single comma and enclosed in curly braces
186-
187187
## js_parse_error
188188

189189
> %message%

packages/svelte/src/compiler/errors.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,12 @@ export function bind_group_invalid_expression(node) {
706706
}
707707

708708
/**
709-
* Can only bind to an Identifier or MemberExpression
709+
* Can only bind to an Identifier or MemberExpression or a `{get, set}` pair
710710
* @param {null | number | NodeLike} node
711711
* @returns {never}
712712
*/
713713
export function bind_invalid_expression(node) {
714-
e(node, "bind_invalid_expression", "Can only bind to an Identifier or MemberExpression");
714+
e(node, "bind_invalid_expression", "Can only bind to an Identifier or MemberExpression or a `{get, set}` pair");
715715
}
716716

717717
/**
@@ -725,6 +725,16 @@ export function bind_invalid_name(node, name, explanation) {
725725
e(node, "bind_invalid_name", explanation ? `\`bind:${name}\` is not a valid binding. ${explanation}` : `\`bind:${name}\` is not a valid binding`);
726726
}
727727

728+
/**
729+
* `bind:%name%={get, set}` must not have surrounding parentheses
730+
* @param {null | number | NodeLike} node
731+
* @param {string} name
732+
* @returns {never}
733+
*/
734+
export function bind_invalid_parens(node, name) {
735+
e(node, "bind_invalid_parens", `\`bind:${name}={get, set}\` must not have surrounding parentheses`);
736+
}
737+
728738
/**
729739
* `bind:%name%` can only be used with %elements%
730740
* @param {null | number | NodeLike} node
@@ -1003,15 +1013,6 @@ export function illegal_element_attribute(node, name) {
10031013
e(node, "illegal_element_attribute", `\`<${name}>\` does not support non-event attributes or spread attributes`);
10041014
}
10051015

1006-
/**
1007-
* Bind directive getter/setter values (`bind:thing={ getter, setter }`) must be two JavaScript expressions separated by a single comma and enclosed in curly braces
1008-
* @param {null | number | NodeLike} node
1009-
* @returns {never}
1010-
*/
1011-
export function invalid_bind_directive(node) {
1012-
e(node, "invalid_bind_directive", "Bind directive getter/setter values (`bind:thing={ getter, setter }`) must be two JavaScript expressions separated by a single comma and enclosed in curly braces");
1013-
}
1014-
10151016
/**
10161017
* %message%
10171018
* @param {null | number | NodeLike} node

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ export function BindDirective(node, context) {
133133
let i = /** @type {number} */ (node.expression.start);
134134
while (context.state.analysis.source[--i] !== '{') {
135135
if (context.state.analysis.source[i] === '(') {
136-
e.invalid_bind_directive(node);
136+
e.bind_invalid_parens(node, node.name);
137137
}
138138
}
139139

140140
if (node.expression.expressions.length !== 2) {
141-
e.invalid_bind_directive(node);
141+
e.bind_invalid_expression(node);
142142
}
143143

144144
return;

0 commit comments

Comments
 (0)