Skip to content

Commit

Permalink
feat: Move @types/react-dom to peer dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eps1lon committed Apr 26, 2024
1 parent d143f46 commit d8a2391
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down

0 comments on commit d8a2391

Please sign in to comment.