Skip to content

Commit f0826b9

Browse files
committed
fix: fix flow error
1 parent 16955ab commit f0826b9

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

jest/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const mockAndroidDialogDateChange = (datePickedByUser: Date) => {
1717
return {
1818
action: DATE_SET_ACTION,
1919
timestamp: pickedDate.getTime(),
20+
utcOffset: 0,
2021
};
2122
}
2223
return (fakeDateTimePickerAndroidOpener: PresentPickerCallback);

src/types.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export type NativeEventIOS = SyntheticEvent<
3636
export type DateTimePickerEvent = {
3737
type: AndroidEvtTypes,
3838
nativeEvent: $ReadOnly<{
39-
timestamp?: number,
40-
utcOffset: number,
39+
timestamp: number,
40+
utcOffset?: number,
4141
...
4242
}>,
4343
...
@@ -94,15 +94,13 @@ type ViewPropsWithoutChildren = $Diff<
9494
export type BaseProps = $ReadOnly<{|
9595
...ViewPropsWithoutChildren,
9696
...DateOptions,
97-
9897
/**
9998
* Timezone in database name.
10099
*
101100
* By default, the date picker will use the device's timezone. With this
102-
* parameter, it is possible to force a certain timezone offset. For
103-
* instance, to show times in Pacific Standard Time
101+
* parameter, it is possible to force a certain timezone based on IANA
104102
*/
105-
timeZoneName?: string,
103+
timeZoneName?: ?string,
106104
|}>;
107105

108106
export type IOSNativeProps = $ReadOnly<{|
@@ -223,11 +221,8 @@ export type TimePickerOptions = {|
223221

224222
export type DateTimePickerResult = $ReadOnly<{|
225223
action: 'timeSetAction' | 'dateSetAction' | 'dismissedAction',
226-
year: number,
227-
month: number,
228-
day: number,
229-
hour: number,
230-
minute: number,
224+
timestamp: number,
225+
utcOffset: number,
231226
|}>;
232227

233228
export type RCTDateTimePickerNative = Class<HostComponent<IOSNativeProps>>;

src/utils.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ export function sharedPropsValidation({
3636
timeZoneOffsetInMinutes,
3737
}: {
3838
value: ?Date,
39-
timeZoneName: ?string,
40-
timeZoneOffsetInMinutes: ?number,
39+
timeZoneName?: ?string,
40+
timeZoneOffsetInMinutes?: ?number,
4141
}) {
4242
invariant(value, 'A date or time must be specified as `value` prop');
4343
invariant(
4444
value instanceof Date,
4545
'`value` prop must be an instance of Date object',
4646
);
4747
invariant(
48-
!(timeZoneName && timeZoneOffsetInMinutes),
48+
timeZoneName == null ||
49+
timeZoneName === undefined ||
50+
timeZoneOffsetInMinutes == null ||
51+
timeZoneOffsetInMinutes === undefined,
4952
'`timeZoneName` and `timeZoneOffsetInMinutes` cannot be specified at the same time',
5053
);
5154
}

test/userlandTestExamples.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import DateTimePicker from '../src/index';
99
// $FlowExpectedError: complains about import path
1010
import {DateTimePickerAndroid} from '../src/DateTimePickerAndroid.android';
1111

12+
// $FlowFixMe[untyped-import]
1213
import {render, fireEvent, waitFor} from '@testing-library/react-native';
1314
import {createDateTimeSetEvtParams} from '../src/index';
1415
import {mockAndroidDialogDateChange, mockAndroidDialogDismissal} from '../jest';

0 commit comments

Comments
 (0)