Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn Flow strict mode on for KeyBoard #22114

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Libraries/Components/Keyboard/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
* @flow strict-local
*/

'use strict';
Expand Down Expand Up @@ -121,7 +121,10 @@ let Keyboard = {
* @param {string} eventName The `nativeEvent` is the string that identifies the event you're listening for.
* @param {function} callback function to be called when the event fires.
*/
removeListener(eventName: KeyboardEventName, callback: Function) {
removeListener(
eventName: KeyboardEventName,
callback: KeyboardEventListener,
) {
invariant(false, 'Dummy method used for documentation');
},

Expand Down Expand Up @@ -155,12 +158,12 @@ Keyboard = KeyboardEventEmitter;
Keyboard.dismiss = dismissKeyboard;
Keyboard.scheduleLayoutAnimation = function(event: KeyboardEvent) {
const {duration, easing} = event;
if (duration) {
if (duration != null && duration !== 0) {
LayoutAnimation.configureNext({
duration: duration,
update: {
duration: duration,
type: (easing && LayoutAnimation.Types[easing]) || 'keyboard',
type: (easing != null && LayoutAnimation.Types[easing]) || 'keyboard',
Copy link
Member

@elicwhite elicwhite Nov 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

This one doesn't need the check for empty string because LayoutAnimation.Types because easing is a key and would be indexing into .Types which probably doesn't have a defined key for the empty string. :)

Copy link
Member

@elicwhite elicwhite Nov 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, the easing type at the top of this file could probably be even stronger by using Type from LayoutAnimation.js instead of string.

},
});
}
Expand Down