Define "react-native-strict-api" type exports (#50909)

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

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

Reviewed By: cipolleschi

Differential Revision: D71969602

fbshipit-source-id: 291182cc826db8b33f21fc79698e6096876d17ef
This commit is contained in:
Alex Hunt
2025-04-28 10:00:39 -07:00
committed by Facebook GitHub Bot
parent 1d8fec19f0
commit 6ea24f7bb9
2 changed files with 35 additions and 5 deletions
+23 -5
View File
@@ -29,11 +29,28 @@
"main": "./index.js",
"types": "types",
"exports": {
".": "./index.js",
"./*": "./*.js",
"./*.js": "./*.js",
"./Libraries/*.d.ts": "./Libraries/*.d.ts",
"./types/*.d.ts": "./types/*.d.ts",
".": {
"react-native-strict-api": "./types_generated/index.d.ts",
"react-native-strict-api-UNSAFE-ALLOW-SUBPATHS": "./types_generated/index.d.ts",
"default": "./index.js"
},
"./*": {
"react-native-strict-api": null,
"react-native-strict-api-UNSAFE-ALLOW-SUBPATHS": "./types_generated/*.d.ts",
"default": "./*.js"
},
"./*.js": {
"react-native-strict-api": null,
"default": "./*.js"
},
"./Libraries/*.d.ts": {
"react-native-strict-api": null,
"default": "./Libraries/*.d.ts"
},
"./types/*.d.ts": {
"react-native-strict-api": null,
"default": "./types/*.d.ts"
},
"./gradle/*": null,
"./React/*": null,
"./ReactAndroid/*": null,
@@ -110,6 +127,7 @@
"!src/private/testing",
"third-party-podspecs",
"types",
"types_generated",
"!**/__docs__/**",
"!**/__fixtures__/**",
"!**/__flowtests__/**",
+12
View File
@@ -19,11 +19,23 @@
"engines": {
"node": ">=18"
},
"exports": {
".": {
"types": "./types_generated/index.d.ts",
"default": "./index.js"
},
"./*": {
"types": null,
"default": "./*.js"
},
"./package.json": "./package.json"
},
"files": [
"index.js",
"index.d.ts",
"Lists",
"README.md",
"types_generated",
"Utilities",
"!**/__docs__/**",
"!**/__fixtures__/**",