File tree 3 files changed +2
-24
lines changed
packages/svelte/src/compiler
3 files changed +2
-24
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import * as assert from '../../utils/assert.js';
5
5
import {
6
6
extract_identifiers ,
7
7
extract_paths ,
8
- get_callee_name ,
9
8
is_event_attribute ,
10
9
is_text_attribute ,
11
10
object
@@ -268,11 +267,7 @@ export function analyze_component(root, options) {
268
267
! Runes . includes ( name ) ||
269
268
( declaration !== null &&
270
269
// const state = $state(0) is valid
271
- ! Runes . includes (
272
- /** @type {string } */ (
273
- get_callee_name ( /** @type {import('estree').Expression } */ ( declaration . initial ) )
274
- )
275
- ) &&
270
+ get_rune ( declaration . initial , instance . scope ) === null &&
276
271
// allow `import { derived } from 'svelte/store'` in the same file as `const x = $derived(..)` because one is not a subscription to the other
277
272
! (
278
273
name === '$derived' &&
Original file line number Diff line number Diff line change @@ -3,11 +3,7 @@ import { walk } from 'zimmerframe';
3
3
import { is_element_node } from './nodes.js' ;
4
4
import * as b from '../utils/builders.js' ;
5
5
import { error } from '../errors.js' ;
6
- import {
7
- extract_identifiers ,
8
- extract_identifiers_from_expression ,
9
- get_callee_name
10
- } from '../utils/ast.js' ;
6
+ import { extract_identifiers , extract_identifiers_from_expression } from '../utils/ast.js' ;
11
7
import { Runes } from './constants.js' ;
12
8
13
9
export class Scope {
Original file line number Diff line number Diff line change @@ -20,19 +20,6 @@ export function object(expression) {
20
20
return expression ;
21
21
}
22
22
23
- /**
24
- * Returns the name of callee if the given expression is a call expression.
25
- * @param {import('estree').Expression | null | undefined } node
26
- */
27
- export function get_callee_name ( node ) {
28
- if ( ! node ) return null ;
29
- if ( node . type !== 'CallExpression' ) return null ;
30
- if ( node . callee . type !== 'Identifier' && node . callee . type !== 'MemberExpression' ) return null ;
31
-
32
- const id = object ( node . callee ) ;
33
- return id === null ? null : id . name ;
34
- }
35
-
36
23
/**
37
24
* Returns true if the attribute contains a single static text node.
38
25
* @param {import('#compiler').Attribute } attribute
You can’t perform that action at this time.
0 commit comments