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
The documentation for providing a return function from onMount states
This behaviour will only work when the function passed to onMount synchronously returns a value. async functions always return a Promise, and as such cannot synchronously return a function.
Which accepts return functions, even when async. This causes a silent failure, which is impossible to detect without reading the documentation. The error can happen when someone converts an existing onMount with a destroy callback to async.
Strictly typing it like below makes TS throw an error when a function is returned wrapped in a promise.
<scriptlang="ts">
import { onMount } from'svelte';onMount(async () => {// ^ No error// .... await someThingreturn () => {// Destroyed will not be call as the function is async. }; });
</script>
Logs
No response
System Info
"svelte": "^3.59.1"
Severity
annoyance
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
The documentation for providing a return function from
onMount
statesBut, the generated type in
lifecycle.d.ts
isWhich accepts return functions, even when async. This causes a silent failure, which is impossible to detect without reading the documentation. The error can happen when someone converts an existing
onMount
with a destroy callback to async.Strictly typing it like below makes TS throw an error when a function is returned wrapped in a promise.
Error after changing type.
Reproduction
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: