-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(remix-server-runtime): MetaFunction
type infers data
and parentsData
types from loaders
#4022
feat(remix-server-runtime): MetaFunction
type infers data
and parentsData
types from loaders
#4022
Conversation
🦋 Changeset detectedLatest commit: 591895a The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
data: Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData; | ||
parentsData: { | ||
[k in keyof ParentsLoaders]: SerializeFrom<ParentsLoaders[k]>; | ||
} & RouteData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppData
and RouteData
included for backwards compatibility. In v2, we should change AppData
to unknown
and remove the need for AppData
and RouteData
here:
// In Remix v2:
export interface MetaFunction<
Loader extends LoaderFunction,
ParentsLoaders extends Record<string, LoaderFunction> = {}
> {
(args: {
data: SerializeFrom<Loader>;
parentsData: {
[k in keyof ParentsLoaders]: SerializeFrom<ParentsLoaders[k]>;
};
...
data
and parentsData
types …data
and parentsData
types from loaders
data
and parentsData
types from loadersMetaFunction
type infers data
and parentsData
types from loaders
8a46f3d
to
60b10a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Since this is technically new API, wanna get one more set of eyes before merging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holy crap I love this 👍
@pcattori could you add some docs on this in the MetaFunction docs? |
60b10a3
to
591895a
Compare
MetaFunction
type infers data
and parentsData
types from loadersMetaFunction
type infers data
and parentsData
types from loaders
Supercedes #928
See usage example in new jsdoc for
MetaFunction
or in the changesetTesting Strategy: I tried out the example shown in the jsdoc locally