Skip to content

Commit 4dd8963

Browse files
huntiefacebook-github-bot
authored andcommitted
Define "react-native-strict-api" type exports (#50909)
Summary: Enables and maps the `types_generated/` directory for `react-native` and `react-native/virtualized-lists` — exposing the new Strict TypeScript API entry points to React Native. **New `"exports"` conditions** - `"react-native-strict-api"` — The Strict TypeScript API opt in, exposing the `index.d.ts` entry point only. - `"react-native-strict-api-UNSAFE-ALLOW-SUBPATHS"` — Opts into the new from-source generated types, but allows accessing subpaths (unsafe). - We intend for this unsafe condition to be an escape hatch for Frameworks only (i.e. Expo). Note: In the case of `virtualized-lists`, we simply use the `"types"` condition — since this package did not expose any TypeScript API previously. NOTE: Should we need to roll back JS Stable API phase 1, **this is the single diff to revert**. Changelog: [General][Added] - Configure the "react-native-strict-api" opt in for our next-gen TypeScript API Differential Revision: D71969602
1 parent d9db5d2 commit 4dd8963

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

packages/react-native/package.json

+23-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,28 @@
2929
"main": "./index.js",
3030
"types": "types",
3131
"exports": {
32-
".": "./index.js",
33-
"./*": "./*.js",
34-
"./*.js": "./*.js",
35-
"./Libraries/*.d.ts": "./Libraries/*.d.ts",
36-
"./types/*.d.ts": "./types/*.d.ts",
32+
".": {
33+
"react-native-strict-api": "./types_generated/index.d.ts",
34+
"react-native-strict-api-UNSAFE-ALLOW-SUBPATHS": "./types_generated/index.d.ts",
35+
"default": "./index.js"
36+
},
37+
"./*": {
38+
"react-native-strict-api": null,
39+
"react-native-strict-api-UNSAFE-ALLOW-SUBPATHS": "./types_generated/*.d.ts",
40+
"default": "./*.js"
41+
},
42+
"./*.js": {
43+
"react-native-strict-api": null,
44+
"default": "./*.js"
45+
},
46+
"./Libraries/*.d.ts": {
47+
"react-native-strict-api": null,
48+
"default": "./Libraries/*.d.ts"
49+
},
50+
"./types/*.d.ts": {
51+
"react-native-strict-api": null,
52+
"default": "./types/*.d.ts"
53+
},
3754
"./gradle/*": null,
3855
"./React/*": null,
3956
"./ReactAndroid/*": null,
@@ -110,6 +127,7 @@
110127
"!src/private/testing",
111128
"third-party-podspecs",
112129
"types",
130+
"types_generated",
113131
"!**/__docs__/**",
114132
"!**/__fixtures__/**",
115133
"!**/__flowtests__/**",

packages/virtualized-lists/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,23 @@
1919
"engines": {
2020
"node": ">=18"
2121
},
22+
"exports": {
23+
".": {
24+
"types": "./types_generated/index.d.ts",
25+
"default": "./index.js"
26+
},
27+
"./*": {
28+
"types": null,
29+
"default": "./*.js"
30+
},
31+
"./package.json": "./package.json"
32+
},
2233
"files": [
2334
"index.js",
2435
"index.d.ts",
2536
"Lists",
2637
"README.md",
38+
"types_generated",
2739
"Utilities",
2840
"!**/__docs__/**",
2941
"!**/__fixtures__/**",

0 commit comments

Comments
 (0)