From 861f867640bfcd12af2d7b8befbff7c45c5a0a5e Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 13:54:03 -0700 Subject: [PATCH 01/14] Upgrade types. Make react 19 default and alias React 18 --- package-lock.json | 100 +++++++++++++++++++++------------------------- package.json | 12 +++--- 2 files changed, 52 insertions(+), 60 deletions(-) diff --git a/package-lock.json b/package-lock.json index 85b634f06f..da8efe8849 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,8 +52,8 @@ "@types/lodash": "4.17.7", "@types/node": "20.16.1", "@types/node-fetch": "2.6.11", - "@types/react": "18.3.3", - "@types/react-dom": "18.3.0", + "@types/react": "19.0.0", + "@types/react-dom": "19.0.0", "@types/relay-runtime": "14.1.24", "@types/use-sync-external-store": "0.0.6", "@typescript-eslint/eslint-plugin": "7.18.0", @@ -85,12 +85,12 @@ "patch-package": "8.0.0", "pkg-pr-new": "0.0.24", "prettier": "3.1.1", - "react": "18.3.1", + "react": "19.0.0", "react-17": "npm:react@^17", - "react-19": "npm:react@19.0.0", - "react-dom": "18.3.1", + "react-18": "npm:react@^18", + "react-dom": "19.0.0", "react-dom-17": "npm:react-dom@^17", - "react-dom-19": "npm:react-dom@19.0.0", + "react-dom-18": "npm:react-dom@^18", "react-error-boundary": "4.0.13", "recast": "0.23.9", "resolve": "1.22.8", @@ -4176,27 +4176,19 @@ "form-data": "^4.0.0" } }, - "node_modules/@types/prop-types": { - "version": "15.7.4", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz", - "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==", - "dev": true - }, "node_modules/@types/react": { - "version": "18.3.3", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.3.tgz", - "integrity": "sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==", + "version": "19.0.0", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.0.0.tgz", + "integrity": "sha512-MY3oPudxvMYyesqs/kW1Bh8y9VqSmf+tzqw3ae8a9DZW68pUe3zAdHeI1jc6iAysuRdACnVknHP8AhwD4/dxtg==", "dev": true, - "license": "MIT", "dependencies": { - "@types/prop-types": "*", "csstype": "^3.0.2" } }, "node_modules/@types/react-dom": { - "version": "18.3.0", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.0.tgz", - "integrity": "sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==", + "version": "19.0.0", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.0.0.tgz", + "integrity": "sha512-1KfiQKsH1o00p9m5ag12axHQSb3FOU9H20UTrujVSkNhuCrRHiQWFqgEnTNK5ZNfnzZv8UWrnXVqCmCF9fgY3w==", "dev": true, "dependencies": { "@types/react": "*" @@ -11069,13 +11061,10 @@ } }, "node_modules/react": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", - "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "version": "19.0.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.0.0.tgz", + "integrity": "sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==", "dev": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, "engines": { "node": ">=0.10.0" } @@ -11094,27 +11083,29 @@ "node": ">=0.10.0" } }, - "node_modules/react-19": { + "node_modules/react-18": { "name": "react", - "version": "19.0.0", - "resolved": "https://registry.npmjs.org/react/-/react-19.0.0.tgz", - "integrity": "sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "dev": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, "engines": { "node": ">=0.10.0" } }, "node_modules/react-dom": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", - "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "version": "19.0.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.0.0.tgz", + "integrity": "sha512-4GV5sHFG0e/0AD4X+ySy6UJd3jVl1iNsNHdpad0qhABJ11twS3TTBnseqsKurKcsNqCEFeGL3uLpVChpIO3QfQ==", "dev": true, "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.2" + "scheduler": "^0.25.0" }, "peerDependencies": { - "react": "^18.3.1" + "react": "^19.0.0" } }, "node_modules/react-dom-17": { @@ -11142,24 +11133,28 @@ "object-assign": "^4.1.1" } }, - "node_modules/react-dom-19": { + "node_modules/react-dom-18": { "name": "react-dom", - "version": "19.0.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.0.0.tgz", - "integrity": "sha512-4GV5sHFG0e/0AD4X+ySy6UJd3jVl1iNsNHdpad0qhABJ11twS3TTBnseqsKurKcsNqCEFeGL3uLpVChpIO3QfQ==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "dev": true, "dependencies": { - "scheduler": "^0.25.0" + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" }, "peerDependencies": { - "react": "^19.0.0" + "react": "^18.3.1" } }, - "node_modules/react-dom-19/node_modules/scheduler": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0.tgz", - "integrity": "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==", - "dev": true + "node_modules/react-dom-18/node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "dev": true, + "dependencies": { + "loose-envify": "^1.1.0" + } }, "node_modules/react-error-boundary": { "version": "4.0.13", @@ -11670,13 +11665,10 @@ } }, "node_modules/scheduler": { - "version": "0.23.2", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", - "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", - "dev": true, - "dependencies": { - "loose-envify": "^1.1.0" - } + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0.tgz", + "integrity": "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==", + "dev": true }, "node_modules/semver": { "version": "6.3.1", diff --git a/package.json b/package.json index f84c9d5347..219a4fe685 100644 --- a/package.json +++ b/package.json @@ -135,8 +135,8 @@ "@types/lodash": "4.17.7", "@types/node": "20.16.1", "@types/node-fetch": "2.6.11", - "@types/react": "18.3.3", - "@types/react-dom": "18.3.0", + "@types/react": "19.0.0", + "@types/react-dom": "19.0.0", "@types/relay-runtime": "14.1.24", "@types/use-sync-external-store": "0.0.6", "@typescript-eslint/eslint-plugin": "7.18.0", @@ -168,12 +168,12 @@ "patch-package": "8.0.0", "pkg-pr-new": "0.0.24", "prettier": "3.1.1", - "react": "18.3.1", + "react": "19.0.0", "react-17": "npm:react@^17", - "react-19": "npm:react@19.0.0", - "react-dom": "18.3.1", + "react-18": "npm:react@^18", + "react-dom": "19.0.0", "react-dom-17": "npm:react-dom@^17", - "react-dom-19": "npm:react-dom@19.0.0", + "react-dom-18": "npm:react-dom@^18", "react-error-boundary": "4.0.13", "recast": "0.23.9", "resolve": "1.22.8", From cd1e5376785d1cc12755c4123222ec19c178d878 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 13:54:14 -0700 Subject: [PATCH 02/14] Update jest config with swap of default react version --- config/jest.config.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/jest.config.js b/config/jest.config.js index ce297ed2af..ffdf6c4871 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -63,17 +63,17 @@ const standardReact19Config = { ...defaults, displayName: "ReactDOM 19", testPathIgnorePatterns: react19TestFileIgnoreList, - moduleNameMapper: { - "^react$": "react-19", - "^react-dom$": "react-dom-19", - "^react-dom/(.*)$": "react-dom-19/$1", - }, }; const standardReact18Config = { ...defaults, displayName: "ReactDOM 18", testPathIgnorePatterns: [ignoreTSFiles], + moduleNameMapper: { + "^react$": "react-18", + "^react-dom$": "react-dom-18", + "^react-dom/(.*)$": "react-dom-18/$1", + }, }; const standardReact17Config = { From c7b97649f52f4438b496ecfa0801ebc7e4afe4f6 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 13:56:57 -0700 Subject: [PATCH 03/14] Fix reference to createFactory --- ...mposeWithState.ts => recomposeWithState.tsx} | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) rename src/react/hoc/__tests__/queries/{recomposeWithState.ts => recomposeWithState.tsx} (87%) diff --git a/src/react/hoc/__tests__/queries/recomposeWithState.ts b/src/react/hoc/__tests__/queries/recomposeWithState.tsx similarity index 87% rename from src/react/hoc/__tests__/queries/recomposeWithState.ts rename to src/react/hoc/__tests__/queries/recomposeWithState.tsx index 2ec2ad7975..68535b077c 100644 --- a/src/react/hoc/__tests__/queries/recomposeWithState.ts +++ b/src/react/hoc/__tests__/queries/recomposeWithState.tsx @@ -1,7 +1,7 @@ // Adapted from v0.30.0 of https://github.com/acdlite/recompose/blob/master/src/packages/recompose/withState.js // to avoid incurring an indirect dependency on ua-parser-js via fbjs. -import React, { createFactory, Component } from "react"; +import React, { Component } from "react"; const setStatic = (key: string, value: string) => (BaseComponent: React.ComponentClass) => { @@ -33,7 +33,6 @@ const wrapDisplayName = ( export const withState = (stateName: string, stateUpdaterName: string, initialState: unknown) => (BaseComponent: React.ComponentClass) => { - const factory = createFactory(BaseComponent); class WithState extends Component< Record, { stateValue: unknown } @@ -58,11 +57,15 @@ export const withState = ); render() { - return factory({ - ...this.props, - [stateName]: this.state.stateValue, - [stateUpdaterName]: this.updateStateValue, - }); + return ( + + ); } } From fa5a2ed75fcd70fc691a3728673bd02328867059 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 13:58:13 -0700 Subject: [PATCH 04/14] Install prop-types types package --- package-lock.json | 7 +++++++ package.json | 1 + 2 files changed, 8 insertions(+) diff --git a/package-lock.json b/package-lock.json index da8efe8849..fbee3454fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,6 +52,7 @@ "@types/lodash": "4.17.7", "@types/node": "20.16.1", "@types/node-fetch": "2.6.11", + "@types/prop-types": "^15.7.14", "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "@types/relay-runtime": "14.1.24", @@ -4176,6 +4177,12 @@ "form-data": "^4.0.0" } }, + "node_modules/@types/prop-types": { + "version": "15.7.14", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.14.tgz", + "integrity": "sha512-gNMvNH49DJ7OJYv+KAKn0Xp45p8PLl6zo2YnvDIbTd4J6MER2BmWN49TG7n9LvkyihINxeKW8+3bfS2yDC9dzQ==", + "dev": true + }, "node_modules/@types/react": { "version": "19.0.0", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.0.0.tgz", diff --git a/package.json b/package.json index 219a4fe685..57f36632ea 100644 --- a/package.json +++ b/package.json @@ -135,6 +135,7 @@ "@types/lodash": "4.17.7", "@types/node": "20.16.1", "@types/node-fetch": "2.6.11", + "@types/prop-types": "^15.7.14", "@types/react": "19.0.0", "@types/react-dom": "19.0.0", "@types/relay-runtime": "14.1.24", From 3ab5ea31353500b77176acb7e9349f0c56b82c7e Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 13:59:43 -0700 Subject: [PATCH 05/14] Use type inference in test --- src/react/hoc/__tests__/ssr/getDataFromTree.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/react/hoc/__tests__/ssr/getDataFromTree.test.tsx b/src/react/hoc/__tests__/ssr/getDataFromTree.test.tsx index 0a687741f6..70daf89795 100644 --- a/src/react/hoc/__tests__/ssr/getDataFromTree.test.tsx +++ b/src/react/hoc/__tests__/ssr/getDataFromTree.test.tsx @@ -5,7 +5,7 @@ import ReactDOM from "react-dom/server"; import gql from "graphql-tag"; import { DocumentNode } from "graphql"; -import { ApolloClient } from "../../../../core"; +import { ApolloClient, TypedDocumentNode } from "../../../../core"; import { ApolloProvider } from "../../../context"; import { InMemoryCache as Cache } from "../../../../cache"; import { itAsync, mockSingleLink } from "../../../../testing"; @@ -805,7 +805,7 @@ describe("SSR", () => { }); it("shouldn't run queries (via Query component) if ssr is turned to off", () => { - const query = gql` + const query: TypedDocumentNode = gql` query user($id: ID) { currentUser(id: $id) { firstName @@ -833,7 +833,7 @@ describe("SSR", () => { const Element = (props: { id: string }) => ( - {({ data, loading }: { data: Data; loading: boolean }) => ( + {({ data, loading }) => (
{loading || !data ? "loading" : data.currentUser!.firstName}
From 7156052d41fdbf09ae85ab0760928c2c88d02dab Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 14:01:01 -0700 Subject: [PATCH 06/14] Use expect-error and type inference in mutation hoc --- src/react/hoc/mutation-hoc.tsx | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/react/hoc/mutation-hoc.tsx b/src/react/hoc/mutation-hoc.tsx index 2a0291653d..a9dc10e673 100644 --- a/src/react/hoc/mutation-hoc.tsx +++ b/src/react/hoc/mutation-hoc.tsx @@ -5,11 +5,7 @@ import hoistNonReactStatics from "hoist-non-react-statics"; import { parser } from "../parser/index.js"; import type { DefaultContext, OperationVariables } from "../../core/types.js"; -import type { - BaseMutationOptions, - MutationFunction, - MutationResult, -} from "../types/types.js"; +import type { BaseMutationOptions } from "../types/types.js"; import { Mutation } from "../components/index.js"; import { @@ -91,12 +87,9 @@ export function withMutation< } return ( + // @ts-expect-error - {/* @ts-expect-error */} - {( - mutate: MutationFunction, - { data, ...r }: MutationResult - ) => { + {(mutate, { data, ...r }) => { // the HOC's historically hoisted the data from the execution result // up onto the result since it was passed as a nested prop // we massage the Mutation component's shape here to replicate that From 7b0693a353016137610926120247afcc7f5fc7c9 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 14:04:23 -0700 Subject: [PATCH 07/14] Update testing library libraries to support React 19 --- package-lock.json | 51 +++++++++++------------------------------------ package.json | 4 ++-- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index fbee3454fb..a4db69df62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,8 +39,8 @@ "@size-limit/esbuild-why": "11.1.4", "@size-limit/preset-small-lib": "11.1.4", "@testing-library/dom": "^10.4.0", - "@testing-library/jest-dom": "6.4.6", - "@testing-library/react": "^16.0.1", + "@testing-library/jest-dom": "6.6.3", + "@testing-library/react": "^16.1.0", "@testing-library/react-render-stream": "2.0.0-alpha.1", "@testing-library/user-event": "14.5.2", "@tsconfig/node20": "20.1.4", @@ -3501,14 +3501,12 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.6.tgz", - "integrity": "sha512-8qpnGVincVDLEcQXWaHOf6zmlbwTKc6Us6PPu4CRnPXCzo2OGBS5cwgMMOWdxDpEz1mkbvXHpEy99M5Yvt682w==", + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz", + "integrity": "sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==", "dev": true, - "license": "MIT", "dependencies": { "@adobe/css-tools": "^4.4.0", - "@babel/runtime": "^7.9.2", "aria-query": "^5.0.0", "chalk": "^3.0.0", "css.escape": "^1.5.1", @@ -3520,30 +3518,6 @@ "node": ">=14", "npm": ">=6", "yarn": ">=1" - }, - "peerDependencies": { - "@jest/globals": ">= 28", - "@types/bun": "latest", - "@types/jest": ">= 28", - "jest": ">= 28", - "vitest": ">= 0.32" - }, - "peerDependenciesMeta": { - "@jest/globals": { - "optional": true - }, - "@types/bun": { - "optional": true - }, - "@types/jest": { - "optional": true - }, - "jest": { - "optional": true - }, - "vitest": { - "optional": true - } } }, "node_modules/@testing-library/jest-dom/node_modules/ansi-styles": { @@ -3604,11 +3578,10 @@ "license": "MIT" }, "node_modules/@testing-library/react": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.0.1.tgz", - "integrity": "sha512-dSmwJVtJXmku+iocRhWOUFbrERC76TX2Mnf0ATODz8brzAZrMBbzLwQixlBSanZxR6LddK3eiwpSFZgDET1URg==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.1.0.tgz", + "integrity": "sha512-Q2ToPvg0KsVL0ohND9A3zLJWcOXXcO8IDu3fj11KhNt0UlCWyFyvnCIBkd12tidB2lkiVRG8VFqdhcqhqnAQtg==", "dev": true, - "license": "MIT", "dependencies": { "@babel/runtime": "^7.12.5" }, @@ -3617,10 +3590,10 @@ }, "peerDependencies": { "@testing-library/dom": "^10.0.0", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "@types/react": "^18.0.0 || ^19.0.0", + "@types/react-dom": "^18.0.0 || ^19.0.0", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" }, "peerDependenciesMeta": { "@types/react": { diff --git a/package.json b/package.json index 57f36632ea..60d01908b4 100644 --- a/package.json +++ b/package.json @@ -122,8 +122,8 @@ "@size-limit/esbuild-why": "11.1.4", "@size-limit/preset-small-lib": "11.1.4", "@testing-library/dom": "^10.4.0", - "@testing-library/jest-dom": "6.4.6", - "@testing-library/react": "^16.0.1", + "@testing-library/jest-dom": "6.6.3", + "@testing-library/react": "^16.1.0", "@testing-library/react-render-stream": "2.0.0-alpha.1", "@testing-library/user-event": "14.5.2", "@tsconfig/node20": "20.1.4", From 1fb3383ddf7821b9ad06b87f273a059c62e42952 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 14:07:58 -0700 Subject: [PATCH 08/14] Pass arg to useRef --- src/react/components/__tests__/client/Query.test.tsx | 2 +- src/react/hooks/internal/useDeepMemo.ts | 2 +- src/react/hooks/useLazyQuery.ts | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/react/components/__tests__/client/Query.test.tsx b/src/react/components/__tests__/client/Query.test.tsx index a97807838a..624d38f137 100644 --- a/src/react/components/__tests__/client/Query.test.tsx +++ b/src/react/components/__tests__/client/Query.test.tsx @@ -210,7 +210,7 @@ describe("Query component", () => { ]; const Component = () => ( - + {(result: any) => { if (result.loading) { return null; diff --git a/src/react/hooks/internal/useDeepMemo.ts b/src/react/hooks/internal/useDeepMemo.ts index 916e23a746..7faf0c6d43 100644 --- a/src/react/hooks/internal/useDeepMemo.ts +++ b/src/react/hooks/internal/useDeepMemo.ts @@ -6,7 +6,7 @@ export function useDeepMemo( memoFn: () => TValue, deps: DependencyList ) { - const ref = React.useRef<{ deps: DependencyList; value: TValue }>(); + const ref = React.useRef<{ deps: DependencyList; value: TValue }>(void 0); if (!ref.current || !equal(ref.current.deps, deps)) { ref.current = { value: memoFn(), deps }; diff --git a/src/react/hooks/useLazyQuery.ts b/src/react/hooks/useLazyQuery.ts index 671c23b9f8..e22b13fb0d 100644 --- a/src/react/hooks/useLazyQuery.ts +++ b/src/react/hooks/useLazyQuery.ts @@ -82,11 +82,12 @@ export function useLazyQuery< options?: LazyQueryHookOptions, NoInfer> ): LazyQueryResultTuple { const execOptionsRef = - React.useRef>>(); - const optionsRef = React.useRef>(); + React.useRef>>(void 0); + const optionsRef = + React.useRef>(void 0); const queryRef = React.useRef< DocumentNode | TypedDocumentNode - >(); + >(void 0); const merged = mergeOptions(options, execOptionsRef.current || {}); const document = merged?.query ?? query; From 707de3810be390f5269300773707717556814456 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 14:08:16 -0700 Subject: [PATCH 09/14] Add expect error to renderHookAsync --- src/testing/internal/rtl/renderHookAsync.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/testing/internal/rtl/renderHookAsync.tsx b/src/testing/internal/rtl/renderHookAsync.tsx index fe41112435..77b998c8a7 100644 --- a/src/testing/internal/rtl/renderHookAsync.tsx +++ b/src/testing/internal/rtl/renderHookAsync.tsx @@ -31,6 +31,7 @@ export async function renderHookAsync< ): Promise> { const { initialProps, ...renderOptions } = options; + // @ts-expect-error if (renderOptions.legacyRoot && typeof ReactDOM.render !== "function") { const error = new Error( "`legacyRoot: true` is not supported in this version of React. " + From e86d0142928b1532ae21fc99899310eeb47850b6 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 14:10:39 -0700 Subject: [PATCH 10/14] Swap testing library patch to 16.1.0 --- ...ary+react+16.0.1.patch => @testing-library+react+16.1.0.patch} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename patches/{@testing-library+react+16.0.1.patch => @testing-library+react+16.1.0.patch} (100%) diff --git a/patches/@testing-library+react+16.0.1.patch b/patches/@testing-library+react+16.1.0.patch similarity index 100% rename from patches/@testing-library+react+16.0.1.patch rename to patches/@testing-library+react+16.1.0.patch From 60fd22a60cc0c01500dec5b7129b692614fab015 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 16:08:26 -0700 Subject: [PATCH 11/14] Add shim for react-dom/client for React 17 --- config/jest.config.js | 1 + config/jest/react-dom-17-client.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 config/jest/react-dom-17-client.js diff --git a/config/jest.config.js b/config/jest.config.js index ffdf6c4871..977c2e8e80 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -83,6 +83,7 @@ const standardReact17Config = { moduleNameMapper: { "^react$": "react-17", "^react-dom$": "react-dom-17", + "^react-dom/client$": "/../config/jest/react-dom-17-client.js", "^react-dom/server$": "react-dom-17/server", "^react-dom/test-utils$": "react-dom-17/test-utils", }, diff --git a/config/jest/react-dom-17-client.js b/config/jest/react-dom-17-client.js new file mode 100644 index 0000000000..44a9ae8583 --- /dev/null +++ b/config/jest/react-dom-17-client.js @@ -0,0 +1,15 @@ +// Shim for React 17 react-dom/client entrypoint imported by React Testing +// Library + +module.exports = { + hydrateRoot: () => { + throw new Error( + "Cannot use hydrateRoot with React 17. Ensure this uses legacy root instead" + ); + }, + createRoot: () => { + throw new Error( + "Cannot use createRoot with React 17. Ensure this uses legacy root instead" + ); + }, +}; From 562f15787404bcaf6920a3eafdc84fac0e4a0ba6 Mon Sep 17 00:00:00 2001 From: jerelmiller Date: Thu, 5 Dec 2024 23:18:59 +0000 Subject: [PATCH 12/14] Clean up Prettier, Size-limit, and Api-Extractor --- .size-limits.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.size-limits.json b/.size-limits.json index 54bce409eb..c7b4947027 100644 --- a/.size-limits.json +++ b/.size-limits.json @@ -1,4 +1,4 @@ { - "dist/apollo-client.min.cjs": 41613, + "dist/apollo-client.min.cjs": 41615, "import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 34349 } From 782ed67326274883d594ef4d12cad5974e0e9c06 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Thu, 5 Dec 2024 16:23:11 -0700 Subject: [PATCH 13/14] Fix type error in getDataFromTree --- src/react/components/__tests__/ssr/getDataFromTree.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/react/components/__tests__/ssr/getDataFromTree.test.tsx b/src/react/components/__tests__/ssr/getDataFromTree.test.tsx index 6441008606..326bdc6828 100644 --- a/src/react/components/__tests__/ssr/getDataFromTree.test.tsx +++ b/src/react/components/__tests__/ssr/getDataFromTree.test.tsx @@ -3,7 +3,7 @@ import React from "react"; import gql from "graphql-tag"; import { DocumentNode } from "graphql"; -import { ApolloClient } from "../../../../core"; +import { ApolloClient, TypedDocumentNode } from "../../../../core"; import { InMemoryCache as Cache } from "../../../../cache"; import { ApolloProvider, @@ -37,7 +37,7 @@ describe("SSR", () => { }); it("should run through all of the queries (also defined via Query component) that want SSR", () => { - const query = gql` + const query: TypedDocumentNode = gql` { currentUser { firstName @@ -63,7 +63,7 @@ describe("SSR", () => { const WrappedElement = () => ( - {({ data, loading }: { data: Data; loading: boolean }) => ( + {({ data, loading }) => (
{loading || !data ? "loading" : data.currentUser!.firstName}
From 554b45fc6121587381cc3f321eca00725d8cea2e Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Fri, 6 Dec 2024 11:17:17 +0100 Subject: [PATCH 14/14] bump `@testing-library/react-render-stream` to 2.0.0 --- package-lock.json | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index a4db69df62..f568baca25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,7 @@ "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "6.6.3", "@testing-library/react": "^16.1.0", - "@testing-library/react-render-stream": "2.0.0-alpha.1", + "@testing-library/react-render-stream": "2.0.0", "@testing-library/user-event": "14.5.2", "@tsconfig/node20": "20.1.4", "@types/bytes": "3.1.4", @@ -3605,9 +3605,9 @@ } }, "node_modules/@testing-library/react-render-stream": { - "version": "2.0.0-alpha.1", - "resolved": "https://registry.npmjs.org/@testing-library/react-render-stream/-/react-render-stream-2.0.0-alpha.1.tgz", - "integrity": "sha512-nCSbToZBlE3iEqzcFEv6jkXE1mw+tKSrHbfqE11K1/a9wiBd+eMfVVEb9Zyi8Rl75BLaX8z5REqHOGUg09zwTw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@testing-library/react-render-stream/-/react-render-stream-2.0.0.tgz", + "integrity": "sha512-fXDshOVxCyao0/R/cm9A1owfmE74ONHDUa+e0Xyc42SwDhpkmewxj/foRGc3CW3T5RT8pHIkwkHgnrM4MxT6FQ==", "dev": true, "license": "MIT", "dependencies": { @@ -3619,8 +3619,8 @@ "peerDependencies": { "@jest/globals": "*", "expect": "*", - "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0", - "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc" } }, "node_modules/@testing-library/react-render-stream/node_modules/agent-base": { diff --git a/package.json b/package.json index 60d01908b4..e509e80e8c 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,7 @@ "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "6.6.3", "@testing-library/react": "^16.1.0", - "@testing-library/react-render-stream": "2.0.0-alpha.1", + "@testing-library/react-render-stream": "2.0.0", "@testing-library/user-event": "14.5.2", "@tsconfig/node20": "20.1.4", "@types/bytes": "3.1.4",