Zero-config type-safety doesn't work properly with `PageData`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
The PageData interface is meant to define a set of properties that every page's load function must return as part of its "data" object.
With the new zero-config type-safety, however, it seems like this is not working as expected. The return types of the load functions aren't typed according to PageData, and there will be no errors even if you haven't provided a required property, there's no typing at all:
With this app.d.ts:
declare global {
namespace App {
interface PageData {
meta: {
title: string;
};
}
}
}
export {};
This +page.ts yields no errors:
export function load() {
return {};
}
And there are no relevant suggestions, etc:

The return type is typed without regard to PageData:

It may be worth noting the classic explicitly-typed load functions still work properly in this respect:

Reproduction
Described above.
Logs
No response
System Info
System:
OS: Linux 5.10 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Memory: 1.65 GB / 3.84 GB
Container: Yes
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.12.1 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 9.3.0 - /usr/bin/npm
npmPackages:
@sveltejs/adapter-auto: ^2.0.0 => 2.0.1
@sveltejs/kit: ^1.5.0 => 1.15.9
svelte: ^3.54.0 => 3.58.0
vite: ^4.3.0 => 4.3.3
Severity
blocking an upgrade
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in app.d.ts and +page.ts, then inspect the zero-config type-safety path described in the issue. The fix is done when a load function returning {} reports the required PageData.meta property while explicitly typed load functions continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100