Skip to content
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

Types are not properly updated for routes under group layouts #6842

Closed
williamviktorsson opened this issue Sep 15, 2022 · 2 comments · Fixed by #6843
Closed

Types are not properly updated for routes under group layouts #6842

williamviktorsson opened this issue Sep 15, 2022 · 2 comments · Fixed by #6843

Comments

@williamviktorsson
Copy link
Contributor

Describe the bug

When altering return values from actions / load functions in +page.server.(ts/js) , the corresponding types are automagically updated while running npm run dev.

This experience breaks for routes under layout groups.

Under layout groups, one seems to be required to run npx svelte-kit sync and restart the language server if running vscode to get the latest types.

When moving such routes with said issue, away from a layout group, the wonderful DX resumes.

Reproduction

This is a reproduction of the issue, taking the base demo-todo-app and putting all routes under a shared (groups) layout group.

Running the project and updating any return values from e.g. the (groups)/login/+page.server.js does not trigger an update in the generated types.

Moving the same route out of the (groups) layout group fixes the issue.

https://github.com/williamviktorsson/layout-groups-typing-bug

Logs

No response

System Info

System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
    Memory: 2.03 GB / 7.92 GB
  Binaries:
    Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.18.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 105.0.5195.102
    Edge: Spartan (44.18362.1533.0)
    Internet Explorer: 11.0.18362.1
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.75
    @sveltejs/kit: next => 1.0.0-next.483
    svelte: ^3.46.0 => 3.50.1
    vite: ^3.1.0 => 3.1.1

Severity

serious, but I can work around it

Additional Information

Layout groups reduce boilerplate code amongst other things, improving DX.

However, losing the great typing experience is a larger loss in DX.

@williamviktorsson
Copy link
Contributor Author

If it helps.

It looks like line 74-75 in @sveltejs\kit\src\core\sync\write_types\index.js has to do with it.

const route = manifest_data.routes.find((route) => route.id === id);
if (!route) return; // this shouldn't ever happen 

route is however undefined for routes under a (layout group)

williamviktorsson added a commit to williamviktorsson/kit that referenced this issue Sep 15, 2022
Fixes sveltejs#6842: Types are not properly updated for routes under group layouts

routes were not found by id under group layouts. replacing '\' with '/' fixes this for route id's.
@williamviktorsson
Copy link
Contributor Author

williamviktorsson commented Sep 15, 2022

Seemingly a windows related bug as it relates to route id's not being found under layout groups, with the occurance of '\' in routes rather than '/'

I was not able to reproduce the issue on a Mac.

Rich-Harris added a commit that referenced this issue Sep 16, 2022
* fix route's not being found by id under group layouts

Fixes #6842: Types are not properly updated for routes under group layouts

routes were not found by id under group layouts. replacing '\' with '/' fixes this for route id's.

* update to conform to linting

* Update packages/kit/src/core/sync/write_types/index.js

* Update packages/kit/src/core/sync/write_types/index.js

* Create six-pants-melt.md

Co-authored-by: Rich Harris <hello@rich-harris.dev>
dummdidumm pushed a commit that referenced this issue Sep 20, 2022
actually fix write_types on windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant