You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been having this annoying issue in VS Code, where I open a SvelteKit file (page, layout, hooks etc.) and I can see that Typescript is not working properly as some parameters are not getting their types inferred correctly, and instead I get a bunch of anys. However, if I remove the parameter and then retype in again, without any other changes whatsoever, it magically starts working just fine.
I tried to capture the issue in the recording. Do you know what might be causing the issue?
Run the dev server: npm run dev => TYPES ARE CORRECT.
Open file src/routes/sverdle/+page.server.ts in a new editor tab.
Close the editor, shut down the dev server, and then reopen VS Code again.
Switch to the +page.server.ts that we just added => TYPES ARE BROKEN
Sometimes, to see the wrong types, it might take up to a couple of tries of closing and reopening the editor, but regardless of that it happens very consistently.
The only way to get the appropriate types back is to remove the parameter, and then retype it again without any other modifications (I demonstrated that in the video recording above).
Describe the bug
I've been having this annoying issue in VS Code, where I open a SvelteKit file (page, layout, hooks etc.) and I can see that Typescript is not working properly as some parameters are not getting their types inferred correctly, and instead I get a bunch of anys. However, if I remove the parameter and then retype in again, without any other changes whatsoever, it magically starts working just fine.
I tried to capture the issue in the recording. Do you know what might be causing the issue?
Screen.Recording.2023-08-25.at.16.18.23.mov
My app.d.ts file:
I've also tried running
npx svelte-kit sync
but it didn't change anything.Reproduction
I've managed to reproduce it with the default SvelteKit demo:
Create a new SvelteKit project using CLI:
npm create svelte@latest my-app
cd my-app && npm install
and then open VS CodeCreate a new
+page.server.ts
file insrc/routes/sverdle/how-to-play/
with the following content:Run the dev server:
npm run dev
=> TYPES ARE CORRECT.Open file
src/routes/sverdle/+page.server.ts
in a new editor tab.Close the editor, shut down the dev server, and then reopen VS Code again.
Switch to the
+page.server.ts
that we just added => TYPES ARE BROKENSometimes, to see the wrong types, it might take up to a couple of tries of closing and reopening the editor, but regardless of that it happens very consistently.
The only way to get the appropriate types back is to remove the parameter, and then retype it again without any other modifications (I demonstrated that in the video recording above).
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: