pull/11294/head
Rich Harris 2 years ago
parent b813d8cb27
commit f69b18eb12

@ -1,3 +1,3 @@
## cyclical_reactive_declaration
Cyclical dependency detected: %cycle.join(' → ')%
Cyclical dependency detected: %cycle%

@ -48,7 +48,7 @@ export class CompileError extends Error {
/**
*
* @param {number | NodeLike} node
* @param {null | number | NodeLike} node
* @param {string} code
* @param {string} message
* @returns {never}
@ -65,7 +65,7 @@ function e(node, code, message) {
}
/**
* @param {number | NodeLike} node
* @param {null | number | NodeLike} node
* @param {string} PARAMETER
* @returns {never}
*/

@ -20,46 +20,9 @@ const internal = {
`Internal compiler error: ${message}. Please report this to https://github.com/sveltejs/svelte/issues`
};
/** @satisfies {Errors} */
const variables = {
'illegal-global': /** @param {string} name */ (name) =>
`${name} is an illegal variable name. To reference a global variable called ${name}, use globalThis.${name}`,
/** @param {string} name */
'duplicate-declaration': (name) => `'${name}' has already been declared`,
'default-export': () => `A component cannot have a default export`,
'illegal-variable-declaration': () =>
'Cannot declare same variable name which is imported inside <script context="module">',
'illegal-store-subscription': () =>
'Cannot subscribe to stores that are not declared at the top level of the component'
};
/** @satisfies {Errors} */
const legacy_reactivity = {
'cyclical-reactive-declaration': /** @param {string[]} cycle */ (cycle) =>
`Cyclical dependency detected: ${cycle.join(' → ')}`
};
/** @satisfies {Errors} */
const compiler_options = {
/** @param {string} msg */
'invalid-compiler-option': (msg) => `Invalid compiler option: ${msg}`,
/** @param {string} msg */
'removed-compiler-option': (msg) => `Invalid compiler option: ${msg}`
};
/** @satisfies {Errors} */
const const_tag = {
'invalid-const-placement': () =>
`{@const} must be the immediate child of {#snippet}, {#if}, {:else if}, {:else}, {#each}, {:then}, {:catch}, <svelte:fragment> or <Component>`
};
/** @satisfies {Errors} */
const errors = {
...internal,
// ...variables,
...compiler_options,
...legacy_reactivity,
...const_tag
...internal
// missing_contenteditable_attribute: {
// code: 'missing-contenteditable-attribute',

File diff suppressed because it is too large Load Diff

@ -1426,7 +1426,7 @@ function order_reactive_statements(unsorted_reactive_declarations) {
const cycle = check_graph_for_cycles(edges);
if (cycle?.length) {
const declaration = /** @type {Tuple[]} */ (lookup.get(cycle[0]))[0];
error(declaration[0], 'cyclical-reactive-declaration', cycle);
e.cyclical_reactive_declaration(declaration[0], cycle.join(' → '));
}
// We use a map and take advantage of the fact that the spec says insertion order is preserved when iterating

@ -485,7 +485,7 @@ const validation = {
((grand_parent?.type !== 'RegularElement' && grand_parent?.type !== 'SvelteElement') ||
!grand_parent.attributes.some((a) => a.type === 'Attribute' && a.name === 'slot')))
) {
error(node, 'invalid-const-placement');
e.invalid_const_placement(node);
}
},
ImportDeclaration(node, context) {

@ -1,4 +1,5 @@
import { error } from './errors-tmp.js';
import * as e from './errors.js';
/**
* @template [Input=any]
@ -141,7 +142,7 @@ export const validate_component_options =
function removed(msg) {
return (input) => {
if (input !== undefined) {
error(null, 'removed-compiler-option', msg);
e.removed_compiler_option(null, msg);
}
return /** @type {any} */ (undefined);
};
@ -200,9 +201,8 @@ function object(children, allow_unknown = false) {
if (allow_unknown) {
output[key] = input[key];
} else {
error(
e.invalid_compiler_option(
null,
'invalid-compiler-option',
`Unexpected option ${keypath ? `${keypath}.${key}` : key}`
);
}
@ -307,5 +307,5 @@ function fun(fallback) {
/** @param {string} msg */
function throw_error(msg) {
error(null, 'invalid-compiler-option', msg);
e.invalid_compiler_option(null, msg);
}

Loading…
Cancel
Save