Skip to content

Commit

Permalink
fix(v2_meta): hint data as being potentially undefined (#6231)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Brophy <matt@brophy.org>
  • Loading branch information
machour and brophdawg11 committed May 5, 2023
1 parent b1c0fbb commit d8bcdc1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/v2-meta-loader-data-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@remix-run/react": patch
"@remix-run/server-runtime": patch
---

Fix `data` parameter typing on `V2_MetaFunction` to include `undefined` for scenarios in which the `loader` threw to it's own boundary.
4 changes: 3 additions & 1 deletion packages/remix-react/routeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ export interface V2_MetaArgs<
Loader extends LoaderFunction | unknown = unknown,
MatchLoaders extends Record<string, unknown> = Record<string, unknown>
> {
data: Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData;
data:
| (Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData)
| undefined;
params: Params;
location: Location;
matches: V2_MetaMatches<MatchLoaders>;
Expand Down
4 changes: 3 additions & 1 deletion packages/remix-server-runtime/routeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ export interface V2_ServerRuntimeMetaArgs<
Loader extends LoaderFunction | unknown = unknown,
MatchLoaders extends Record<string, unknown> = Record<string, unknown>
> {
data: Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData;
data:
| (Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData)
| undefined;
params: Params;
location: Location;
matches: V2_ServerRuntimeMetaMatches<MatchLoaders>;
Expand Down

0 comments on commit d8bcdc1

Please sign in to comment.