Skip to content

Align TurboModule EventEmitter payload types across platforms - #58063

Open
christophpurrer wants to merge 1 commit into
react:mainfrom
christophpurrer:export-D116952150
Open

Align TurboModule EventEmitter payload types across platforms#58063
christophpurrer wants to merge 1 commit into
react:mainfrom
christophpurrer:export-D116952150

Conversation

@christophpurrer

Copy link
Copy Markdown
Contributor

Summary:
Codegen's EventEmitter<T> support for TurboModules diverged between platforms
in two ways:

  • The explicit number types Double, Float and Int32 worked as emitter
    payloads on Android and C++, but iOS rejected them at codegen time (plain
    number worked). iOS now maps all of them to NSNumber *_Nonnull, matching
    how plain number is already emitted.
  • ArrayBuffer was rejected on Android and iOS, but the C++ generator silently
    accepted it and produced a jsi::ArrayBuffer emitter. ArrayBuffer is not
    emittable on any platform — Android emitters always carry a folly::dynamic
    payload, which cannot hold raw bytes — and the schema type
    NativeModuleEventEmitterBaseTypeAnnotation already excluded it. It is now
    rejected everywhere.

ArrayBuffer payloads are rejected in the shared parser, so Flow and TypeScript
specs produce the same error, and the three generators keep an equivalent guard
so schemas that are constructed without going through the parser fail the same
way. ArrayBuffer remains supported as a method argument and as a synchronous
return value.

Changelog:
[iOS][Added] - Support Double, Float and Int32 payloads for TurboModule EventEmitters
[General][Breaking] - Reject ArrayBuffer as a TurboModule EventEmitter payload on all platforms

Differential Revision: D116952150

Summary:
Codegen's `EventEmitter<T>` support for TurboModules diverged between platforms
in two ways:

- The explicit number types `Double`, `Float` and `Int32` worked as emitter
  payloads on Android and C++, but iOS rejected them at codegen time (plain
  `number` worked). iOS now maps all of them to `NSNumber *_Nonnull`, matching
  how plain `number` is already emitted.
- `ArrayBuffer` was rejected on Android and iOS, but the C++ generator silently
  accepted it and produced a `jsi::ArrayBuffer` emitter. `ArrayBuffer` is not
  emittable on any platform — Android emitters always carry a `folly::dynamic`
  payload, which cannot hold raw bytes — and the schema type
  `NativeModuleEventEmitterBaseTypeAnnotation` already excluded it. It is now
  rejected everywhere.

`ArrayBuffer` payloads are rejected in the shared parser, so Flow and TypeScript
specs produce the same error, and the three generators keep an equivalent guard
so schemas that are constructed without going through the parser fail the same
way. `ArrayBuffer` remains supported as a method argument and as a synchronous
return value.

Changelog:
[iOS][Added] - Support `Double`, `Float` and `Int32` payloads for TurboModule `EventEmitter`s
[General][Breaking] - Reject `ArrayBuffer` as a TurboModule `EventEmitter` payload on all platforms

Differential Revision: D116952150
@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 Aug 21, 2026
@meta-codesync

meta-codesync Bot commented Aug 21, 2026

Copy link
Copy Markdown

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

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