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. 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;