Skip to content

Commit

Permalink
Add @types/react as optional peerDependency on packages that use it (#…
Browse files Browse the repository at this point in the history
…43509)

Summary:
Now that RN is providing TS type information, many of those .d.ts files depend on types from react.  In modern packagemanagers (Ex: pnpm) types/react will not be available to RN since it does not declare it as a dependency.

I also noticed that the types for react-native-popup-menu-android appear to be pointing to the wrong location.

Add types/react as a peerDependency on the packages that have .d.ts files that import from React.
Add types/react to peerDependencyMeta with optional:true to prevent users not using TS from requiring types/react.

## Changelog:

[GENERAL] [ADDED] Added types/react as an optional peerDependency

Pull Request resolved: #43509

Reviewed By: cortinico

Differential Revision: D55225940

Pulled By: NickGerleman

fbshipit-source-id: 4cbab071928cb925baec45f55461559acc9a54e6
  • Loading branch information
acoates-ms authored and facebook-github-bot committed Mar 25, 2024
1 parent 8a2cf68 commit dbf8e3f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@react-native/metro-babel-transformer": "0.75.0-main",
"@react-native/metro-config": "0.75.0-main",
"@tsconfig/node18": "1.0.1",
"@types/react": "^18.0.18",
"@types/react": "^18.2.6",
"@typescript-eslint/parser": "^7.1.1",
"ansi-styles": "^4.2.1",
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-popup-menu-android/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
* @format
*/

export type {default} from './PopupMenuAndroid';
export type {PopupMenuAndroidInstance} from './PopupMenuAndroid';
export type {default} from './js/PopupMenuAndroid';
export type {PopupMenuAndroidInstance} from './js/PopupMenuAndroid';
9 changes: 7 additions & 2 deletions packages/react-native-popup-menu-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"name": "@react-native/popup-menu-android",
"version": "0.75.0-main",
"description": "PopupMenu for the Android platform",
"react-native": "js/PopupMenuAndroid",
"source": "js/PopupMenuAndroid",
"main": "index.js",
"files": [
"js",
"android",
Expand All @@ -21,9 +20,15 @@
"@react-native/codegen": "0.75.0-main"
},
"peerDependencies": {
"@types/react": "^18.2.6",
"react": "*",
"react-native": "*"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"dependencies": {
"nullthrows": "^1.1.1"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@
"featureflags-update": "node ./scripts/featureflags/index.js"
},
"peerDependencies": {
"@types/react": "^18.2.6",
"react": "18.2.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"dependencies": {
"@jest/create-cache-key-function": "^29.6.3",
"@react-native-community/cli": "14.0.0-alpha.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/virtualized-lists/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
"react-test-renderer": "18.2.0"
},
"peerDependencies": {
"@types/react": "^18.2.6",
"react": "*",
"react-native": "*"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2767,10 +2767,10 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==

"@types/react@^18.0.18":
version "18.0.20"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.20.tgz#e4c36be3a55eb5b456ecf501bd4a00fd4fd0c9ab"
integrity sha512-MWul1teSPxujEHVwZl4a5HxQ9vVNsjTchVA+xRqv/VYGCuKGAU6UhfrTdF5aBefwD1BHUD8i/zq+O/vyCm/FrA==
"@types/react@^18.2.6":
version "18.2.67"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.67.tgz#96b7af0b5e79c756f4bdd981de2ca28472c858e5"
integrity sha512-vkIE2vTIMHQ/xL0rgmuoECBCkZFZeHr49HeWSc24AptMbNRo7pwSBvj73rlJJs9fGKj0koS+V7kQB1jHS0uCgw==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
Expand Down

0 comments on commit dbf8e3f

Please sign in to comment.