-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LayoutServerLoad return type is not compatible with simple interface object #5963
Comments
https://github.com/tcc-sejohnson/kit-broken-layout-server-typings Here's another repro. Turns out this can bite you even if you just have an explicitly typed variable as part of your return signature. |
Does changing it to a -export interface Session {
+export type Session = {
authToken: string;
} Not that that's a solution — ideally it'd work either way — but it'd be useful information, and is a possible workaround |
It works that way, yes, but it sucks to do that. This is essentially the reincarnation of that problem we had with the old types, which is why we introduced the |
For deep interfaces type aliasing on the root like this |
Ok so here's my summary of the issue(s): |
* Fix params and parent data types * add output generic to load function types, helps with #5963 * remove JSONObject, add event types to $types * fix types * changeset
Describe the bug
If you explicitly declare the return type of the
load
function in+layout.server.ts
, then you will be told by typescript that it doesn't match the expected return type. For example:Specifically you get this nice error:
Running
npm run check
will output the above error if you don't get it directly in your development environmentReproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-o1ssqr?file=src%2Froutes%2F%2Blayout.server.ts,package.json&terminal=dev
Stackblitz can't find the
./$types
so it doesn't actually reproduce the error...Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: