Skip to content

Zero-config type-safety doesn't work properly with PageData #9799

@aradalvand

Description

@aradalvand

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:
image

The return type is typed without regard to PageData:
image

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions