Skip to content

Commit

Permalink
Fix typings for MetaMatch across server and client
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Aug 24, 2023
1 parent ebc148c commit 779e123
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
15 changes: 12 additions & 3 deletions packages/remix-react/routeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export interface MetaMatch<
}

export type MetaMatches<
MatchLoaders extends Record<string, unknown> = Record<string, unknown>
MatchLoaders extends Record<string, LoaderFunction> = Record<
string,
LoaderFunction
>
> = Array<
{
[K in keyof MatchLoaders]: MetaMatch<
Expand All @@ -67,7 +70,10 @@ export type MetaMatches<

export interface MetaArgs<
Loader extends LoaderFunction | unknown = unknown,
MatchLoaders extends Record<string, unknown> = Record<string, unknown>
MatchLoaders extends Record<string, LoaderFunction> = Record<
string,
LoaderFunction
>
> {
data:
| (Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData)
Expand All @@ -80,7 +86,10 @@ export interface MetaArgs<

export interface MetaFunction<
Loader extends LoaderFunction | unknown = unknown,
MatchLoaders extends Record<string, unknown> = Record<string, unknown>
MatchLoaders extends Record<string, LoaderFunction> = Record<
string,
LoaderFunction
>
> {
(args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
}
Expand Down
16 changes: 13 additions & 3 deletions packages/remix-server-runtime/routeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ export interface LoaderFunction {
*/
export interface ServerRuntimeMetaFunction<
Loader extends LoaderFunction | unknown = unknown,
ParentsLoaders extends Record<string, LoaderFunction> = {}
ParentsLoaders extends Record<string, LoaderFunction> = Record<
string,
LoaderFunction
>
> {
(
args: ServerRuntimeMetaArgs<Loader, ParentsLoaders>
Expand All @@ -148,10 +151,14 @@ interface ServerRuntimeMetaMatch<
handle?: unknown;
params: AgnosticRouteMatch["params"];
meta: ServerRuntimeMetaDescriptor[];
error?: unknown;
}

type ServerRuntimeMetaMatches<
MatchLoaders extends Record<string, unknown> = Record<string, unknown>
MatchLoaders extends Record<string, LoaderFunction> = Record<
string,
LoaderFunction
>
> = Array<
{
[K in keyof MatchLoaders]: ServerRuntimeMetaMatch<
Expand All @@ -163,7 +170,10 @@ type ServerRuntimeMetaMatches<

export interface ServerRuntimeMetaArgs<
Loader extends LoaderFunction | unknown = unknown,
MatchLoaders extends Record<string, unknown> = Record<string, unknown>
MatchLoaders extends Record<string, LoaderFunction> = Record<
string,
LoaderFunction
>
> {
data:
| (Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData)
Expand Down

0 comments on commit 779e123

Please sign in to comment.