Skip to content

Commit

Permalink
Make some objects read-only in event-related APIs
Browse files Browse the repository at this point in the history
Summary:
Changelog: [internal]

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

Differential Revision: D68831136
  • Loading branch information
rubennorte authored and facebook-github-bot committed Jan 29, 2025
1 parent be15449 commit 2b38416
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/src/private/webapis/dom/events/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2b38416

Please sign in to comment.