Skip to content

Commit 52e6fa8

Browse files
committed
cheeky hack to keep treeshakeability until we can nuke this validation altogether
1 parent b35af52 commit 52e6fa8

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

packages/svelte/src/internal/shared/errors.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
import { DEV } from 'esm-env';
44

5+
/**
6+
* Cannot use `{@render children(...)}` if the parent component uses `let:` directives. Consider using a named snippet instead
7+
* @returns {never}
8+
*/
9+
export function invalid_default_snippet() {
10+
if (DEV) {
11+
const error = new Error(`invalid_default_snippet\nCannot use \`{@render children(...)}\` if the parent component uses \`let:\` directives. Consider using a named snippet instead`);
12+
13+
error.name = 'Svelte error';
14+
throw error;
15+
} else {
16+
// TODO print a link to the documentation
17+
throw new Error("invalid_default_snippet");
18+
}
19+
}
20+
521
/**
622
* `%name%(...)` can only be used during component initialisation
723
* @param {string} name
@@ -82,20 +98,4 @@ export function svelte_element_invalid_this_value() {
8298
// TODO print a link to the documentation
8399
throw new Error("svelte_element_invalid_this_value");
84100
}
85-
}
86-
87-
/**
88-
* Cannot use `{@render children(...)}` if the parent component uses `let:` directives. Consider using a named snippet instead
89-
* @returns {never}
90-
*/
91-
export function invalid_default_snippet() {
92-
if (DEV) {
93-
const error = new Error(`invalid_default_snippet\nCannot use \`{@render children(...)}\` if the parent component uses \`let:\` directives. Consider using a named snippet instead`);
94-
95-
error.name = 'Svelte error';
96-
throw error;
97-
} else {
98-
// TODO print a link to the documentation
99-
throw new Error("invalid_default_snippet");
100-
}
101101
}

packages/svelte/src/internal/shared/validate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const invalid_default_snippet = add_snippet_symbol(e.invalid_default_snip
1212
* @param {any} fn
1313
* @returns {import('svelte').Snippet}
1414
*/
15+
/*@__NO_SIDE_EFFECTS__*/
1516
export function add_snippet_symbol(fn) {
1617
fn[snippet_symbol] = true;
1718
return fn;

0 commit comments

Comments
 (0)