Skip to content

Commit ea97bf3

Browse files
authored
chore: update flowtype (#231)
1 parent efdb632 commit ea97bf3

File tree

6 files changed

+317
-210
lines changed

6 files changed

+317
-210
lines changed

.flowconfig

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ suppress_type=$FlowFixMe
4444
suppress_type=$FlowFixMeProps
4545
suppress_type=$FlowFixMeState
4646

47-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
49-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
50-
5147
[lints]
5248
sketchy-null-number=warn
5349
sketchy-null-mixed=warn
@@ -56,7 +52,6 @@ untyped-type-import=warn
5652
nonstrict-import=warn
5753
deprecated-type=warn
5854
unsafe-getters-setters=warn
59-
inexact-spread=warn
6055
unnecessary-invariant=warn
6156
signature-verification-failure=warn
6257
deprecated-utility=error
@@ -71,4 +66,4 @@ untyped-import
7166
untyped-type-import
7267

7368
[version]
74-
^0.113.0
69+
^0.137.0

example/App.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* @flow
66
*/
77

8-
import React, {useState, useEffect} from 'react';
8+
import * as React from 'react';
9+
import {useState, useEffect} from 'react';
910
import {
1011
Alert,
1112
StyleSheet,
@@ -16,20 +17,26 @@ import {
1617
} from 'react-native';
1718
import PushNotificationIOS from '../js';
1819

19-
class Button extends React.Component<$FlowFixMeProps> {
20-
render() {
21-
return (
22-
<TouchableHighlight
23-
underlayColor={'white'}
24-
style={styles.button}
25-
onPress={this.props.onPress}>
26-
<Text style={styles.buttonLabel}>{this.props.label}</Text>
27-
</TouchableHighlight>
28-
);
29-
}
30-
}
20+
type ButtonProps = {|
21+
onPress: () => void | Promise<void>,
22+
label: string,
23+
|};
24+
25+
const Button: React.StatelessFunctionalComponent<ButtonProps> = ({
26+
onPress,
27+
label,
28+
}) => {
29+
return (
30+
<TouchableHighlight
31+
underlayColor={'white'}
32+
style={styles.button}
33+
onPress={onPress}>
34+
<Text style={styles.buttonLabel}>{label}</Text>
35+
</TouchableHighlight>
36+
);
37+
};
3138

32-
export const App = () => {
39+
export const App = (): React.Node => {
3340
const [permissions, setPermissions] = useState({});
3441

3542
useEffect(() => {

js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import {NativeEventEmitter, NativeModules} from 'react-native';
1414
import invariant from 'invariant';
15-
import {
15+
import type {
1616
NotificationAlert,
1717
NotificationRequest,
1818
NotificationCategory,
@@ -29,7 +29,7 @@ const NOTIF_REGISTER_EVENT = 'remoteNotificationsRegistered';
2929
const NOTIF_REGISTRATION_ERROR_EVENT = 'remoteNotificationRegistrationError';
3030
const DEVICE_LOCAL_NOTIF_EVENT = 'localNotificationReceived';
3131

32-
export {
32+
export type {
3333
NotificationAlert,
3434
NotificationRequest,
3535
NotificationCategory,

js/types.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
export type NotificationRequest = {
1+
/**
2+
* @flow
3+
*/
4+
5+
export type NotificationRequest = {|
26
/**
37
* identifier of the notification.
48
* Required in order to retrieve specific notification.
@@ -49,33 +53,33 @@ export type NotificationRequest = {
4953
* Optional data to be added to the notification
5054
*/
5155
userInfo?: Object,
52-
};
56+
|};
5357

5458
/**
5559
* Alert Object that can be included in the aps `alert` object
5660
*/
57-
export type NotificationAlert = {
61+
export type NotificationAlert = {|
5862
title?: string,
5963
subtitle?: string,
6064
body?: string,
61-
};
65+
|};
6266

6367
/**
6468
* Notification Category that can include specific actions
6569
*/
66-
export type NotificationCategory = {
70+
export type NotificationCategory = {|
6771
/**
6872
* Identifier of the notification category.
6973
* Notification with this category will have the specified actions.
7074
*/
7175
id: string,
7276
actions: NotificationAction[],
73-
};
77+
|};
7478

7579
/**
7680
* Notification Action that can be added to specific categories
7781
*/
78-
export type NotificationAction = {
82+
export type NotificationAction = {|
7983
/**
8084
* Identifier of Action.
8185
* This value will be returned as actionIdentifier when notification is received.
@@ -109,4 +113,4 @@ export type NotificationAction = {
109113
*/
110114
placeholder?: string,
111115
},
112-
};
116+
|};

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
"babel-core": "^7.0.0-bridge.0",
4949
"babel-jest": "24.1.0",
5050
"babel-plugin-module-resolver": "^3.1.3",
51-
"eslint": "^6.8.0",
52-
"flow-bin": "^0.113.0",
51+
"eslint": "^7.13.0",
52+
"flow-bin": "0.137.0",
5353
"jest": "^24.9.0",
54-
"metro-react-native-babel-preset": "0.58.0",
54+
"metro-react-native-babel-preset": "^0.64.0",
5555
"react": "16.11.0",
5656
"react-native": "0.62.2",
5757
"typescript": "^3.9.5"

0 commit comments

Comments
 (0)