Skip to content
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

__error generated types should use ErrorLoad instead of Load. #4398

Closed
f-elix opened this issue Mar 20, 2022 · 2 comments
Closed

__error generated types should use ErrorLoad instead of Load. #4398

f-elix opened this issue Mar 20, 2022 · 2 comments
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. types / typescript
Milestone

Comments

@f-elix
Copy link
Contributor

f-elix commented Mar 20, 2022

Describe the bug

The types generated at ./.sveltekit/types/src/routes/__error.d.ts by Sveltekit use the generic Load function type instead of the ErrorLoad type, which causes errors to show up when using the error and status parameters in the function.

Reproduction

https://github.com/f-elix/sveltekit-generated-types-error

You can open this repo in vscode to see the errors in __error.svelte. npm run check will also display the errors in the terminal.

Logs

No response

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
    Memory: 26.30 GB / 39.76 GB
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (98.0.1108.43)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.33
    @sveltejs/kit: next => 1.0.0-next.301
    svelte: ^3.44.0 => 3.46.4

Severity

annoyance

Additional Information

I can use the ErrorLoad type provided by Sveltekit to work around that.

@Rich-Harris
Copy link
Member

Relatedly, I sort of wonder if we shouldn't just have a single Load type where status and error are both null in the default case. (This thinking also prompted by the addition of page endpoints, which mean that a non-error load can be called even if the status code is a 4xx/5xx, even though we're not currently using it — #4328)

@benmccann benmccann added bug Something isn't working types / typescript p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. labels Mar 21, 2022
@benmccann benmccann added this to the 1.0 milestone Mar 21, 2022
@Rich-Harris
Copy link
Member

Going to close this in favour of #4461, where we're plotting the removal of ErrorLoad altogether

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. types / typescript
Projects
None yet
Development

No branches or pull requests

3 participants