Skip to content

Commit 22f9984

Browse files
committed
simplify
1 parent 2125aca commit 22f9984

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import * as assert from '../../utils/assert.js';
55
import {
66
extract_identifiers,
77
extract_paths,
8-
get_call_expression,
98
is_event_attribute,
109
is_text_attribute,
11-
object
10+
object,
11+
unwrap_ts_expression
1212
} from '../../utils/ast.js';
1313
import * as b from '../../utils/builders.js';
1414
import { ReservedKeywords, Runes, SVGElements } from '../constants.js';
@@ -661,8 +661,8 @@ const runes_scope_js_tweaker = {
661661
/** @type {import('./types').Visitors} */
662662
const runes_scope_tweaker = {
663663
VariableDeclarator(node, { state }) {
664-
const init = get_call_expression(node);
665-
if (init === null) return;
664+
const init = unwrap_ts_expression(node.init);
665+
if (!init || init.type !== 'CallExpression') return;
666666
if (get_rune(init, state.scope) === null) return;
667667

668668
const callee = init.callee;

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -266,23 +266,6 @@ function _extract_paths(assignments = [], param, expression, update_expression)
266266
return assignments;
267267
}
268268

269-
/**
270-
* If the init of the declarator is a call expression, returns it.
271-
*
272-
* @param {import('estree').VariableDeclarator} node
273-
*/
274-
export function get_call_expression(node) {
275-
let init = node.init;
276-
if (init) {
277-
init = unwrap_ts_expression(init);
278-
if (init.type === 'CallExpression') {
279-
return init;
280-
}
281-
}
282-
283-
return null;
284-
}
285-
286269
/**
287270
* The Acorn TS plugin defines `foo!` as a `TSNonNullExpression` node, and
288271
* `foo as Bar` as a `TSAsExpression` node. This function unwraps those.

0 commit comments

Comments
 (0)