From 9e34b45c1ed79853b6d570f505bce9c3ad04c875 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 22 Apr 2024 14:31:32 +0200 Subject: [PATCH 1/3] feat: Move `@types/react-dom` to peer dependencies Type dependencies need to match their runtime counterpart. If `foo` is a dependency, `@types/foo` needs to be one as well. If `foo` is a peer dependency, `@types/foo` needs to be one as well. This is especially apparent if the constraint on `foo` spans multiple major versions. If we'd make `@types/foo` a direct dependency, users couldn't control which major version they get. Package managers would pick the highest. By moving `@types/foo` to peer dependencies, users can control which version of `foo` and `@types/foo` they have. --- package.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c38a74e..d4e8cd40 100644 --- a/package.json +++ b/package.json @@ -46,10 +46,10 @@ "license": "MIT", "dependencies": { "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^10.0.0", - "@types/react-dom": "^18.0.0" + "@testing-library/dom": "^10.0.0" }, "devDependencies": { + "@types/react-dom": "^18.2.25", "@testing-library/jest-dom": "^5.11.6", "chalk": "^4.1.2", "dotenv-cli": "^4.0.0", @@ -62,9 +62,15 @@ "typescript": "^4.1.2" }, "peerDependencies": { + "@types/react-dom": "^18.0.0", "react": "^18.0.0", "react-dom": "^18.0.0" }, + "peerDependenciesMeta": { + "@types/react-dom": { + "optional": true + } + }, "eslintConfig": { "extends": "./node_modules/kcd-scripts/eslint.js", "parserOptions": { From c4b764e737134f98ac96b5dc608e69d9500a4dbb Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 26 Apr 2024 13:09:07 +0200 Subject: [PATCH 2/3] feat!: move dtl to peerDeps commit 2fa5eac17254b5bfb94cb510cba22b665c234ebf Author: Matan Borenkraout Date: Wed Apr 24 11:06:27 2024 +0300 fix formatting commit 7a07982822e25ceb29d91110be5076805bff9299 Author: Matan Borenkraout Date: Wed Apr 24 09:14:25 2024 +0300 feat!: move dtl to peerDeps --- README.md | 11 +++++++---- package.json | 7 ++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 85613475..bffa75a5 100644 --- a/README.md +++ b/README.md @@ -97,10 +97,12 @@ primary guiding principle is: ## Installation This module is distributed via [npm][npm] which is bundled with [node][node] and -should be installed as one of your project's `devDependencies`: +should be installed as one of your project's `devDependencies`. +Starting from RTL version 16, you'll also need to install +`@testing-library/dom`: ``` -npm install --save-dev @testing-library/react +npm install --save-dev @testing-library/react @testing-library/dom ``` or @@ -108,10 +110,11 @@ or for installation via [yarn][yarn] ``` -yarn add --dev @testing-library/react +yarn add --dev @testing-library/react @testing-library/dom ``` -This library has `peerDependencies` listings for `react` and `react-dom`. +This library has `peerDependencies` listings for `react`, `react-dom` and +starting from RTL version 16 also `@testing-library/dom`. _React Testing Library versions 13+ require React v18. If your project uses an older version of React, be sure to install version 12:_ diff --git a/package.json b/package.json index d4e8cd40..0d01214c 100644 --- a/package.json +++ b/package.json @@ -45,12 +45,12 @@ "author": "Kent C. Dodds (https://kentcdodds.com)", "license": "MIT", "dependencies": { - "@babel/runtime": "^7.12.5", - "@testing-library/dom": "^10.0.0" + "@babel/runtime": "^7.12.5" }, "devDependencies": { - "@types/react-dom": "^18.2.25", + "@testing-library/dom": "^10.0.0", "@testing-library/jest-dom": "^5.11.6", + "@types/react-dom": "^18.2.25", "chalk": "^4.1.2", "dotenv-cli": "^4.0.0", "jest-diff": "^29.7.0", @@ -62,6 +62,7 @@ "typescript": "^4.1.2" }, "peerDependencies": { + "@testing-library/dom": "^10.0.0", "@types/react-dom": "^18.0.0", "react": "^18.0.0", "react-dom": "^18.0.0" From 7bb03cc4819dd291ebf122bd193471912ac0c2ba Mon Sep 17 00:00:00 2001 From: Matan Borenkraout Date: Sat, 1 Jun 2024 17:53:55 +0300 Subject: [PATCH 3/3] push @types/react-dom back --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4235d76e..8bfbeecc 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "@testing-library/dom": "^10.0.0", "@testing-library/jest-dom": "^5.11.6", "@types/react": "^18.3.1", + "@types/react-dom": "^18.3.0", "chalk": "^4.1.2", "dotenv-cli": "^4.0.0", "jest-diff": "^29.7.0", @@ -63,8 +64,8 @@ }, "peerDependencies": { "@testing-library/dom": "^10.0.0", - "@types/react-dom": "^18.0.0", "@types/react": "^18.0.0", + "@types/react-dom": "^18.0.0", "react": "^18.0.0", "react-dom": "^18.0.0" },