6

I'm trying to import the PageLoad function for the SvelteKit load function according to the docs.

The import does not seem to exist. This is a brand new app with the latest version of SvelteKit. It will find the PageLoadData just fine.

src/routes/+page.server.ts

+page.server.ts

I also tried this post, but I am already doing everything it says.

Thanks,

J

Jonathan
  • 3,893
  • 5
  • 46
  • 77
  • 2
    Have you tried restarting the dev server? You can also remove the types file (`.svelte-kit/types/src/routes/$types.d.ts`) and see what gets generated/regenerated. – H.B. Oct 19 '22 at 23:58
  • 2
    By the way, the type is in the wrong place, it should be `load: PageServerLoad`. – H.B. Oct 20 '22 at 00:08
  • 2
    I restarted VS Code and it worked. I swear I did that several times before. Weird. Thanks! – Jonathan Oct 20 '22 at 00:14
  • Should be closed as duplicate of [SvelteKit, import type LayoutServerLoad/PageLoad](https://stackoverflow.com/questions/74060175/sveltekit-import-type-layoutserverload-pageload) – H.B. Oct 20 '22 at 00:34
  • 3
    For anyone reading this, the automatic type creation is buggy. You have to restart vs-code sometimes when you rename or create a new route, and you have to `npm run dev` on and off again for it to work. – Jonathan Oct 20 '22 at 01:32

0 Answers0