-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking: update onMount type definition to prevent async function re…
…turn (#8136) --------- Co-authored-by: Yuichiro Yamashita <[email protected]> Co-authored-by: Simon H <[email protected]>
- Loading branch information
1 parent
662804e
commit 350c6c3
Showing
5 changed files
with
120 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { onMount } from '$runtime/index'; | ||
|
||
// sync and no return | ||
onMount(() => { | ||
console.log('mounted'); | ||
}); | ||
|
||
// sync and return value | ||
onMount(() => { | ||
return 'done'; | ||
}); | ||
|
||
// sync and return sync | ||
onMount(() => { | ||
return () => { | ||
return 'done'; | ||
}; | ||
}); | ||
|
||
// sync and return async | ||
onMount(() => { | ||
return async () => { | ||
const res = await fetch(''); | ||
return res; | ||
}; | ||
}); | ||
|
||
// async and no return | ||
onMount(async () => { | ||
await fetch(''); | ||
}); | ||
|
||
// async and return value | ||
onMount(async () => { | ||
const res = await fetch(''); | ||
return res; | ||
}); | ||
|
||
// @ts-expect-error async and return sync | ||
onMount(async () => { | ||
return () => { | ||
return 'done'; | ||
}; | ||
}); | ||
|
||
// @ts-expect-error async and return async | ||
onMount(async () => { | ||
return async () => { | ||
const res = await fetch(''); | ||
return res; | ||
}; | ||
}); | ||
|
||
// @ts-expect-error async and return any | ||
onMount(async () => { | ||
const a: any = null as any; | ||
return a; | ||
}); |