Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(remix-server-runtime): don't use React types #5713

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-react-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/server-runtime": patch
---

Fix typing issues when using React 17 stemming from `@remix/server-runtime` including `@types/react` as a `devDependency` when it doesn't actually do anything React-specific and was just re-exporting `ComponentType` in values such as `CatchBoundaryComponent`/`ErrorBoundaryComponent`/`V2_ErrorBoundaryComponent`. These types are more correctly exported from `@remix-run/react` which is React-aware so that is the correct place to be importing those types from. In order to avoid breaking existing builds, the types in `@remix/server-runtime` have been loosened to `any` and `@deprecated` warnings have been added informing users to switch to the corresponding types in `@remix-run/react`.
5 changes: 5 additions & 0 deletions .changeset/types-cookie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/server-runtime": patch
---

Move `@types/cookie` to `dependencies` since we re-export types from there
1 change: 1 addition & 0 deletions packages/remix-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@remix-run/server-runtime": "1.17.0",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^13.3.0",
"@types/react": "^18.0.15",
"abort-controller": "^3.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/remix-server-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
"module": "dist/esm/index.js",
"dependencies": {
"@remix-run/router": "1.6.3",
"@types/cookie": "^0.4.1",
"@web3-storage/multipart-parser": "^1.0.0",
"cookie": "^0.4.1",
"set-cookie-parser": "^2.4.8",
"source-map": "^0.7.3"
},
"devDependencies": {
"@remix-run/web-file": "^3.0.2",
"@types/cookie": "^0.4.0",
"@types/react": "^18.0.15",
"@types/set-cookie-parser": "^2.4.1"
},
"engines": {
Expand Down
23 changes: 16 additions & 7 deletions packages/remix-server-runtime/routeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {
Params,
RouterState,
} from "@remix-run/router";
import type { ComponentType } from "react";

import type { AppLoadContext, AppData } from "./data";
import type { LinkDescriptor } from "./links";
Expand Down Expand Up @@ -48,23 +47,31 @@ export interface ActionFunction {
/**
* A React component that is rendered when the server throws a Response.
*
* @deprecated Please enable the v2_errorBoundary flag
* @deprecated Please enable the v2_errorBoundary flag to eliminate the need
* for this type. If you are still using this, please use `@remix-run/react`'s
* `CatchBoundaryComponent` type
*/
export type CatchBoundaryComponent = ComponentType;
export type CatchBoundaryComponent = any;

/**
* A React component that is rendered when there is an error on a route.
*
* @deprecated Please enable the v2_errorBoundary flag
* @deprecated Please enable the v2_errorBoundary flag to eliminate the need
* for this type. If you are still using this, please use `@remix-run/react`'s
* `ErrorBoundaryComponent` type
*/
export type ErrorBoundaryComponent = ComponentType<{ error: Error }>;
export type ErrorBoundaryComponent = any;

/**
* V2 version of the ErrorBoundary that eliminates the distinction between
* Error and Catch Boundaries and behaves like RR 6.4 errorElement and captures
* errors with useRouteError()
*
* @deprecated Please enable the v2_errorBoundary flag to eliminate the need
* for this type. If you are still using this, please use `@remix-run/react`'s
* `V2_ErrorBoundaryComponent` type
*/
export type V2_ErrorBoundaryComponent = ComponentType;
export type V2_ErrorBoundaryComponent = any;

export type HeadersArgs = {
loaderHeaders: Headers;
Expand Down Expand Up @@ -262,8 +269,10 @@ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;

/**
* A React component that is rendered for a route.
*
* @deprecated Please use `@remix-run/react`'s `RouteComponent` type instead
*/
export type RouteComponent = ComponentType<{}>;
export type RouteComponent = any;

/**
* An arbitrary object that is associated with a route.
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2943,7 +2943,7 @@
resolved "https://registry.npmjs.org/@types/cookie-signature/-/cookie-signature-1.0.3.tgz"
integrity sha512-0jpd4oizLaBybWBCew/lx4iAjjNWmCfzbspvnjoppyGEquN51BjShmPCksiH2IXLwtxQ2F/e2PkFy0LL7jpLsw==

"@types/cookie@^0.4.0", "@types/cookie@^0.4.1":
"@types/cookie@^0.4.1":
version "0.4.1"
resolved "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz"
integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==
Expand Down