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
-`Action` and `ActionReturn` have a default parameter type of `undefined` now, which means you need to type the generic if you want to specify that this action receives a parameter. The migration script will migrate this automatically ([#7442](https://github.com/sveltejs/svelte/pull/7442))
58
58
59
-
```diff
60
-
-const action: Action = (node, params) => { .. } // this is now an error if you use params in any way
61
-
+const action: Action<HTMLElement, string> = (node, params) => { .. } // params is of type string
59
+
```ts
60
+
// @noErrors
61
+
---const action:Action= (node, params) => { ... } // this is now an error if you use params in any way---
62
+
+++const action:Action<HTMLElement, string> = (node, params) => { ... } // params is of type string+++
62
63
```
63
64
64
65
-`onMount` now shows a type error if you return a function asynchronously from it, because this is likely a bug in your code where you expect the callback to be called on destroy, which it will only do for synchronously returned functions ([#8136](https://github.com/sveltejs/svelte/issues/8136))
65
66
66
-
```diff
67
+
```js
68
+
// @noErrors
67
69
// Example where this change reveals an actual bug
68
70
onMount(
69
-
-// someCleanup() not called because function handed to onMount is async
70
-
-async () => {
71
-
-const something = await foo();
72
-
+// someCleanup() is called because function handed to onMount is sync
73
-
+() => {
74
-
+foo().then(something => ..
75
-
// ..
76
-
return () => someCleanup();
77
-
}
71
+
---// someCleanup() not called because function handed to onMount is async
72
+
async () => {
73
+
constsomething=awaitfoo();---
74
+
+++// someCleanup() is called because function handed to onMount is sync
75
+
() => {
76
+
foo().then(something=>{...});
77
+
//...
78
+
return () =>someCleanup();
79
+
}
78
80
);
79
81
```
80
82
81
83
## Custom Elements with Svelte
82
84
83
85
The creation of custom elements with Svelte has been overhauled and significantly improved. The `tag` option is deprecated in favor of the new `customElement` option:
This change was made to allow [more configurability](custom-elements-api#component-options) for advanced use cases. The migration script will adjust your code automatically. The update timing of properties has changed slightly as well. ([#8457](https://github.com/sveltejs/svelte/issues/8457))
@@ -93,28 +95,27 @@ This change was made to allow [more configurability](custom-elements-api#compone
93
95
94
96
`SvelteComponentTyped` is deprecated, as `SvelteComponent` now has all its typing capabilities. Replace all instances of `SvelteComponentTyped` with `SvelteComponent`.
If you have used `SvelteComponent` as the component instance type previously, you may see a somewhat opaque type error now, which is solved by changing `:typeof SvelteComponent` to `:typeof SvelteComponent<any>`.
0 commit comments