Skip to content

Commit

Permalink
Refine Keyboard API Event typings (#23272)
Browse files Browse the repository at this point in the history
Summary:
- Improve type inference of the `event.easing` keyboard event property with the `KeyboardEventEasing` type.
- Exporting `KeyboardEventName` and `KeyboardEventEasing` for others to use.
- Removing unnecessary optional property flag (ie.`?`) for all properties in `KeyboardEvent`. (I personally haven't seen any of the properties not being returned for all keyboard events).

[iOS] [Changed] - Refine Keyboard API Event typings
Pull Request resolved: #23272

Differential Revision: D13941758

Pulled By: cpojer

fbshipit-source-id: 4891898c29cf6963069dbe6b4d439694761fd9e7
  • Loading branch information
nossbigg authored and facebook-github-bot committed Feb 4, 2019
1 parent 2aa2401 commit 7ee13cc
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Libraries/Components/Keyboard/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ const KeyboardObserver = require('NativeModules').KeyboardObserver;
const dismissKeyboard = require('dismissKeyboard');
const KeyboardEventEmitter = new NativeEventEmitter(KeyboardObserver);

type KeyboardEventName =
export type KeyboardEventName =
| 'keyboardWillShow'
| 'keyboardDidShow'
| 'keyboardWillHide'
| 'keyboardDidHide'
| 'keyboardWillChangeFrame'
| 'keyboardDidChangeFrame';

export type KeyboardEventEasing =
| 'easeIn'
| 'easeInEaseOut'
| 'easeOut'
| 'linear'
| 'keyboard';

type ScreenRect = $ReadOnly<{|
screenX: number,
screenY: number,
Expand All @@ -33,11 +40,11 @@ type ScreenRect = $ReadOnly<{|
|}>;

export type KeyboardEvent = $ReadOnly<{|
duration?: number,
easing?: string,
duration: number,
easing: KeyboardEventEasing,
endCoordinates: ScreenRect,
startCoordinates?: ScreenRect,
isEventFromThisApp?: boolean,
startCoordinates: ScreenRect,
isEventFromThisApp: boolean,
|}>;

type KeyboardEventListener = (e: KeyboardEvent) => void;
Expand Down

0 comments on commit 7ee13cc

Please sign in to comment.