Skip to content

Hide runtime-managed class constructors from public API (#57028)#57028

Closed
huntie wants to merge 1 commit into
facebook:mainfrom
huntie:export-D107119545
Closed

Hide runtime-managed class constructors from public API (#57028)#57028
huntie wants to merge 1 commit into
facebook:mainfrom
huntie:export-D107119545

Conversation

@huntie
Copy link
Copy Markdown
Member

@huntie huntie commented Jun 1, 2026

Summary:

Mark ReactNativeElement and ReadOnlyNode as non-user-constructible in the generated TypeScript definitions by emitting protected constructor().

Motivation

  • Correctness — like web DOM elements (HTMLElement, etc.), ReactNativeElement instances are created by the React Native runtime, not in user space. See also D107227212.
  • Reduce public API surface (in particular, since this is also aliased to the HostInstance type).

Changes

  • Adds a new build-types protected-constructor directive and corresponding build-types post-transform.
  • Applies directive to ReactNativeElement and ReadOnlyNode.
  • Also extracts shared build-types directive helpers into transforms/typescript/utils/buildDirectives.js.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D107119545

@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 1, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Jun 1, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@meta-codesync meta-codesync Bot changed the title Hide ReactNativeElement constructor from public API Hide ReactNativeElement constructor from public API (#57028) Jun 1, 2026
huntie added a commit to huntie/react-native that referenced this pull request Jun 1, 2026
Summary:

Mark `ReactNativeElement` as non-user-constructible in the generated TypeScript definitions by selectively stripping the constructor on this type.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types omit-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Differential Revision: D107119545
@huntie huntie force-pushed the export-D107119545 branch from afcb4ed to 5bbd9b2 Compare June 1, 2026 18:25
huntie added a commit to huntie/react-native that referenced this pull request Jun 1, 2026
Summary:

Mark `ReactNativeElement` as non-user-constructible in the generated TypeScript definitions by selectively stripping the constructor on this type.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types omit-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Differential Revision: D107119545
@huntie huntie force-pushed the export-D107119545 branch from 5bbd9b2 to 2decca5 Compare June 1, 2026 18:52
@huntie huntie changed the title Hide ReactNativeElement constructor from public API (#57028) Hide runtime-managed class constructors from public API (#57028) Jun 2, 2026
huntie added a commit to huntie/react-native that referenced this pull request Jun 2, 2026
Summary:

Mark `ReactNativeElement` and `ReadOnlyNode` as non-user-constructible in the generated TypeScript definitions by emitting `protected constructor()`.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space. See also D107227212.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types private-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement` and `ReadOnlyNode`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D107119545
huntie added a commit to huntie/react-native that referenced this pull request Jun 2, 2026
Summary:

Mark `ReactNativeElement` and `ReadOnlyNode` as non-user-constructible in the generated TypeScript definitions by emitting `protected constructor()`.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space. See also D107227212.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types private-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement` and `ReadOnlyNode`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D107119545
huntie added a commit to huntie/react-native that referenced this pull request Jun 2, 2026
Summary:

Mark `ReactNativeElement` and `ReadOnlyNode` as non-user-constructible in the generated TypeScript definitions by emitting `protected constructor()`.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space. See also D107227212.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types private-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement` and `ReadOnlyNode`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D107119545
@huntie huntie force-pushed the export-D107119545 branch 2 times, most recently from 92c19e9 to 01bfa84 Compare June 2, 2026 13:43
huntie added a commit to huntie/react-native that referenced this pull request Jun 2, 2026
Summary:

Mark `ReactNativeElement` and `ReadOnlyNode` as non-user-constructible in the generated TypeScript definitions by emitting `protected constructor()`.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space. See also D107227212.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types protected-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement` and `ReadOnlyNode`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D107119545
Summary:

Mark `ReactNativeElement` and `ReadOnlyNode` as non-user-constructible in the generated TypeScript definitions by emitting `protected constructor()`.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space. See also D107227212.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types protected-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement` and `ReadOnlyNode`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D107119545
@huntie huntie force-pushed the export-D107119545 branch from 01bfa84 to 494964a Compare June 2, 2026 13:49
huntie added a commit to huntie/react-native that referenced this pull request Jun 2, 2026
Summary:

Mark `ReactNativeElement` and `ReadOnlyNode` as non-user-constructible in the generated TypeScript definitions by emitting `protected constructor()`.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space. See also D107227212.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types protected-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement` and `ReadOnlyNode`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D107119545
huntie added a commit to huntie/react-native that referenced this pull request Jun 2, 2026
Summary:

Mark `ReactNativeElement` and `ReadOnlyNode` as non-user-constructible in the generated TypeScript definitions by emitting `protected constructor()`.

**Motivation**

- Correctness — like web DOM elements (`HTMLElement`, etc.), `ReactNativeElement` instances are created by the React Native runtime, not in user space. See also D107227212.
- Reduce public API surface (in particular, since this is also aliased to the `HostInstance` type).

**Changes**

- Adds a new `build-types protected-constructor` directive and corresponding `build-types` post-transform.
- Applies directive to `ReactNativeElement` and `ReadOnlyNode`.
- Also extracts shared `build-types` directive helpers into `transforms/typescript/utils/buildDirectives.js`.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D107119545
@meta-codesync meta-codesync Bot closed this in d566838 Jun 2, 2026
@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Jun 2, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Jun 2, 2026

This pull request has been merged in d566838.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @huntie in d566838

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

@huntie huntie deleted the export-D107119545 branch June 2, 2026 16:25
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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants