Skip to content

Commit 1f887b6

Browse files
committed
fixup types
1 parent 0957cc8 commit 1f887b6

File tree

2 files changed

+76
-110
lines changed

2 files changed

+76
-110
lines changed

packages/react-native/Libraries/Types/CoreEventTypes.js

Lines changed: 47 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,10 @@ export interface NativePointerEvent extends NativeMouseEvent {
221221
export type PointerEvent = NativeSyntheticEvent<NativePointerEvent>;
222222

223223
export type NativeTouchEvent = $ReadOnly<{
224-
altKey?: ?boolean, // [macOS]
225-
button?: ?number, // [macOS]
226224
/**
227225
* Array of all touch events that have changed since the last event
228226
*/
229227
changedTouches: $ReadOnlyArray<NativeTouchEvent>,
230-
ctrlKey?: ?boolean, // [macOS]
231228
/**
232229
* 3D Touch reported force
233230
* @platform ios
@@ -245,7 +242,7 @@ export type NativeTouchEvent = $ReadOnly<{
245242
* The Y position of the touch, relative to the element
246243
*/
247244
locationY: number,
248-
metaKey?: ?boolean, // [macOS]
245+
249246
/**
250247
* The X position of the touch, relative to the screen
251248
*/
@@ -254,7 +251,6 @@ export type NativeTouchEvent = $ReadOnly<{
254251
* The Y position of the touch, relative to the screen
255252
*/
256253
pageY: number,
257-
shiftKey?: ?boolean, // [macOS]
258254
/**
259255
* The node id of the element receiving the touch event
260256
*/
@@ -267,6 +263,13 @@ export type NativeTouchEvent = $ReadOnly<{
267263
* Array of all current touches on the screen
268264
*/
269265
touches: $ReadOnlyArray<NativeTouchEvent>,
266+
// [macOS
267+
ctrlKey?: ?boolean,
268+
altKey?: ?boolean,
269+
shiftKey?: ?boolean,
270+
metaKey?: ?boolean,
271+
button?: ?number,
272+
// macOS]
270273
}>;
271274

272275
export type GestureResponderEvent = ResponderSyntheticEvent<NativeTouchEvent>;
@@ -283,48 +286,6 @@ export type NativeScrollPoint = $ReadOnly<{
283286
x: number,
284287
}>;
285288

286-
// [macOS
287-
export type KeyEvent = NativeSyntheticEvent<
288-
$ReadOnly<{|
289-
// Modifier keys
290-
capsLockKey: boolean,
291-
shiftKey: boolean,
292-
ctrlKey: boolean,
293-
altKey: boolean,
294-
metaKey: boolean,
295-
numericPadKey: boolean,
296-
helpKey: boolean,
297-
functionKey: boolean,
298-
// Key options
299-
ArrowLeft: boolean,
300-
ArrowRight: boolean,
301-
ArrowUp: boolean,
302-
ArrowDown: boolean,
303-
key: string,
304-
|}>,
305-
>;
306-
307-
/**
308-
* Represents a key that could be passed to `KeyDownEvents` and `KeyUpEvents`.
309-
*
310-
* `key` is the actual key, such as "a", or one of the special values:
311-
* "Tab", "Escape", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
312-
* "Backspace", "Delete", "Home", "End", "PageUp", "PageDown".
313-
*
314-
* The rest are modifiers that when absent mean false.
315-
*
316-
* @platform macos
317-
*/
318-
export type HandledKeyEvent = $ReadOnly<{|
319-
altKey?: ?boolean,
320-
ctrlKey?: ?boolean,
321-
metaKey?: ?boolean,
322-
shiftKey?: ?boolean,
323-
key: string,
324-
|}>;
325-
326-
// macOS]
327-
328289
export type NativeScrollVelocity = $ReadOnly<{
329290
y: number,
330291
x: number,
@@ -371,28 +332,6 @@ export type MouseEvent = NativeSyntheticEvent<
371332
}>,
372333
>;
373334

374-
// // Base mouse event data shared between MouseEvent and DragEvent
375-
// export type NativeMouseEvent = $ReadOnly<{
376-
// clientX: number,
377-
// clientY: number,
378-
// pageX: number,
379-
// pageY: number,
380-
// timestamp: number,
381-
// screenX?: number,
382-
// screenY?: number,
383-
// altKey?: boolean,
384-
// ctrlKey?: boolean,
385-
// shiftKey?: boolean,
386-
// metaKey?: boolean,
387-
// }>;
388-
389-
// export type MouseEvent = NativeSyntheticEvent<
390-
// $ReadOnly<{
391-
// ...NativeMouseEvent,
392-
// dataTransfer?: DataTransfer,
393-
// }>,
394-
// >;
395-
396335
// [macOS
397336
export type DataTransferItem = $ReadOnly<{
398337
name: string,
@@ -416,13 +355,46 @@ export type DragEvent = NativeSyntheticEvent<
416355
pageX: number,
417356
pageY: number,
418357
timestamp: number,
419-
screenX?: number,
420-
screenY?: number,
421-
altKey?: boolean,
422-
ctrlKey?: boolean,
423-
shiftKey?: boolean,
424-
metaKey?: boolean,
425358
dataTransfer?: DataTransfer,
426359
}>,
427360
>;
361+
362+
export type KeyEvent = NativeSyntheticEvent<
363+
$ReadOnly<{|
364+
// Modifier keys
365+
capsLockKey: boolean,
366+
shiftKey: boolean,
367+
ctrlKey: boolean,
368+
altKey: boolean,
369+
metaKey: boolean,
370+
numericPadKey: boolean,
371+
helpKey: boolean,
372+
functionKey: boolean,
373+
// Key options
374+
ArrowLeft: boolean,
375+
ArrowRight: boolean,
376+
ArrowUp: boolean,
377+
ArrowDown: boolean,
378+
key: string,
379+
|}>,
380+
>;
381+
382+
/**
383+
* Represents a key that could be passed to `KeyDownEvents` and `KeyUpEvents`.
384+
*
385+
* `key` is the actual key, such as "a", or one of the special values:
386+
* "Tab", "Escape", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
387+
* "Backspace", "Delete", "Home", "End", "PageUp", "PageDown".
388+
*
389+
* The rest are modifiers that when absent mean false.
390+
*
391+
* @platform macos
392+
*/
393+
export type HandledKeyEvent = $ReadOnly<{|
394+
ctrlKey?: ?boolean,
395+
altKey?: ?boolean,
396+
shiftKey?: ?boolean,
397+
metaKey?: ?boolean,
398+
key: string,
399+
|}>;
428400
// macOS]

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8486,21 +8486,21 @@ export interface NativePointerEvent extends NativeMouseEvent {
84868486
}
84878487
export type PointerEvent = NativeSyntheticEvent<NativePointerEvent>;
84888488
export type NativeTouchEvent = $ReadOnly<{
8489-
altKey?: ?boolean,
8490-
button?: ?number,
84918489
changedTouches: $ReadOnlyArray<NativeTouchEvent>,
8492-
ctrlKey?: ?boolean,
84938490
force?: number,
84948491
identifier: number,
84958492
locationX: number,
84968493
locationY: number,
8497-
metaKey?: ?boolean,
84988494
pageX: number,
84998495
pageY: number,
8500-
shiftKey?: ?boolean,
85018496
target: ?number,
85028497
timestamp: number,
85038498
touches: $ReadOnlyArray<NativeTouchEvent>,
8499+
ctrlKey?: ?boolean,
8500+
altKey?: ?boolean,
8501+
shiftKey?: ?boolean,
8502+
metaKey?: ?boolean,
8503+
button?: ?number,
85048504
}>;
85058505
export type GestureResponderEvent = ResponderSyntheticEvent<NativeTouchEvent>;
85068506
export type NativeScrollRectangle = $ReadOnly<{
@@ -8513,30 +8513,6 @@ export type NativeScrollPoint = $ReadOnly<{
85138513
y: number,
85148514
x: number,
85158515
}>;
8516-
export type KeyEvent = NativeSyntheticEvent<
8517-
$ReadOnly<{|
8518-
capsLockKey: boolean,
8519-
shiftKey: boolean,
8520-
ctrlKey: boolean,
8521-
altKey: boolean,
8522-
metaKey: boolean,
8523-
numericPadKey: boolean,
8524-
helpKey: boolean,
8525-
functionKey: boolean,
8526-
ArrowLeft: boolean,
8527-
ArrowRight: boolean,
8528-
ArrowUp: boolean,
8529-
ArrowDown: boolean,
8530-
key: string,
8531-
|}>,
8532-
>;
8533-
export type HandledKeyEvent = $ReadOnly<{|
8534-
altKey?: ?boolean,
8535-
ctrlKey?: ?boolean,
8536-
metaKey?: ?boolean,
8537-
shiftKey?: ?boolean,
8538-
key: string,
8539-
|}>;
85408516
export type NativeScrollVelocity = $ReadOnly<{
85418517
y: number,
85428518
x: number,
@@ -8592,15 +8568,33 @@ export type DragEvent = NativeSyntheticEvent<
85928568
pageX: number,
85938569
pageY: number,
85948570
timestamp: number,
8595-
screenX?: number,
8596-
screenY?: number,
8597-
altKey?: boolean,
8598-
ctrlKey?: boolean,
8599-
shiftKey?: boolean,
8600-
metaKey?: boolean,
86018571
dataTransfer?: DataTransfer,
86028572
}>,
86038573
>;
8574+
export type KeyEvent = NativeSyntheticEvent<
8575+
$ReadOnly<{|
8576+
capsLockKey: boolean,
8577+
shiftKey: boolean,
8578+
ctrlKey: boolean,
8579+
altKey: boolean,
8580+
metaKey: boolean,
8581+
numericPadKey: boolean,
8582+
helpKey: boolean,
8583+
functionKey: boolean,
8584+
ArrowLeft: boolean,
8585+
ArrowRight: boolean,
8586+
ArrowUp: boolean,
8587+
ArrowDown: boolean,
8588+
key: string,
8589+
|}>,
8590+
>;
8591+
export type HandledKeyEvent = $ReadOnly<{|
8592+
ctrlKey?: ?boolean,
8593+
altKey?: ?boolean,
8594+
shiftKey?: ?boolean,
8595+
metaKey?: ?boolean,
8596+
key: string,
8597+
|}>;
86048598
"
86058599
`;
86068600

0 commit comments

Comments
 (0)