Open Kworz opened 8 months ago
I don't quite understand the use case for this. If you're in the routes files you can use the data props instead of the page store. If you're in a non-route component or a parent layout file, there isn't a specific path to "fine-grain" the global type. Can you provide an example repo that showcases the problem you're facing?
I'm facing this issue in this repo https://github.com/Kworz/mink
in the hooks.server.ts
we can see that not all the locals are filled with data due to their route context, that is why types based on routes would be a great addition
Describe the problem
Defining globals for PageData is fine for most of the time. But when you are splitting your app in 2 or more named layouts with with specific data being loaded in
+layout.ts / +layout.server.ts
it's frustrating to have to force non-null checking for data that will always be there.For example:
Leads to having ESLint being completely lost here, as data is there but typed as optional.
Describe the proposed solution
The actual way of defining global app types should not be modified as it works fine for almost everyone. We could add something like:
Alternatives considered
As stated in the docs
Use optional properties for data that is only present on specific pages.
works fine tbh, juste let ESLint scream at you and be confident about your data structure.Importance
would make my life easier
Additional Information
No response