Type the meta function's data and parentData properties as potentially undefined #5522
andrelandgraf
started this conversation in
Proposals
Replies: 1 comment
-
Doing But MetaFunction accepts a generic now I think, so it could be |
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.
-
The route's meta function runs even if a loader throws an error. In such cases, the data property is undefined. Currently, the data property is typed as
any
.We mostly access loader data from the route's component, where it is always defined. In meta functions, it can be undefined, but the current types don't highlight this.
It's too easy to forget about this during development. It would be great if Remix could highlight that the
data
property can be undefined by making it optional or typing it asany | undefined
- or something similar!Beta Was this translation helpful? Give feedback.
All reactions