Skip to content

Broken auto generation of types #6444

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

Closed
icalvin102 opened this issue Aug 30, 2022 · 4 comments · Fixed by #6450
Closed

Broken auto generation of types #6444

icalvin102 opened this issue Aug 30, 2022 · 4 comments · Fixed by #6450
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. types / typescript

Comments

@icalvin102
Copy link
Contributor

Describe the bug

The auto generated types like PageData are not updated automatically when editing files in newer svelte-kit versions.

Example: Changing the return type of the load function in +page.server.ts does not automatically change the import('./$types').PageData type in +page.svelte

I first thought that it might be an issue with nvim+lsp but I get the same behavior using vscode.
It seems that this is caused by svelte-kit sync not running automatically on write of a file.

Running svelte-kit sync manually generates the correct types. However reopening the editor or restarting the svelte-languageserver is necessary in order to display the changed types correctly in the editor.

I don't remember that I had this issue in versions prior to the big change of the load API.
The behavior is present in a project that I'm currently migrating to 1.0.0-next.406 and in a fresh 1.0.0-next.454 project that I created with npm init svelte@latest (see reproduction example)

Reproduction

Setup

Check automatic type (re)generation

  • Open src/routes/+page.server.ts
  • Change property name of return value from foo to something else
  • Save file
  • Open scr/routes/+page.svelte
  • Check if hover info on PageData reflects the above changes
  • Repeat a few times

Check manual type (re)generation

  • Open src/routes/+page.server.ts
  • Change property name of return value from foo to something else
  • Save file
  • Open scr/routes/+page.svelte
  • Check if hover info on PageData reflects the above changes
  • Run npm run sync
  • Restart svelte language server or restart editor
  • Check if hover info on PageData reflects the above changes

Logs

No response

System Info

Editors:
  NVIM: v0.7.2
  vscodium: 1.70.2.22230-2
  svelte-languageserver: 0.14.33 

System:
  OS: Linux 5.19 Arch Linux
  CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
  Memory: 12.34 GB / 31.29 GB
  Container: Yes
  Shell: 5.1.16 - /bin/bash
Binaries:
  Node: 16.16.0 - /usr/bin/node
  npm: 8.17.0 - /usr/bin/npm
Browsers:
  Brave Browser: 104.1.42.88
  Firefox: 103.0.2
npmPackages:
  @sveltejs/adapter-auto: next => 1.0.0-next.69
  @sveltejs/kit: next => 1.0.0-next.454
  svelte: ^3.44.0 => 3.49.0
  vite: ^3.1.0-beta.1 => 3.1.0-beta.1

Severity

blocking an upgrade

Additional Information

No response

@elliott-with-the-longest-name-on-github
Copy link
Contributor

Does Ctrl+Shift+p > Restart Svelte language server update the types when you have the dev server running?

@icalvin102
Copy link
Contributor Author

icalvin102 commented Aug 30, 2022

@tcc-sejohnson running the dev server generates the types only once at the start. HMR on file write works as usual though.

Restarting the language server has no effect unless svelte-kit sync is run manually.

The language server only shows the wrong information because the types in the .sveltekit directory are not up to date.

@elliott-with-the-longest-name-on-github
Copy link
Contributor

Strange. I'll try to take a look today.

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github added bug Something isn't working types / typescript p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. labels Aug 30, 2022
@woss
Copy link

woss commented Nov 30, 2023

this is still occurring on latest sveltekit

my 3 sveltekit apps are in the monorepo and no types are generated for the .server or +page|layout.ts files even with the freshly created app using the docs.

maybe it helps to say that I am using the advanced routing (private) and (public)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. types / typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants