function wrap_snippet(component, fn) {
	const snippet = (/** @type {TemplateNode} */ node, /** @type {any[]} */ ...args) => {
		var previous_component_function = dev_current_component_function;
		set_dev_current_component_function(component);

		try {
			return fn(node, ...args);
		} finally {
			set_dev_current_component_function(previous_component_function);
		}
	};

	prevent_snippet_stringification(snippet);

	return snippet;
}
In development, wrap the snippet function so that it passes validation, and so that the
correct component context is set for ownership checks
@param {any} component
@param {(node: TemplateNode, ...args: any[]) => void} fn