Replies: 1 comment
-
|
It might be possible to do something with the autogenerated types, but since they are generated per-page, they probably cannot easily be targeted automatically without extra tooling. This should become less of an issue once remote functions are stable and supersede |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As we know, SvelteKit allows child routes to return data that will overwrite the values in that were returned by a parent layout load function. This is often useful, but sometimes can lead to certain footguns.
As a simple example:
Then anywhere that references
page.data.userwhen under theusers/[userId]route will be unexpectedly looking at the wrong data.This is a simple, contrived example, but as apps grow this class of bug becomes more likely.
I'm about to write an ESLint plugin for my own project which will prevent returning certain keys from non-root layout load functions, which should be sufficient to catch the majority of these cases. But I was wondering if anyone thinks this might be a good feature to build into SvelteKit itself.
Something like this. (Don't think about the actual name of configuration key too much. I just picked something quickly to illustrate the idea)
Beta Was this translation helpful? Give feedback.
All reactions