My params are not being inferred correctly in +page.server.ts #14556
-
Hi all, just starting with svelte kit. Now if my +page.server.ts load function doesnt have params it works perfectly (on the +page.svelte the response is typed). But if I add params I get the following error: Here is the screenshot with my setup and both +page.svelte and +page.server.ts functions side by side: I have tried rerunning svelte-kit sync and npm run build but it doesnt solve the issue. Anybody have an idea what is wrong ? Thank you ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@logic-and-math I ran into the same issue on a fresh SvelteKit + TS project. From what I can tell, this happens because VS Code is using the bundled TypeScript instead of the workspace version that has the What fixed it for me:
After switching, the language service picked up the Svelte plugin correctly and the red underline went away. If it still doesn’t clear up, make sure the Svelte extension is up to date and check that your "plugins": [{ "name": "@sveltejs/ts-plugin" }] |
Beta Was this translation helpful? Give feedback.
@logic-and-math I ran into the same issue on a fresh SvelteKit + TS project.
tsc
(and VS Code when it falls back to its built-in TS service) doesn’t seem to pick up the generated$types
. That means when you destructure{ params }
in+page.server.ts
, it shows up asany
and throws TS7031, even thoughsvelte-check
reports no problems.From what I can tell, this happens because VS Code is using the bundled TypeScript instead of the workspace version that has the
@sveltejs/ts-plugin
.What fixed it for me:
After switching…