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 DatePickerIOS #22105

Closed
wants to merge 3 commits into from
Closed
Changes from 2 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: 8 additions & 3 deletions Libraries/Components/DatePicker/DatePickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This is a controlled component version of RCTDatePickerIOS
*
* @format
* @flow
* @flow strict-local
*/

'use strict';
Expand All @@ -21,10 +21,15 @@ const View = require('View');
const requireNativeComponent = require('requireNativeComponent');

import type {ViewProps} from 'ViewPropTypes';
import type {SyntheticEvent} from 'CoreEventTypes';

const RCTDatePickerIOS = requireNativeComponent('RCTDatePicker');

type Event = Object;
type Event = SyntheticEvent<
$ReadOnly<{|
timestamp: number,
|}>,
>;

type Props = $ReadOnly<{|
...ViewProps,
Expand Down Expand Up @@ -154,7 +159,7 @@ class DatePickerIOS extends React.Component<Props> {
? props.initialDate.getTime()
: undefined
}
locale={props.locale ? props.locale : undefined}
locale={props.locale}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the same behavior. React handles null (allowed by the flow type) differently than undefined. Was there a flow error that required this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes... I got this error...

Sketchy null check on string [1] which is potentially an empty string. Perhaps
you meant to check for null or undefined [2]? (sketchy-null-string)

I think this is a problem of flow. The situation is simlilar to this issue facebook/flow#4608

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.

Ah, I think to be semantically the same it needs to be changed to the following then.

locale={(props.locale != null && props.locale != "")  ? props.locale : undefined}

maximumDate={
props.maximumDate ? props.maximumDate.getTime() : undefined
}
Expand Down