Skip to content

Commit c80dcde

Browse files
huntiefacebook-github-bot
authored andcommitted
Define "react-native-strict-api" type exports (facebook#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 e873955 commit c80dcde

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

packages/react-native/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@
2929
"main": "./index.js",
3030
"types": "types",
3131
"exports": {
32-
".": "./index.js",
33-
"./*": "./*.js",
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+
},
3442
"./*.js": "./*.js",
3543
"./Libraries/*.d.ts": "./Libraries/*.d.ts",
3644
"./types/*.d.ts": "./types/*.d.ts",
@@ -110,6 +118,7 @@
110118
"!src/private/testing",
111119
"third-party-podspecs",
112120
"types",
121+
"types_generated",
113122
"!**/__docs__/**",
114123
"!**/__fixtures__/**",
115124
"!**/__flowtests__/**",

packages/virtualized-lists/package.json

+8
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@
1919
"engines": {
2020
"node": ">=18"
2121
},
22+
"exports": {
23+
".": {
24+
"types": "./types_generated/index.d.ts",
25+
"default": "./index.js"
26+
},
27+
"./package.json": "./package.json"
28+
},
2229
"files": [
2330
"index.js",
2431
"index.d.ts",
2532
"Lists",
2633
"README.md",
34+
"types_generated",
2735
"Utilities",
2836
"!**/__docs__/**",
2937
"!**/__fixtures__/**",

0 commit comments

Comments
 (0)