Add @types/react as optional peerDependency on packages that use it (#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.

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

Pull Request resolved: https://github.com/facebook/react-native/pull/43509

Reviewed By: cortinico

Differential Revision: D55225940

Pulled By: NickGerleman

fbshipit-source-id: 4cbab071928cb925baec45f55461559acc9a54e6
This commit is contained in:
Andrew Coates
2024-04-02 10:35:24 +01:00
committed by Alex Hunt
parent 462fbaef0c
commit 5d63c85ced
6 changed files with 26 additions and 9 deletions
+1 -1
View File
@@ -61,7 +61,7 @@
"@react-native/metro-babel-transformer": "0.74.76",
"@react-native/metro-config": "0.74.76",
"@tsconfig/node18": "1.0.1",
"@types/react": "^18.0.18",
"@types/react": "^18.2.6",
"@typescript-eslint/parser": "^6.7.4",
"ansi-styles": "^4.2.1",
"async": "^3.2.2",
+2 -2
View File
@@ -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';
@@ -2,8 +2,7 @@
"name": "@react-native/popup-menu-android",
"version": "0.74.76",
"description": "PopupMenu for the Android platform",
"react-native": "js/PopupMenuAndroid",
"source": "js/PopupMenuAndroid",
"main": "index.js",
"files": [
"js",
"android",
@@ -21,9 +20,15 @@
"@react-native/codegen": "0.74.76"
},
"peerDependencies": {
"@types/react": "^18.2.6",
"react": "*",
"react-native": "*"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"dependencies": {
"nullthrows": "^1.1.1"
},
+6
View File
@@ -97,8 +97,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": "13.6.2",
+6
View File
@@ -27,7 +27,13 @@
"react-test-renderer": "18.2.0"
},
"peerDependencies": {
"@types/react": "^18.2.6",
"react": "*",
"react-native": "*"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
}
+4 -4
View File
@@ -2781,10 +2781,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" "*"