Skip to content

Commit 5f6c5ca

Browse files
authored
chore: remove get_callee_name (#9595)
no longer necessary with the enhanced get_rune function
1 parent 13c6c27 commit 5f6c5ca

File tree

3 files changed

+2
-24
lines changed

3 files changed

+2
-24
lines changed

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as assert from '../../utils/assert.js';
55
import {
66
extract_identifiers,
77
extract_paths,
8-
get_callee_name,
98
is_event_attribute,
109
is_text_attribute,
1110
object
@@ -268,11 +267,7 @@ export function analyze_component(root, options) {
268267
!Runes.includes(name) ||
269268
(declaration !== null &&
270269
// 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 &&
276271
// allow `import { derived } from 'svelte/store'` in the same file as `const x = $derived(..)` because one is not a subscription to the other
277272
!(
278273
name === '$derived' &&

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { walk } from 'zimmerframe';
33
import { is_element_node } from './nodes.js';
44
import * as b from '../utils/builders.js';
55
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';
117
import { Runes } from './constants.js';
128

139
export class Scope {

packages/svelte/src/compiler/utils/ast.js

-13
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ export function object(expression) {
2020
return expression;
2121
}
2222

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-
3623
/**
3724
* Returns true if the attribute contains a single static text node.
3825
* @param {import('#compiler').Attribute} attribute

0 commit comments

Comments
 (0)