Skip to content

Commit 16c10de

Browse files
authored
chore: update flowtype (#50)
1 parent baae775 commit 16c10de

File tree

10 files changed

+129
-221
lines changed

10 files changed

+129
-221
lines changed

.flowconfig

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,61 @@
22
; We fork some components by platform
33
.*/*[.]android.js
44

5+
; Ignore templates for 'react-native init'
6+
<PROJECT_ROOT>/template/.*
7+
8+
; Ignore the Dangerfile
9+
<PROJECT_ROOT>/bots/dangerfile.js
10+
511
; Ignore "BUCK" generated dirs
612
<PROJECT_ROOT>/\.buckd/
713

8-
; Ignore polyfills
9-
node_modules/react-native/Libraries/polyfills/.*
10-
1114
; These should not be required directly
1215
; require from fbjs/lib instead: require('fbjs/lib/warning')
13-
node_modules/warning/.*
16+
.*/node_modules/warning/.*
1417

1518
; Flow doesn't support platforms
1619
.*/Libraries/Utilities/LoadingView.js
1720

18-
; Ignore example folder
19-
.*/example/.*
20-
21-
2221
[untyped]
2322
.*/node_modules/@react-native-community/cli/.*/.*
2423

2524
[include]
2625

26+
[declarations]
27+
.*/node_modules/.*
28+
2729
[libs]
28-
node_modules/react-native/Libraries/react-native/react-native-interface.js
29-
node_modules/react-native/flow/
30+
interface.js
31+
flow/
3032

3133
[options]
3234
emoji=true
3335

3436
esproposal.optional_chaining=enable
3537
esproposal.nullish_coalescing=enable
3638

39+
exact_by_default=true
40+
3741
module.file_ext=.js
3842
module.file_ext=.json
3943
module.file_ext=.ios.js
40-
module.file_ext=.android.js
4144

4245
munge_underscores=true
4346

44-
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
45-
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
46-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
47+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/index.js'
48+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/\1'
49+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/Libraries/Image/RelativeImageStub'
4750

4851
suppress_type=$FlowIssue
4952
suppress_type=$FlowFixMe
5053
suppress_type=$FlowFixMeProps
5154
suppress_type=$FlowFixMeState
55+
suppress_type=$FlowFixMeEmpty
5256

53-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
54-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
55-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
57+
experimental.well_formed_exports=true
58+
experimental.types_first=true
59+
experimental.abstract_locations=true
5660

5761
[lints]
5862
sketchy-null-number=warn
@@ -62,10 +66,10 @@ untyped-type-import=warn
6266
nonstrict-import=warn
6367
deprecated-type=warn
6468
unsafe-getters-setters=warn
65-
inexact-spread=warn
6669
unnecessary-invariant=warn
6770
signature-verification-failure=warn
6871
deprecated-utility=error
72+
unsafe-addition=error
6973

7074
[strict]
7175
deprecated-type
@@ -77,4 +81,4 @@ untyped-import
7781
untyped-type-import
7882

7983
[version]
80-
^0.105.0
84+
^0.127.0

.vscode/settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"java.configuration.updateBuildConfiguration": "interactive"
3-
}
2+
"java.configuration.updateBuildConfiguration": "interactive",
3+
"flow.useNPMPackagedFlow": true,
4+
"javascript.validate.enable": false
5+
}

example/.gitignore

Lines changed: 0 additions & 56 deletions
This file was deleted.

example/App.js

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
'use strict';
1111

12-
import {ProgressBar} from '@react-native-community/progress-bar-android';
13-
import React from 'react';
12+
import * as React from 'react';
13+
import {ProgressBar} from '../js';
1414
import createReactClass from 'create-react-class';
1515
import RNTesterBlock from './RNTesterBlock';
1616
import RNTesterPage from './RNTesterPage';
@@ -39,39 +39,30 @@ const MovingBar = createReactClass({
3939
},
4040
});
4141

