You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@
6
6
***breaking** Minimum supported TypeScript version is now 5 (it will likely work with lower versions, but we make no guarantess about that)
7
7
***breaking** Stricter types for `createEventDispatcher` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224))
8
8
***breaking** Stricter types for `Action` and `ActionReturn` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224))
9
+
***breaking** Stricter types for `onMount` - now throws a type error when returning a function asynchronously to catch potential mistakes around callback functions (see PR for migration instructions) ([#8136](https://github.com/sveltejs/svelte/pull/8136))
* It must be called during the component's initialisation (but doesn't need to live *inside* the component;
28
28
* it can be called from an external module).
29
29
*
30
+
* If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted.
31
+
*
30
32
* `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api).
31
33
*
32
34
* https://svelte.dev/docs#run-time-svelte-onmount
33
35
*/
34
-
exportfunctiononMount(fn: ()=>any){
36
+
exportfunctiononMount<T>(fn: ()=>TextendsPromise<()=>any> ? "Returning a function asynchronously from onMount won't call that function on destroy" : T): void{
0 commit comments