From e6b5ccd29a883272b9521c4352bdf37dd4436f4f Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Tue, 5 Dec 2023 21:16:13 +0000 Subject: [PATCH] fix: tweak invalid dollar prefix rules around function args (#9792) --- .changeset/neat-dingos-clap.md | 5 +++++ packages/svelte/src/compiler/phases/scope.js | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/neat-dingos-clap.md diff --git a/.changeset/neat-dingos-clap.md b/.changeset/neat-dingos-clap.md new file mode 100644 index 0000000000..6954c6cd40 --- /dev/null +++ b/.changeset/neat-dingos-clap.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: tweak invalid dollar prefix rules around function args diff --git a/packages/svelte/src/compiler/phases/scope.js b/packages/svelte/src/compiler/phases/scope.js index 02cd980adc..1a65ed26fc 100644 --- a/packages/svelte/src/compiler/phases/scope.js +++ b/packages/svelte/src/compiler/phases/scope.js @@ -73,7 +73,13 @@ export class Scope { error(node, 'invalid-dollar-binding'); } - if (node.name.startsWith('$') && declaration_kind !== 'synthetic' && this.function_depth <= 1) { + if ( + node.name.startsWith('$') && + declaration_kind !== 'synthetic' && + declaration_kind !== 'param' && + declaration_kind !== 'rest_param' && + this.function_depth <= 1 + ) { error(node, 'invalid-dollar-prefix'); }