From bc2e27b9d5b76e3ee31166bfecde7d4f051fb6e0 Mon Sep 17 00:00:00 2001 From: Mehdi Achour Date: Fri, 28 Apr 2023 10:11:18 +0100 Subject: [PATCH 1/2] fix(v2_meta): hint data as being potentially undefined Closes #6210 --- packages/remix-react/routeModules.ts | 4 +++- packages/remix-server-runtime/routeModules.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/remix-react/routeModules.ts b/packages/remix-react/routeModules.ts index 34f701171ed..474fbfcc443 100644 --- a/packages/remix-react/routeModules.ts +++ b/packages/remix-react/routeModules.ts @@ -117,7 +117,9 @@ export interface V2_MetaArgs< Loader extends LoaderFunction | unknown = unknown, MatchLoaders extends Record = Record > { - data: Loader extends LoaderFunction ? SerializeFrom : AppData; + data: + | (Loader extends LoaderFunction ? SerializeFrom : AppData) + | undefined; params: Params; location: Location; matches: V2_MetaMatches; diff --git a/packages/remix-server-runtime/routeModules.ts b/packages/remix-server-runtime/routeModules.ts index d8eec949d49..01ad308e5da 100644 --- a/packages/remix-server-runtime/routeModules.ts +++ b/packages/remix-server-runtime/routeModules.ts @@ -200,7 +200,9 @@ export interface V2_ServerRuntimeMetaArgs< Loader extends LoaderFunction | unknown = unknown, MatchLoaders extends Record = Record > { - data: Loader extends LoaderFunction ? SerializeFrom : AppData; + data: + | (Loader extends LoaderFunction ? SerializeFrom : AppData) + | undefined; params: Params; location: Location; matches: V2_ServerRuntimeMetaMatches; From 2f658b72e35ce033eccf16ca3ff20051f54338c2 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 5 May 2023 13:06:00 -0400 Subject: [PATCH 2/2] Add changeset --- .changeset/v2-meta-loader-data-type.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/v2-meta-loader-data-type.md diff --git a/.changeset/v2-meta-loader-data-type.md b/.changeset/v2-meta-loader-data-type.md new file mode 100644 index 00000000000..6d87ba2dc0c --- /dev/null +++ b/.changeset/v2-meta-loader-data-type.md @@ -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.