Replies: 9 comments 6 replies
-
Beta Was this translation helpful? Give feedback.
-
I'm going to convert this to a discussion so it can go through our new Open Development process. Please upvote the new Proposal if you'd like to see this considered! |
Beta Was this translation helpful? Give feedback.
-
Related PR to ensure we have typings on |
Beta Was this translation helpful? Give feedback.
-
I've been working on a typesafe wrapper library for React Router (https://github.com/jamesopstad/typesafe-router) and would like to build in better support for the various data types that can be returned by loaders. Currently, I'd be happy to put together a PR if you are in favour of this approach. It would also benefit regular React Router users. |
Beta Was this translation helpful? Give feedback.
-
Doesn't this just hide the As they say in https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes
Overall you might even argue that we're worse off, because disguising the type assertion in this way renders it invisible from tooling such as https://github.com/plantain-00/type-coverage that would otherwise be able to warn us about the |
Beta Was this translation helpful? Give feedback.
-
@brophdawg11 Do you have any update on this? I've looked at the Roadmap but it doesn't seem completely up-to-date and can't find this issue on it. |
Beta Was this translation helpful? Give feedback.
-
I was quite surprised to not find |
Beta Was this translation helpful? Give feedback.
-
Generics should also work with |
Beta Was this translation helpful? Give feedback.
-
any updates on this? seems like a strange gap in the toolkit to have… |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What is the new or updated feature that you are suggesting?
Instead of returning
unknown
by default and then typecasting (as seen in one of the examples), prefer generics:Bad
Good
The same should be applied to
useRouteLoaderData
anduseActionData
and it should account fordefer
as well (see #9641 and #9642).Why should this feature be included?
Generics over typecasting.
Beta Was this translation helpful? Give feedback.
All reactions