Make some objects read-only in event-related APIs (#49045)

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

Changelog: [internal]

Making some objects read-only to reflect usage and allow callers to pass both read-only and writable objects.

Reviewed By: yungsters

Differential Revision: D68831136

fbshipit-source-id: e9a2d96ec0abd13f609d26d376e6da946f802011
This commit is contained in:
Rubén Norte
2025-01-29 10:06:08 -08:00
committed by Facebook GitHub Bot
parent 4ba0e79712
commit d80284c607
3 changed files with 8 additions and 8 deletions
@@ -19,10 +19,10 @@ import type {EventInit} from './Event';
import Event from './Event';
export type CustomEventInit = {
export type CustomEventInit = $ReadOnly<{
...EventInit,
detail?: mixed,
};
}>;
export default class CustomEvent extends Event {
_detail: mixed;
@@ -36,11 +36,11 @@ import {
setStopPropagationFlag,
} from './internals/EventInternals';
export type EventInit = {
export type EventInit = $ReadOnly<{
bubbles?: boolean,
cancelable?: boolean,
composed?: boolean,
};
}>;
export default class Event {
static +NONE: 0;
@@ -39,16 +39,16 @@ export type EventHandler = interface {
};
export type EventListener = EventCallback | EventHandler;
export type EventListenerOptions = {
export type EventListenerOptions = $ReadOnly<{
capture?: boolean,
};
}>;
export type AddEventListenerOptions = {
export type AddEventListenerOptions = $ReadOnly<{
...EventListenerOptions,
passive?: boolean,
once?: boolean,
signal?: AbortSignal,
};
}>;
type EventListenerRegistration = {
+callback: EventListener,