Skip to content
Permalink
Browse files

Refine Keyboard API Event typings (#23272)

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 7ee13cc84c342244d3aa9e485de0e759482287ea
Showing with 12 additions and 5 deletions.
  1. +12 −5 Libraries/Components/Keyboard/Keyboard.js
@@ -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,
@@ -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;

0 comments on commit 7ee13cc

Please sign in to comment.
You can’t perform that action at this time.