42-
export default class ProgressBarAndroidExample extends React.Component<{}> {
43-
static title = '<ProgressBarAndroid>';
44-
static description = 'Horizontal bar to show the progress of some operation.';
42+
const App: React.ComponentType<{}> = () => {
43+
return (
44+
<RNTesterPage title="ProgressBar Examples">
45+
<RNTesterBlock title="Horizontal Indeterminate ProgressBar">
46+
{/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
47+
* found when making Flow check .android.js files. */}
48+
<ProgressBar styleAttr="Horizontal" />
49+
</RNTesterBlock>
4550

46-
render() {
47-
return (
48-
<RNTesterPage title="ProgressBar Examples">
49-
<RNTesterBlock title="Horizontal Indeterminate ProgressBar">
50-
{/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
51-
* found when making Flow check .android.js files. */}
52-
<ProgressBar styleAttr="Horizontal" />
53-
</RNTesterBlock>
51+
<RNTesterBlock title="Horizontal ProgressBar">
52+
<MovingBar styleAttr="Horizontal" indeterminate={false} />
53+
</RNTesterBlock>
5454

55-
<RNTesterBlock title="Horizontal ProgressBar">
56-
<MovingBar styleAttr="Horizontal" indeterminate={false} />
57-
</RNTesterBlock>
55+
<RNTesterBlock title="Horizontal Black Indeterminate ProgressBar">
56+
{/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
57+
* found when making Flow check .android.js files. */}
58+
<ProgressBar styleAttr="Horizontal" color="black" />
59+
</RNTesterBlock>
5860

59-
<RNTesterBlock title="Horizontal Black Indeterminate ProgressBar">
60-
{/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
61-
* found when making Flow check .android.js files. */}
62-
<ProgressBar styleAttr="Horizontal" color="black" />
63-
</RNTesterBlock>
61+
<RNTesterBlock title="Horizontal Blue ProgressBar">
62+
<MovingBar styleAttr="Horizontal" indeterminate={false} color="blue" />
63+
</RNTesterBlock>
64+
</RNTesterPage>
65+
);
66+
};
6467

65-
<RNTesterBlock title="Horizontal Blue ProgressBar">
66-
<MovingBar
67-
styleAttr="Horizontal"
68-
indeterminate={false}
69-
color="blue"
70-
/>
71-
</RNTesterBlock>
72-
</RNTesterPage>
73-
);
74-
}
75-
}
76-
77-
module.exports = ProgressBarAndroidExample;
68+
export default App;

example/RNTesterBlock.js

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,33 @@
99

1010
'use strict';
1111

12-
import React from 'react';
13-
import PropTypes from 'prop-types';
12+
import * as React from 'react';
1413
import {StyleSheet, Text, View} from 'react-native';
1514

16-
class RNTesterBlock extends React.Component<
17-
{
18-
title?: string,
19-
description?: string,
20-
},
21-
$FlowFixMeState,
22-
> {
23-
static propTypes = {
24-
title: PropTypes.string,
25-
description: PropTypes.string,
26-
};
27-
28-
state = {description: (null: ?string)};
29-
30-
render() {
31-
var description;
32-
if (this.props.description) {
33-
description = (
34-
<Text style={styles.descriptionText}>{this.props.description}</Text>
35-
);
36-
}
37-
38-
return (
39-
<View style={styles.container}>
40-
<View style={styles.titleContainer}>
41-
<Text style={styles.titleText}>{this.props.title}</Text>
42-
{description}
43-
</View>
44-
<View style={styles.children}>
45-
{
46-
// $FlowFixMe found when converting React.createClass to ES6
47-
this.props.children
48-
}
49-
</View>
15+
type Props = $ReadOnly<{
16+
title?: string,
17+
description?: string,
18+
children: React.Node,
19+
}>;
20+
const RNTesterBlock: React.ComponentType<Props> = ({
21+
title,
22+
description,
23+
children,
24+
}) => {
25+
return (
26+
<View style={styles.container}>
27+
<View style={styles.titleContainer}>
28+
<Text style={styles.titleText}>{title}</Text>
29+
{description ? (
30+
<Text style={styles.descriptionText}>{description}</Text>
31+
) : null}
5032
</View>
51-
);
52-
}
53-
}
33+
<View style={styles.children}>{children}</View>
34+
</View>
35+
);
36+
};
5437

55-
var styles = StyleSheet.create({
38+
const styles = StyleSheet.create({
5639
container: {
5740
borderRadius: 3,
5841
borderWidth: 0.5,
@@ -78,16 +61,6 @@ var styles = StyleSheet.create({
7861
descriptionText: {
7962
fontSize: 14,
8063
},
81-
disclosure: {
82-
position: 'absolute',
83-
top: 0,
84-
right: 0,
85-
padding: 10,
86-
},
87-
disclosureIcon: {
88-
width: 12,
89-
height: 8,
90-
},
9164
children: {
9265
margin: 10,
9366
},

0 commit comments

Comments
 (0)