|
2 | 2 | title: 'Runtime warnings'
|
3 | 3 | ---
|
4 | 4 |
|
5 |
| -## Client warnings |
| 5 | +## Client errors |
6 | 6 |
|
7 |
| -### binding_property_non_reactive |
| 7 | +### bind_invalid_checkbox_value |
8 | 8 |
|
9 | 9 | ```
|
10 |
| -`%binding%` is binding to a non-reactive property |
| 10 | +Using `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead |
11 | 11 | ```
|
12 | 12 |
|
| 13 | +### bind_invalid_export |
| 14 | + |
| 15 | +``` |
| 16 | +Component %component% has an export named `%key%` that a consumer component is trying to access using `bind:%key%`, which is disallowed. Instead, use `bind:this` (e.g. `<%name% bind:this={component} />`) and then access the property on the bound component instance (e.g. `component.%key%`) |
| 17 | +``` |
| 18 | + |
| 19 | +### bind_not_bindable |
| 20 | + |
13 | 21 | ```
|
14 |
| -`%binding%` (%location%) is binding to a non-reactive property |
| 22 | +A component is attempting to bind to a non-bindable property `%key%` belonging to %component% (i.e. `<%name% bind:%key%={...}>`). To mark a property as bindable: `let { %key% = $bindable() } = $props()` |
15 | 23 | ```
|
16 | 24 |
|
17 |
| -### console_log_state |
| 25 | +### component_api_changed |
18 | 26 |
|
19 | 27 | ```
|
20 |
| -Your `console.%method%` contained `$state` proxies. Consider using `$inspect(...)` or `$state.snapshot(...)` instead |
| 28 | +%parent% called `%method%` on an instance of %component%, which is no longer valid in Svelte 5. See https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes for more information |
21 | 29 | ```
|
22 | 30 |
|
23 |
| -When logging a [proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), browser devtools will log the proxy itself rather than the value it represents. In the case of Svelte, the 'target' of a `$state` proxy might not resemble its current value, which can be confusing. |
| 31 | +### component_api_invalid_new |
24 | 32 |
|
25 |
| -The easiest way to log a value as it changes over time is to use the [`$inspect`](https://svelte.dev/docs/svelte/$inspect) rune. Alternatively, to log things on a one-off basis (for example, inside an event handler) you can use [`$state.snapshot`](https://svelte.dev/docs/svelte/$state#$state.snapshot) to take a snapshot of the current value. |
| 33 | +``` |
| 34 | +Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.componentApi` compiler option to `4` to keep it working. See https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes for more information |
| 35 | +``` |
26 | 36 |
|
27 |
| -### event_handler_invalid |
| 37 | +### derived_references_self |
28 | 38 |
|
29 | 39 | ```
|
30 |
| -%handler% should be a function. Did you mean to %suggestion%? |
| 40 | +A derived value cannot reference itself recursively |
31 | 41 | ```
|
32 | 42 |
|
33 |
| -### hydration_attribute_changed |
| 43 | +### each_key_duplicate |
| 44 | + |
| 45 | +``` |
| 46 | +Keyed each block has duplicate key at indexes %a% and %b% |
| 47 | +``` |
34 | 48 |
|
35 | 49 | ```
|
36 |
| -The `%attribute%` attribute on `%html%` changed its value between server and client renders. The client value, `%value%`, will be ignored in favour of the server value |
| 50 | +Keyed each block has duplicate key `%value%` at indexes %a% and %b% |
37 | 51 | ```
|
38 | 52 |
|
39 |
| -### hydration_html_changed |
| 53 | +### effect_in_teardown |
40 | 54 |
|
41 | 55 | ```
|
42 |
| -The value of an `{@html ...}` block changed between server and client renders. The client value will be ignored in favour of the server value |
| 56 | +`%rune%` cannot be used inside an effect cleanup function |
43 | 57 | ```
|
44 | 58 |
|
| 59 | +### effect_in_unowned_derived |
| 60 | + |
45 | 61 | ```
|
46 |
| -The value of an `{@html ...}` block %location% changed between server and client renders. The client value will be ignored in favour of the server value |
| 62 | +Effect cannot be created inside a `$derived` value that was not itself created inside an effect |
47 | 63 | ```
|
48 | 64 |
|
49 |
| -### hydration_mismatch |
| 65 | +### effect_orphan |
50 | 66 |
|
51 | 67 | ```
|
52 |
| -Hydration failed because the initial UI does not match what was rendered on the server |
| 68 | +`%rune%` can only be used inside an effect (e.g. during component initialisation) |
53 | 69 | ```
|
54 | 70 |
|
| 71 | +### effect_update_depth_exceeded |
| 72 | + |
55 | 73 | ```
|
56 |
| -Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near %location% |
| 74 | +Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops |
57 | 75 | ```
|
58 | 76 |
|
59 |
| -### invalid_raw_snippet_render |
| 77 | +### hydration_failed |
60 | 78 |
|
61 | 79 | ```
|
62 |
| -The `render` function passed to `createRawSnippet` should return HTML for a single element |
| 80 | +Failed to hydrate the application |
63 | 81 | ```
|
64 | 82 |
|
65 |
| -### legacy_recursive_reactive_block |
| 83 | +### invalid_snippet |
66 | 84 |
|
67 | 85 | ```
|
68 |
| -Detected a migrated `$:` reactive block in `%filename%` that both accesses and updates the same reactive value. This may cause recursive updates when converted to an `$effect`. |
| 86 | +Could not `{@render}` snippet due to the expression being `null` or `undefined`. Consider using optional chaining `{@render snippet?.()}` |
69 | 87 | ```
|
70 | 88 |
|
71 |
| -### lifecycle_double_unmount |
| 89 | +### lifecycle_legacy_only |
72 | 90 |
|
73 | 91 | ```
|
74 |
| -Tried to unmount a component that was not mounted |
| 92 | +`%name%(...)` cannot be used in runes mode |
75 | 93 | ```
|
76 | 94 |
|
77 |
| -### ownership_invalid_binding |
| 95 | +### props_invalid_value |
78 | 96 |
|
79 | 97 | ```
|
80 |
| -%parent% passed a value to %child% with `bind:`, but the value is owned by %owner%. Consider creating a binding between %owner% and %parent% |
| 98 | +Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value |
81 | 99 | ```
|
82 | 100 |
|
83 |
| -### ownership_invalid_mutation |
| 101 | +### props_rest_readonly |
84 | 102 |
|
85 | 103 | ```
|
86 |
| -Mutating a value outside the component that created it is strongly discouraged. Consider passing values to child components with `bind:`, or use a callback instead |
| 104 | +Rest element properties of `$props()` such as `%property%` are readonly |
87 | 105 | ```
|
88 | 106 |
|
| 107 | +### rune_outside_svelte |
| 108 | + |
89 | 109 | ```
|
90 |
| -%component% mutated a value owned by %owner%. This is strongly discouraged. Consider passing values to child components with `bind:`, or use a callback instead |
| 110 | +The `%rune%` rune is only available inside `.svelte` and `.svelte.js/ts` files |
91 | 111 | ```
|
92 | 112 |
|
93 |
| -### state_proxy_equality_mismatch |
| 113 | +### state_descriptors_fixed |
94 | 114 |
|
95 | 115 | ```
|
96 |
| -Reactive `$state(...)` proxies and the values they proxy have different identities. Because of this, comparisons with `%operator%` will produce unexpected results |
| 116 | +Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`. |
97 | 117 | ```
|
98 | 118 |
|
99 |
| -`$state(...)` creates a [proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) of the value it is passed. The proxy and the value have different identities, meaning equality checks will always return `false`: |
| 119 | +### state_prototype_fixed |
| 120 | + |
| 121 | +``` |
| 122 | +Cannot set prototype of `$state` object |
| 123 | +``` |
100 | 124 |
|
101 |
| -```svelte |
102 |
| -<script> |
103 |
| - let value = { foo: 'bar' }; |
104 |
| - let proxy = $state(value); |
| 125 | +### state_unsafe_local_read |
105 | 126 |
|
106 |
| - value === proxy; // always false |
107 |
| -</script> |
108 | 127 | ```
|
| 128 | +Reading state that was created inside the same derived is forbidden. Consider using `untrack` to read locally created state |
| 129 | +``` |
| 130 | + |
| 131 | +### state_unsafe_mutation |
109 | 132 |
|
110 |
| -To resolve this, ensure you're comparing values where both values were created with `$state(...)`, or neither were. Note that `$state.raw(...)` will _not_ create a state proxy. |
| 133 | +``` |
| 134 | +Updating state inside a derived or a template expression is forbidden. If the value should not be reactive, declare it without `$state` |
| 135 | +``` |
111 | 136 |
|
112 | 137 |
|
113 |
| -## Shared warnings |
| 138 | +## Shared errors |
114 | 139 |
|
115 |
| -### dynamic_void_element_content |
| 140 | +### invalid_default_snippet |
116 | 141 |
|
117 | 142 | ```
|
118 |
| -`<svelte:element this="%tag%">` is a void element — it cannot have content |
| 143 | +Cannot use `{@render children(...)}` if the parent component uses `let:` directives. Consider using a named snippet instead |
119 | 144 | ```
|
120 | 145 |
|
121 |
| -### state_snapshot_uncloneable |
| 146 | +### lifecycle_outside_component |
122 | 147 |
|
123 | 148 | ```
|
124 |
| -Value cannot be cloned with `$state.snapshot` — the original value was returned |
| 149 | +`%name%(...)` can only be used during component initialisation |
125 | 150 | ```
|
126 | 151 |
|
| 152 | +### store_invalid_shape |
| 153 | + |
127 | 154 | ```
|
128 |
| -The following properties cannot be cloned with `$state.snapshot` — the return value contains the originals: |
| 155 | +`%name%` is not a store with a `subscribe` method |
| 156 | +``` |
| 157 | + |
| 158 | +### svelte_element_invalid_this_value |
129 | 159 |
|
130 |
| -%properties% |
| 160 | +``` |
| 161 | +The `this` prop on `<svelte:element>` must be a string, if defined |
131 | 162 | ```
|
132 | 163 |
|
0 commit comments