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

100% Statements 25/25
100% Branches 8/8
100% Functions 1/1
100% Lines 24/24

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 24 252x 2x 2x 2x 2x 2x 2x 2x 2x 222x 222x 222x 222x 222x 222x 222x 222x 222x 222x 222x 222x 1x 1x 222x  
/** @import { AST } from '#compiler' */
/** @import { Context } from '../types' */
import * as e from '../../../errors.js';
 
/**
 * @param {AST.LetDirective} node
 * @param {Context} context
 */
export function LetDirective(node, context) {
	const parent = context.path.at(-1);
 
	if (
		parent === undefined ||
		(parent.type !== 'Component' &&
			parent.type !== 'RegularElement' &&
			parent.type !== 'SlotElement' &&
			parent.type !== 'SvelteElement' &&
			parent.type !== 'SvelteComponent' &&
			parent.type !== 'SvelteSelf' &&
			parent.type !== 'SvelteFragment')
	) {
		e.let_directive_invalid_placement(node);
	}
}