All files / src/compiler/phases/2-analyze/visitors TaggedTemplateExpression.js

100% Statements 24/24
100% Branches 1/1
100% Functions 1/1
100% Lines 23/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 242x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x  
/** @import { TaggedTemplateExpression, VariableDeclarator } from 'estree' */
/** @import { Context } from '../types' */
import { is_pure } from './shared/utils.js';
 
/**
 * @param {TaggedTemplateExpression} node
 * @param {Context} context
 */
export function TaggedTemplateExpression(node, context) {
	if (context.state.expression && !is_pure(node.tag, context)) {
		context.state.expression.has_call = true;
		context.state.expression.has_state = true;
	}
 
	if (node.tag.type === 'Identifier') {
		const binding = context.state.scope.get(node.tag.name);
 
		if (binding !== null) {
			binding.is_called = true;
		}
	}
	context.next();
}