chore: remove get_callee_name (#9595)

no longer necessary with the enhanced get_rune function
pull/9576/head
Rich Harris 1 year ago committed by GitHub
parent 13c6c273c6
commit 5f6c5ca8ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,6 @@ import * as assert from '../../utils/assert.js';
import {
extract_identifiers,
extract_paths,
get_callee_name,
is_event_attribute,
is_text_attribute,
object
@ -268,11 +267,7 @@ export function analyze_component(root, options) {
!Runes.includes(name) ||
(declaration !== null &&
// const state = $state(0) is valid
!Runes.includes(
/** @type {string} */ (
get_callee_name(/** @type {import('estree').Expression} */ (declaration.initial))
)
) &&
get_rune(declaration.initial, instance.scope) === null &&
// allow `import { derived } from 'svelte/store'` in the same file as `const x = $derived(..)` because one is not a subscription to the other
!(
name === '$derived' &&

@ -3,11 +3,7 @@ import { walk } from 'zimmerframe';
import { is_element_node } from './nodes.js';
import * as b from '../utils/builders.js';
import { error } from '../errors.js';
import {
extract_identifiers,
extract_identifiers_from_expression,
get_callee_name
} from '../utils/ast.js';
import { extract_identifiers, extract_identifiers_from_expression } from '../utils/ast.js';
import { Runes } from './constants.js';
export class Scope {

@ -20,19 +20,6 @@ export function object(expression) {
return expression;
}
/**
* Returns the name of callee if the given expression is a call expression.
* @param {import('estree').Expression | null | undefined} node
*/
export function get_callee_name(node) {
if (!node) return null;
if (node.type !== 'CallExpression') return null;
if (node.callee.type !== 'Identifier' && node.callee.type !== 'MemberExpression') return null;
const id = object(node.callee);
return id === null ? null : id.name;
}
/**
* Returns true if the attribute contains a single static text node.
* @param {import('#compiler').Attribute} attribute

Loading…
Cancel
Save