1

I'm confused by the svelte-kit docs.

I started an empty project, trying to get to know svelte, trying to create a basic app.

I want to do dynamic routes and as a base for my +page.ts file i used this.

I see types being imported via the jsdoc annotation, but how do I import them the usual way, like import { Stuff } from "./$types". This doesn't seem to work. And actually the PageLoad type imported via jsdoc syntax also doesn't provide any typing - I see a warning saying that params has any type.

Is there a good basic example app written in TypeScript? Examples that I found were outdated.

I'm using WebStorm.

enter image description here

RCKT
  • 141
  • 2
  • 12

1 Answers1

0

The regular import syntax should work, but the dev server has to be running for the types to be generated in the first place. (Alternatively you can run svelte-kit sync to update the types once.)

H.B.
  • 166,899
  • 29
  • 327
  • 400
  • Ok, I can import the type, but it still doesn't seem to work. The code works, but the types in WebStorm don't. I updated the question with a screenshot. – RCKT Dec 13 '22 at 19:47
  • 1
    You are using the type the wrong way. `PageLoad` is not for the argument, it's the whole function: `export const load: PageLoad = ({ params }) => ...` – H.B. Dec 13 '22 at 22:37