Skip to content

Commit a490021

Browse files
committed
lint
1 parent 8fcdad2 commit a490021

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ export function analyze_component(root, source, options) {
287287

288288
const store_name = name.slice(1);
289289
const declaration = instance.scope.get(store_name);
290+
const init = /** @type {Node | undefined} */ (declaration?.initial);
290291

291292
// If we're not in legacy mode through the compiler option, assume the user
292293
// is referencing a rune and not a global store.
@@ -295,9 +296,9 @@ export function analyze_component(root, source, options) {
295296
!is_rune(name) ||
296297
(declaration !== null &&
297298
// const state = $state(0) is valid
298-
(get_rune(declaration.initial, instance.scope) === null ||
299+
(get_rune(init, instance.scope) === null ||
299300
// rune-line names received as props are valid too (but we have to protect against $props as store)
300-
(store_name !== 'props' && get_rune(declaration.initial, instance.scope) === '$props')) &&
301+
(store_name !== 'props' && get_rune(init, instance.scope) === '$props')) &&
301302
// allow `import { derived } from 'svelte/store'` in the same file as `const x = $derived(..)` because one is not a subscription to the other
302303
!(
303304
name === '$derived' &&

packages/svelte/src/compiler/phases/3-transform/client/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ export function should_proxy(node, scope) {
259259
binding.initial.type !== 'FunctionDeclaration' &&
260260
binding.initial.type !== 'ClassDeclaration' &&
261261
binding.initial.type !== 'ImportDeclaration' &&
262-
binding.initial.type !== 'EachBlock'
262+
binding.initial.type !== 'EachBlock' &&
263+
binding.initial.type !== 'SnippetBlock'
263264
) {
264265
return should_proxy(binding.initial, null);
265266
}

packages/svelte/src/compiler/phases/scope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ export function set_scope(node, { next, state }) {
726726

727727
/**
728728
* Returns the name of the rune if the given expression is a `CallExpression` using a rune.
729-
* @param {Node | AST.EachBlock | null | undefined} node
729+
* @param {Node | null | undefined} node
730730
* @param {Scope} scope
731731
*/
732732
export function get_rune(node, scope) {

0 commit comments

Comments
 (0)