diff --git a/.changeset/flat-boxes-brake.md b/.changeset/flat-boxes-brake.md
new file mode 100644
index 00000000000..f58aa8c5c56
--- /dev/null
+++ b/.changeset/flat-boxes-brake.md
@@ -0,0 +1,6 @@
+---
+"@remix-run/react": patch
+"@remix-run/server-runtime": patch
+---
+
+Add type deprecations for types now in React Router
diff --git a/packages/remix-react/components.tsx b/packages/remix-react/components.tsx
index 9f38e5918d2..7754ee3c6ca 100644
--- a/packages/remix-react/components.tsx
+++ b/packages/remix-react/components.tsx
@@ -112,19 +112,6 @@ function useRemixContext(): RemixContextObject {
return context;
}
-////////////////////////////////////////////////////////////////////////////////
-// RemixEntry
-
-export function RemixEntry(props: {
- context: EntryContext;
- action: NavigationType;
- location: Location;
- navigator: Navigator;
- static?: boolean;
-}) {
- return
Not Implemented!
;
-}
-
////////////////////////////////////////////////////////////////////////////////
// RemixRoute
diff --git a/packages/remix-react/data.ts b/packages/remix-react/data.ts
index 8b22febb006..4991ec8720d 100644
--- a/packages/remix-react/data.ts
+++ b/packages/remix-react/data.ts
@@ -2,16 +2,14 @@ import {
AbortedDeferredError,
UNSAFE_DeferredData as DeferredData,
} from "@remix-run/router";
-import type { FormMethod as FormMethodRR } from "react-router-dom";
+/**
+ * Data for a route that was returned from a `loader()`.
+ *
+ * Note: This moves to unknown in ReactRouter and eventually likely in Remix
+ */
export type AppData = any;
-export type FormMethod = FormMethodRR;
-
-export type FormEncType =
- | "application/x-www-form-urlencoded"
- | "multipart/form-data";
-
export function isCatchResponse(response: any): boolean {
return (
response instanceof Response &&
diff --git a/packages/remix-react/errors.ts b/packages/remix-react/errors.ts
index d4fc56d3738..d8605ccbd4a 100644
--- a/packages/remix-react/errors.ts
+++ b/packages/remix-react/errors.ts
@@ -3,6 +3,10 @@ import { ErrorResponse } from "@remix-run/router";
import type { AppData } from "./data";
+/**
+ * @deprecated in favor of the `ErrorResponse` class in React Router. Please
+ * enable the `future.v2_errorBoundary` flag to ease your migration to Remix v2.
+ */
export interface ThrownResponse<
Status extends number = number,
Data = AppData
diff --git a/packages/remix-react/index.tsx b/packages/remix-react/index.tsx
index fac69ffddf1..930abb91337 100644
--- a/packages/remix-react/index.tsx
+++ b/packages/remix-react/index.tsx
@@ -1,6 +1,8 @@
export type { RemixBrowserProps } from "./browser";
export { RemixBrowser } from "./browser";
export type {
+ FormEncType,
+ FormMethod,
FormProps,
Location,
NavigateFunction,
@@ -63,8 +65,6 @@ export {
RemixContext as UNSAFE_RemixContext,
} from "./components";
-export type { FormMethod, FormEncType } from "./data";
-
export type { ThrownResponse } from "./errors";
export { useCatch } from "./errorBoundaries";
diff --git a/packages/remix-react/routeData.ts b/packages/remix-react/routeData.ts
deleted file mode 100644
index a147435e7f9..00000000000
--- a/packages/remix-react/routeData.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import type { AppData } from "./data";
-
-export interface RouteData {
- [routeId: string]: AppData;
-}
diff --git a/packages/remix-react/routeModules.ts b/packages/remix-react/routeModules.ts
index a908fe65a0e..34f701171ed 100644
--- a/packages/remix-react/routeModules.ts
+++ b/packages/remix-react/routeModules.ts
@@ -1,4 +1,5 @@
import type { ComponentType } from "react";
+import type { RouterState } from "@remix-run/router";
import type {
DataRouteMatch,
Params,
@@ -10,7 +11,8 @@ import type { LoaderFunction, SerializeFrom } from "@remix-run/server-runtime";
import type { AppData } from "./data";
import type { LinkDescriptor } from "./links";
import type { EntryRoute } from "./routes";
-import type { RouteData } from "./routeData";
+
+type RouteData = RouterState["loaderData"];
export interface RouteModules {
[routeId: string]: RouteModule;
diff --git a/packages/remix-react/transition.ts b/packages/remix-react/transition.ts
index eea748ff79e..713162e7767 100644
--- a/packages/remix-react/transition.ts
+++ b/packages/remix-react/transition.ts
@@ -1,10 +1,4 @@
-import type { Location, NavigationType as Action } from "react-router-dom";
-
-export interface CatchData {
- status: number;
- statusText: string;
- data: T;
-}
+import type { Location } from "react-router-dom";
export interface Submission {
action: string;
@@ -81,29 +75,6 @@ export type TransitionStates = {
export type Transition = TransitionStates[keyof TransitionStates];
-export type Redirects = {
- Loader: {
- isRedirect: true;
- type: "loader";
- setCookie: boolean;
- };
- Action: {
- isRedirect: true;
- type: "action";
- setCookie: boolean;
- };
- LoaderSubmission: {
- isRedirect: true;
- type: "loaderSubmission";
- setCookie: boolean;
- };
- FetchAction: {
- isRedirect: true;
- type: "fetchAction";
- setCookie: boolean;
- };
-};
-
// TODO: keep data around on resubmission?
export type FetcherStates = {
Idle: {
@@ -181,30 +152,6 @@ export type FetcherStates = {
export type Fetcher =
FetcherStates[keyof FetcherStates];
-export class CatchValue {
- constructor(
- public status: number,
- public statusText: string,
- public data: any
- ) {}
-}
-
-export type NavigationEvent = {
- type: "navigation";
- action: Action;
- location: Location;
- submission?: Submission;
-};
-
-export type FetcherEvent = {
- type: "fetcher";
- key: string;
- submission?: Submission;
- href: string;
-};
-
-export type DataEvent = NavigationEvent | FetcherEvent;
-
export const IDLE_TRANSITION: TransitionStates["Idle"] = {
state: "idle",
submission: undefined,
diff --git a/packages/remix-server-runtime/data.ts b/packages/remix-server-runtime/data.ts
index eead955c4ab..6237b8643d9 100644
--- a/packages/remix-server-runtime/data.ts
+++ b/packages/remix-server-runtime/data.ts
@@ -21,6 +21,8 @@ export interface AppLoadContext {
/**
* Data for a route that was returned from a `loader()`.
+ *
+ * Note: This moves to unknown in ReactRouter and eventually likely in Remix
*/
export type AppData = any;
diff --git a/packages/remix-server-runtime/errors.ts b/packages/remix-server-runtime/errors.ts
index 85f98407f8c..c4a4ccd38b0 100644
--- a/packages/remix-server-runtime/errors.ts
+++ b/packages/remix-server-runtime/errors.ts
@@ -43,7 +43,10 @@ import { isRouteErrorResponse } from "@remix-run/router";
* line.
*/
-// TODO Re-export as ErrorResponse?
+/**
+ * @deprecated in favor of the `ErrorResponse` class in React Router. Please
+ * enable the `future.v2_errorBoundary` flag to ease your migration to Remix v2.
+ */
export interface ThrownResponse {
status: number;
statusText: string;
diff --git a/packages/remix-server-runtime/responses.ts b/packages/remix-server-runtime/responses.ts
index 967c10eb24f..3494202a12a 100644
--- a/packages/remix-server-runtime/responses.ts
+++ b/packages/remix-server-runtime/responses.ts
@@ -1,5 +1,7 @@
import {
defer as routerDefer,
+ json as routerJson,
+ redirect as routerRedirect,
type UNSAFE_DeferredData as DeferredData,
type TrackedPromise,
} from "@remix-run/router";
@@ -39,37 +41,16 @@ export type TypedResponse = Omit<
* @see https://remix.run/utils/json
*/
export const json: JsonFunction = (data, init = {}) => {
- let responseInit = typeof init === "number" ? { status: init } : init;
-
- let headers = new Headers(responseInit.headers);
- if (!headers.has("Content-Type")) {
- headers.set("Content-Type", "application/json; charset=utf-8");
- }
-
- return new Response(JSON.stringify(data), {
- ...responseInit,
- headers,
- });
+ return routerJson(data, init);
};
/**
- * This is a shortcut for creating `application/json` responses. Converts `data`
- * to JSON and sets the `Content-Type` header.
+ * This is a shortcut for creating Remix deferred responses
*
- * @see https://remix.run/api/remix#json
+ * @see https://remix.run/docs/utils/defer
*/
export const defer: DeferFunction = (data, init = {}) => {
- let responseInit = typeof init === "number" ? { status: init } : init;
-
- let headers = new Headers(responseInit.headers);
- if (!headers.has("Content-Type")) {
- headers.set("Content-Type", "application/json; charset=utf-8");
- }
-
- return routerDefer(data, {
- ...responseInit,
- headers,
- }) as TypedDeferredData;
+ return routerDefer(data, init) as TypedDeferredData;
};
export type RedirectFunction = (
@@ -84,20 +65,7 @@ export type RedirectFunction = (
* @see https://remix.run/utils/redirect
*/
export const redirect: RedirectFunction = (url, init = 302) => {
- let responseInit = init;
- if (typeof responseInit === "number") {
- responseInit = { status: responseInit };
- } else if (typeof responseInit.status === "undefined") {
- responseInit.status = 302;
- }
-
- let headers = new Headers(responseInit.headers);
- headers.set("Location", url);
-
- return new Response(null, {
- ...responseInit,
- headers,
- }) as TypedResponse;
+ return routerRedirect(url, init) as TypedResponse;
};
export function isDeferredData(value: any): value is DeferredData {
diff --git a/packages/remix-server-runtime/routeData.ts b/packages/remix-server-runtime/routeData.ts
deleted file mode 100644
index a147435e7f9..00000000000
--- a/packages/remix-server-runtime/routeData.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import type { AppData } from "./data";
-
-export interface RouteData {
- [routeId: string]: AppData;
-}
diff --git a/packages/remix-server-runtime/routeModules.ts b/packages/remix-server-runtime/routeModules.ts
index 9eddc2b40c3..d8eec949d49 100644
--- a/packages/remix-server-runtime/routeModules.ts
+++ b/packages/remix-server-runtime/routeModules.ts
@@ -1,17 +1,28 @@
-import type { AgnosticRouteMatch, Location, Params } from "@remix-run/router";
+import type {
+ AgnosticRouteMatch,
+ Location,
+ Params,
+ RouterState,
+} from "@remix-run/router";
import type { ComponentType } from "react";
import type { AppLoadContext, AppData } from "./data";
import type { LinkDescriptor } from "./links";
-import type { RouteData } from "./routeData";
import type { SerializeFrom } from "./serialize";
+type RouteData = RouterState["loaderData"];
+
export interface RouteModules {
[routeId: string]: RouteModule;
}
/**
* The arguments passed to ActionFunction and LoaderFunction.
+ *
+ * Note this is almost identical to React Router's version but over there the
+ * context is optional since it's only there during static handler invocations.
+ * Keeping Remix's own definition for now so it can differentiate between
+ * client/server
*/
export interface DataFunctionArgs {
request: Request;
@@ -20,6 +31,7 @@ export interface DataFunctionArgs {
}
export type LoaderArgs = DataFunctionArgs;
+
export type ActionArgs = DataFunctionArgs;
/**