fix: error on snippet rest parameters (#12472)

closes #12464
pull/12470/head
Simon H 5 months ago committed by GitHub
parent c287bd503d
commit 3c3a542c05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -250,7 +250,7 @@
## snippet_invalid_rest_parameter
> snippets do not support rest parameters; use an array instead
> Snippets do not support rest parameters; use an array instead
## snippet_shadowing_prop

@ -1108,12 +1108,12 @@ export function snippet_conflict(node) {
}
/**
* snippets do not support rest parameters; use an array instead
* Snippets do not support rest parameters; use an array instead
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function snippet_invalid_rest_parameter(node) {
e(node, "snippet_invalid_rest_parameter", "snippets do not support rest parameters; use an array instead");
e(node, "snippet_invalid_rest_parameter", "Snippets do not support rest parameters; use an array instead");
}
/**

@ -674,6 +674,12 @@ const validation = {
SnippetBlock(node, context) {
validate_block_not_empty(node.body, context);
for (const arg of node.parameters) {
if (arg.type === 'RestElement') {
e.snippet_invalid_rest_parameter(arg);
}
}
context.next({ ...context.state, parent_element: null });
const { path } = context;

@ -0,0 +1,9 @@
import { test } from '../../test';
export default test({
error: {
code: 'snippet_invalid_rest_parameter',
message: 'Snippets do not support rest parameters; use an array instead',
position: [19, 26]
}
});

@ -0,0 +1,3 @@
{#snippet children(...args)}
{args}
{/snippet}
Loading…
Cancel
Save