pull/9681/head
Rich Harris 3 years ago
parent 2125acac51
commit 22f9984ff6

@ -5,10 +5,10 @@ import * as assert from '../../utils/assert.js';
import {
extract_identifiers,
extract_paths,
get_call_expression,
is_event_attribute,
is_text_attribute,
object
object,
unwrap_ts_expression
} from '../../utils/ast.js';
import * as b from '../../utils/builders.js';
import { ReservedKeywords, Runes, SVGElements } from '../constants.js';
@ -661,8 +661,8 @@ const runes_scope_js_tweaker = {
/** @type {import('./types').Visitors} */
const runes_scope_tweaker = {
VariableDeclarator(node, { state }) {
const init = get_call_expression(node);
if (init === null) return;
const init = unwrap_ts_expression(node.init);
if (!init || init.type !== 'CallExpression') return;
if (get_rune(init, state.scope) === null) return;
const callee = init.callee;

@ -266,23 +266,6 @@ function _extract_paths(assignments = [], param, expression, update_expression)
return assignments;
}
/**
* If the init of the declarator is a call expression, returns it.
*
* @param {import('estree').VariableDeclarator} node
*/
export function get_call_expression(node) {
let init = node.init;
if (init) {
init = unwrap_ts_expression(init);
if (init.type === 'CallExpression') {
return init;
}
}
return null;
}
/**
* The Acorn TS plugin defines `foo!` as a `TSNonNullExpression` node, and
* `foo as Bar` as a `TSAsExpression` node. This function unwraps those.

Loading…
Cancel
Save