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
As a convenience, SvelteKit automatically awaits top-level promises in load functions, giving the return of the load functions and the actual data available to the pages a slightly different type-interface. Svelte handles this by using different types for load functions and page data.
Unfortunately, this produces type errors when attempting to strongly type the PageData interface. If the load function returns a promise with a number, the page will only receive the number, and typing the PageData interface with either a promise with a number or just a number will give of an error, either in the load function or in the page.
Errors:
If typing without promise:
"Type 'Promise<number>' is not assignable to type 'number'"
If typing with promise:
"Operator '+' cannot be applied to types '2' and 'Promise<number>'"
Is there any update on this, or can I somehow be of any help in solving this? It seems like an issue that would be general, and it's significantly holding our project back
Describe the bug
Only tested using Typescript
As a convenience, SvelteKit automatically awaits top-level promises in load functions, giving the return of the load functions and the actual data available to the pages a slightly different type-interface. Svelte handles this by using different types for load functions and page data.
Unfortunately, this produces type errors when attempting to strongly type the PageData interface. If the load function returns a promise with a number, the page will only receive the number, and typing the PageData interface with either a promise with a number or just a number will give of an error, either in the load function or in the page.
Reproduction
https://github.com/bertmad3400/sveltekit-issue
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: