From c8f308fb2ca58da186f9bd6757146c0f3f584008 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 31 Jul 2024 13:56:51 -0400 Subject: [PATCH] Fix types for unstable_data (#9811) --- .changeset/mighty-needles-destroy.md | 5 ++ integration/package.json | 2 +- packages/remix-dev/package.json | 2 +- packages/remix-react/package.json | 6 +-- packages/remix-server-runtime/package.json | 2 +- packages/remix-server-runtime/single-fetch.ts | 8 ++- packages/remix-testing/package.json | 4 +- pnpm-lock.yaml | 50 +++++++++---------- 8 files changed, 45 insertions(+), 34 deletions(-) create mode 100644 .changeset/mighty-needles-destroy.md diff --git a/.changeset/mighty-needles-destroy.md b/.changeset/mighty-needles-destroy.md new file mode 100644 index 00000000000..d40d3b8a95c --- /dev/null +++ b/.changeset/mighty-needles-destroy.md @@ -0,0 +1,5 @@ +--- +"@remix-run/react": patch +--- + +[REMOVE] Fix typings for unstable_data and useLoaderData diff --git a/integration/package.json b/integration/package.json index de17024eb8d..927688ead3a 100644 --- a/integration/package.json +++ b/integration/package.json @@ -14,7 +14,7 @@ "@remix-run/dev": "workspace:*", "@remix-run/express": "workspace:*", "@remix-run/node": "workspace:*", - "@remix-run/router": "1.19.0-pre.0", + "@remix-run/router": "1.19.0-pre.1", "@remix-run/server-runtime": "workspace:*", "@types/express": "^4.17.9", "@vanilla-extract/css": "^1.10.0", diff --git a/packages/remix-dev/package.json b/packages/remix-dev/package.json index bf9cfe57314..0b5057b4e7f 100644 --- a/packages/remix-dev/package.json +++ b/packages/remix-dev/package.json @@ -32,7 +32,7 @@ "@mdx-js/mdx": "^2.3.0", "@npmcli/package-json": "^4.0.1", "@remix-run/node": "workspace:*", - "@remix-run/router": "1.19.0-pre.0", + "@remix-run/router": "1.19.0-pre.1", "@remix-run/server-runtime": "workspace:*", "@types/mdx": "^2.0.5", "@vanilla-extract/integration": "^6.2.0", diff --git a/packages/remix-react/package.json b/packages/remix-react/package.json index be134a437ca..7fac93cc3a3 100644 --- a/packages/remix-react/package.json +++ b/packages/remix-react/package.json @@ -19,10 +19,10 @@ "tsc": "tsc" }, "dependencies": { - "@remix-run/router": "1.19.0-pre.0", + "@remix-run/router": "1.19.0-pre.1", "@remix-run/server-runtime": "workspace:*", - "react-router": "6.26.0-pre.0", - "react-router-dom": "6.26.0-pre.0", + "react-router": "6.26.0-pre.1", + "react-router-dom": "6.26.0-pre.1", "turbo-stream": "2.2.0" }, "devDependencies": { diff --git a/packages/remix-server-runtime/package.json b/packages/remix-server-runtime/package.json index ac8549e911e..6ea488d5514 100644 --- a/packages/remix-server-runtime/package.json +++ b/packages/remix-server-runtime/package.json @@ -19,7 +19,7 @@ "tsc": "tsc" }, "dependencies": { - "@remix-run/router": "1.19.0-pre.0", + "@remix-run/router": "1.19.0-pre.1", "@types/cookie": "^0.6.0", "@web3-storage/multipart-parser": "^1.0.0", "cookie": "^0.6.0", diff --git a/packages/remix-server-runtime/single-fetch.ts b/packages/remix-server-runtime/single-fetch.ts index f6b8957a011..e9298122a7b 100644 --- a/packages/remix-server-runtime/single-fetch.ts +++ b/packages/remix-server-runtime/single-fetch.ts @@ -2,6 +2,7 @@ import type { StaticHandler, unstable_DataStrategyFunctionArgs as DataStrategyFunctionArgs, unstable_DataStrategyFunction as DataStrategyFunction, + UNSAFE_DataWithResponseInit as DataWithResponseInit, } from "@remix-run/router"; import { isRouteErrorResponse, @@ -335,7 +336,10 @@ export function encodeViaTurboStream( }); } -export function data(value: Serializable, init?: number | ResponseInit) { +export function data( + value: D, + init?: number | ResponseInit +) { return routerData(value, init); } @@ -361,6 +365,7 @@ type Serializable = type DataFunctionReturnValue = | Serializable + | DataWithResponseInit | TypedDeferredData> | TypedResponse>; @@ -372,6 +377,7 @@ type DataFunctionReturnValue = export type Serialize = Awaited> extends TypedDeferredData ? D : Awaited> extends TypedResponse> ? SerializeFrom : + Awaited> extends DataWithResponseInit ? D : Awaited>; export type Loader = ( diff --git a/packages/remix-testing/package.json b/packages/remix-testing/package.json index a2365a998d1..4e571b3bad6 100644 --- a/packages/remix-testing/package.json +++ b/packages/remix-testing/package.json @@ -21,8 +21,8 @@ "dependencies": { "@remix-run/node": "workspace:*", "@remix-run/react": "workspace:*", - "@remix-run/router": "1.19.0-pre.0", - "react-router-dom": "6.26.0-pre.0" + "@remix-run/router": "1.19.0-pre.1", + "react-router-dom": "6.26.0-pre.1" }, "devDependencies": { "@remix-run/server-runtime": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7bbe4a0ed1b..4c20c39a78c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -323,8 +323,8 @@ importers: specifier: workspace:* version: link:../packages/remix-node '@remix-run/router': - specifier: 1.19.0-pre.0 - version: 1.19.0-pre.0 + specifier: 1.19.0-pre.1 + version: 1.19.0-pre.1 '@remix-run/server-runtime': specifier: workspace:* version: link:../packages/remix-server-runtime @@ -871,8 +871,8 @@ importers: specifier: ^2.11.0-pre.0 version: link:../remix-react '@remix-run/router': - specifier: 1.19.0-pre.0 - version: 1.19.0-pre.0 + specifier: 1.19.0-pre.1 + version: 1.19.0-pre.1 '@remix-run/server-runtime': specifier: workspace:* version: link:../remix-server-runtime @@ -1217,17 +1217,17 @@ importers: packages/remix-react: dependencies: '@remix-run/router': - specifier: 1.19.0-pre.0 - version: 1.19.0-pre.0 + specifier: 1.19.0-pre.1 + version: 1.19.0-pre.1 '@remix-run/server-runtime': specifier: workspace:* version: link:../remix-server-runtime react-router: - specifier: 6.26.0-pre.0 - version: 6.26.0-pre.0(react@18.2.0) + specifier: 6.26.0-pre.1 + version: 6.26.0-pre.1(react@18.2.0) react-router-dom: - specifier: 6.26.0-pre.0 - version: 6.26.0-pre.0(react-dom@18.2.0)(react@18.2.0) + specifier: 6.26.0-pre.1 + version: 6.26.0-pre.1(react-dom@18.2.0)(react@18.2.0) turbo-stream: specifier: 2.2.0 version: 2.2.0 @@ -1303,8 +1303,8 @@ importers: packages/remix-server-runtime: dependencies: '@remix-run/router': - specifier: 1.19.0-pre.0 - version: 1.19.0-pre.0 + specifier: 1.19.0-pre.1 + version: 1.19.0-pre.1 '@types/cookie': specifier: ^0.6.0 version: 0.6.0 @@ -1340,11 +1340,11 @@ importers: specifier: workspace:* version: link:../remix-react '@remix-run/router': - specifier: 1.19.0-pre.0 - version: 1.19.0-pre.0 + specifier: 1.19.0-pre.1 + version: 1.19.0-pre.1 react-router-dom: - specifier: 6.26.0-pre.0 - version: 6.26.0-pre.0(react-dom@18.2.0)(react@18.2.0) + specifier: 6.26.0-pre.1 + version: 6.26.0-pre.1(react-dom@18.2.0)(react@18.2.0) devDependencies: '@remix-run/server-runtime': specifier: workspace:* @@ -4201,8 +4201,8 @@ packages: - encoding dev: false - /@remix-run/router@1.19.0-pre.0: - resolution: {integrity: sha512-kIabFU8rSYO99jUvDVPNN13UBHaonCvqhRoa9ed6thH/zbwQmaYvljP0kd2QvxrRF94XwexpQJE4vTRtiRIr0w==} + /@remix-run/router@1.19.0-pre.1: + resolution: {integrity: sha512-odV+ZH4LbnpZttNvIJ1EDXuLNHC29h+mLcbahCqZrknXonjjwLiYn1qBOFzPxn6onGs0rMJuo1qUyE/+P/jK9A==} engines: {node: '>=14.0.0'} dev: false @@ -12786,26 +12786,26 @@ packages: engines: {node: '>=0.10.0'} dev: false - /react-router-dom@6.26.0-pre.0(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-yG+aNIxCzdyo3ZIeLvPtxxS4RE4av9wL1fUgd4L+Af1sOYz9lxWj7IPMmCKepoXd1XKedwsNsCm/uTJ94Qp/8Q==} + /react-router-dom@6.26.0-pre.1(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-eS7OZvFd+xfWqQfuTW8IOehBof8C0s9KrSFYxlf/ixzhhFYF3AV6qdjV5J3OeUDAT+AmKuAZ8UJ37sKvNO58CQ==} engines: {node: '>=14.0.0'} peerDependencies: react: '>=16.8' react-dom: '>=16.8' dependencies: - '@remix-run/router': 1.19.0-pre.0 + '@remix-run/router': 1.19.0-pre.1 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - react-router: 6.26.0-pre.0(react@18.2.0) + react-router: 6.26.0-pre.1(react@18.2.0) dev: false - /react-router@6.26.0-pre.0(react@18.2.0): - resolution: {integrity: sha512-ONaqRSj6h7DSCFnAGBkb5PBelbdQKR/Ijv91VxKnvRZQm+roc8jF1a/1xhdmJ+dQRbYT8BxTUAnQAyyZsF1wzg==} + /react-router@6.26.0-pre.1(react@18.2.0): + resolution: {integrity: sha512-j9nqRS72gJV6ZcCvdUP5ryk0edSMsdzkT3fpWFLOPwkfm7Nk5qnBdMP5plK37ufVPSNpq2XT8toEDswyn0wUCg==} engines: {node: '>=14.0.0'} peerDependencies: react: '>=16.8' dependencies: - '@remix-run/router': 1.19.0-pre.0 + '@remix-run/router': 1.19.0-pre.1 react: 18.2.0 dev: false