Skip to content

Commit

Permalink
chore: update flowtype (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
Naturalclar authored Nov 9, 2020
1 parent efdb632 commit ea97bf3
Show file tree
Hide file tree
Showing 6 changed files with 317 additions and 210 deletions.
7 changes: 1 addition & 6 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
Expand All @@ -56,7 +52,6 @@ untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
inexact-spread=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error
Expand All @@ -71,4 +66,4 @@ untyped-import
untyped-type-import

[version]
^0.113.0
^0.137.0
35 changes: 21 additions & 14 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* @flow
*/

import React, {useState, useEffect} from 'react';
import * as React from 'react';
import {useState, useEffect} from 'react';
import {
Alert,
StyleSheet,
Expand All @@ -16,20 +17,26 @@ import {
} from 'react-native';
import PushNotificationIOS from '../js';

class Button extends React.Component<$FlowFixMeProps> {
render() {
return (
<TouchableHighlight
underlayColor={'white'}
style={styles.button}
onPress={this.props.onPress}>
<Text style={styles.buttonLabel}>{this.props.label}</Text>
</TouchableHighlight>
);
}
}
type ButtonProps = {|
onPress: () => void | Promise<void>,
label: string,
|};

const Button: React.StatelessFunctionalComponent<ButtonProps> = ({
onPress,
label,
}) => {
return (
<TouchableHighlight
underlayColor={'white'}
style={styles.button}
onPress={onPress}>
<Text style={styles.buttonLabel}>{label}</Text>
</TouchableHighlight>
);
};

export const App = () => {
export const App = (): React.Node => {
const [permissions, setPermissions] = useState({});

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import {NativeEventEmitter, NativeModules} from 'react-native';
import invariant from 'invariant';
import {
import type {
NotificationAlert,
NotificationRequest,
NotificationCategory,
Expand All @@ -29,7 +29,7 @@ const NOTIF_REGISTER_EVENT = 'remoteNotificationsRegistered';
const NOTIF_REGISTRATION_ERROR_EVENT = 'remoteNotificationRegistrationError';
const DEVICE_LOCAL_NOTIF_EVENT = 'localNotificationReceived';

export {
export type {
NotificationAlert,
NotificationRequest,
NotificationCategory,
Expand Down
20 changes: 12 additions & 8 deletions js/types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export type NotificationRequest = {
/**
* @flow
*/

export type NotificationRequest = {|
/**
* identifier of the notification.
* Required in order to retrieve specific notification.
Expand Down Expand Up @@ -49,33 +53,33 @@ export type NotificationRequest = {
* Optional data to be added to the notification
*/
userInfo?: Object,
};
|};

/**
* Alert Object that can be included in the aps `alert` object
*/
export type NotificationAlert = {
export type NotificationAlert = {|
title?: string,
subtitle?: string,
body?: string,
};
|};

/**
* Notification Category that can include specific actions
*/
export type NotificationCategory = {
export type NotificationCategory = {|
/**
* Identifier of the notification category.
* Notification with this category will have the specified actions.
*/
id: string,
actions: NotificationAction[],
};
|};

/**
* Notification Action that can be added to specific categories
*/
export type NotificationAction = {
export type NotificationAction = {|
/**
* Identifier of Action.
* This value will be returned as actionIdentifier when notification is received.
Expand Down Expand Up @@ -109,4 +113,4 @@ export type NotificationAction = {
*/
placeholder?: string,
},
};
|};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.1.0",
"babel-plugin-module-resolver": "^3.1.3",
"eslint": "^6.8.0",
"flow-bin": "^0.113.0",
"eslint": "^7.13.0",
"flow-bin": "0.137.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "0.58.0",
"metro-react-native-babel-preset": "^0.64.0",
"react": "16.11.0",
"react-native": "0.62.2",
"typescript": "^3.9.5"
Expand Down
Loading

0 comments on commit ea97bf3

Please sign in to comment.