Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

huntie
Copy link
Member

@huntie huntie commented Apr 24, 2025

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

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Apr 24, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D71969602

huntie added a commit to huntie/react-native that referenced this pull request Apr 25, 2025
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
@huntie huntie force-pushed the export-D71969602 branch from ed39e16 to c80dcde Compare April 25, 2025 13:42
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D71969602

huntie added a commit to huntie/react-native that referenced this pull request Apr 25, 2025
Summary:
Pull Request resolved: facebook#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

Differential Revision: D71969602
@huntie huntie force-pushed the export-D71969602 branch from c80dcde to 1d5f5af Compare April 25, 2025 13:46
Summary:
NOTE: Resubmission of D71968187.

Define `"exports"` field on the main `react-native` package.

**Notes**

Module resolution should be equivalent to the previous implicit `"main"` field (backwards compatible).

- Exports all module subpaths to JavaScript (Flow) source files, with and without `.js` suffix (unchanged ✅)
    - These are restricted to the `flow/` and `Libraries/` subdirectories (ℹ️ this should be unchanged, matching any JS imports apps may have today)
        - Still includes 3P integration scripts such as `./jest-preset.js` and `./rn-get-polyfills.js` (unchanged ✅)
- Exports `./package.json` (unchanged ✅)
- TypeScript should:
    - fall back to the `"types"` field (unchanged ✅)
    - OR to `"."`,`"./*"` when Package Exports support is enabled via `compilerOptions`, and use the *adjacent `.d.ts` file* (unchanged ✅)

Changelog:
[General][Breaking] - The `react-native` package now defines package.json `"exports"`.
- While these expose existing JavaScript and TypeScript modules, this change may affect deep imports of non-JS files via Node in third party tools.
- Imports from `src/` and `src/private/` directories are disallowed.

Differential Revision: D72228547
@huntie huntie force-pushed the export-D71969602 branch from 1d5f5af to 4dd8963 Compare April 25, 2025 20:22
huntie added a commit to huntie/react-native that referenced this pull request Apr 25, 2025
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
Summary:
Pull Request resolved: facebook#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

Differential Revision: D71969602
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D71969602

@huntie huntie force-pushed the export-D71969602 branch from 4dd8963 to c892fed Compare April 25, 2025 20:28
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Apr 28, 2025
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 6ea24f7.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @huntie in 6ea24f7

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants