Skip to content

Hide src/ directory from TypeScript (#57277)#57277

Open
huntie wants to merge 3 commits into
react:mainfrom
huntie:export-D109018821
Open

Hide src/ directory from TypeScript (#57277)#57277
huntie wants to merge 3 commits into
react:mainfrom
huntie:export-D109018821

Conversation

@huntie

@huntie huntie commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary:

Motivation

Incremental progress towards restricting React Native's internal JavaScript source code.

  • src/private/ was added relatively recently, with very little OSS code depending on it — we can action earlier.
  • Helps to reduce the increasingly complicated state of our root "exports" map.

Changes

Resolve to null for the "types" package exports condition — this hides from TypeScript suggestions/auto-import.

  • Breaking: TypeScript's language server will no longer be able to see these modules, and projects will need a // $TSIgnore on these imports.
  • The ability to access these modules is unchanged: they remain present in the bundle and accessible by Metro.

Changelog:
[General][Breaking] - Deep imports to 'react-native/src/private/...' have been restricted, and are no longer visible to TypeScript. These subpaths still exist, but do not have type coverage.

Differential Revision: D109018821

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2026
@meta-codesync

meta-codesync Bot commented Jun 18, 2026

Copy link
Copy Markdown

@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109018821.

@meta-codesync meta-codesync Bot changed the title Hide src/ directory from TypeScript Hide src/ directory from TypeScript (#57277) Jun 18, 2026
@huntie huntie force-pushed the export-D109018821 branch from f56cc90 to 2a052d1 Compare June 18, 2026 14:25
huntie added a commit to huntie/react-native that referenced this pull request Jun 18, 2026
Summary:

**Motivation**

Incremental progress towards restricting React Native's internal JavaScript source code.

- `src/private/` was added relatively recently, with very little OSS code depending on it — we can action earlier.
- Helps to reduce the increasingly complicated state of our root `"exports"` map.

**Changes**

Resolve to `null` for the `"types"` package exports condition — this hides from TypeScript suggestions/auto-import.

- **Breaking**: TypeScript's language server will no longer be able to see these modules, and projects will need a `// $TSIgnore` on these imports.
- The ability to access these modules is unchanged: they remain present in the bundle and accessible by Metro.

Changelog:
[General][Breaking] - Deep imports to `'react-native/src/private/...'` have been restricted, and are no longer visible to TypeScript. These subpaths still exist, but do not have type coverage.

Differential Revision: D109018821
huntie added 3 commits June 18, 2026 07:58
Summary:

`interface.js` was a legacy, Flow-only entry point whose sole content was a bare `declare var __DEV__: boolean;` global, registered as a Flow `[libs]` file.

Relocate into `flow/globals.js`, allowing us to drop this from the package `"files"` (and `"exports"`) list.

Changelog: [Internal]

Differential Revision: D109018822
Summary:

Simplify `"exports"` mapping on the `react-native` package by replacing the `"./*"` wildcard export with explicit listed subpaths (invert from blocklist to allowlist).

These changes are **non-breaking** — the net accessible exports subpaths before/after are equivalent.

Changelog: [Internal]

Differential Revision: D109018823
Summary:

**Motivation**

Incremental progress towards restricting React Native's internal JavaScript source code.

- `src/private/` was added relatively recently, with very little OSS code depending on it — we can action earlier.
- Helps to reduce the increasingly complicated state of our root `"exports"` map.

**Changes**

Resolve to `null` for the `"types"` package exports condition — this hides from TypeScript suggestions/auto-import.

- **Breaking**: TypeScript's language server will no longer be able to see these modules, and projects will need a `// $TSIgnore` on these imports.
- The ability to access these modules is unchanged: they remain present in the bundle and accessible by Metro.

Changelog:
[General][Breaking] - Deep imports to `'react-native/src/private/...'` have been restricted, and are no longer visible to TypeScript. These subpaths still exist, but do not have type coverage.

Differential Revision: D109018821
@huntie huntie force-pushed the export-D109018821 branch from 2a052d1 to 567f264 Compare June 18, 2026 14:59
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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant