Skip to content

Commit 9127fb5

Browse files
logandanielsfacebook-github-bot
authored andcommitted
Manual fixes for xplat/js/react-native-github
Summary: Need to add explicit type annotations in these areas to unblock types-first architecture for Flow. These are locations the codemod could not automatically handle. I'll call out areas I need a close eye on in the comments. Reviewed By: panagosg7 Differential Revision: D16659053 fbshipit-source-id: 167dd2abe093019b128676426374c1c62cf71e7f
1 parent 99487d6 commit 9127fb5

File tree

55 files changed

+270
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+270
-122
lines changed

Libraries/Animated/src/Animated.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,31 @@
1212

1313
import Platform from '../../Utilities/Platform';
1414

15-
const AnimatedImplementation = Platform.isTesting
16-
? require('./AnimatedMock')
17-
: require('./AnimatedImplementation');
15+
const AnimatedMock = require('./AnimatedMock');
16+
const AnimatedImplementation = require('./AnimatedImplementation');
17+
18+
const Animated = ((Platform.isTesting
19+
? AnimatedMock
20+
: AnimatedImplementation): typeof AnimatedMock);
1821

1922
module.exports = {
20-
get FlatList() {
23+
get FlatList(): any {
2124
return require('./components/AnimatedFlatList');
2225
},
23-
get Image() {
26+
get Image(): any {
2427
return require('./components/AnimatedImage');
2528
},
26-
get ScrollView() {
29+
get ScrollView(): any {
2730
return require('./components/AnimatedScrollView');
2831
},
29-
get SectionList() {
32+
get SectionList(): any {
3033
return require('./components/AnimatedSectionList');
3134
},
32-
get Text() {
35+
get Text(): any {
3336
return require('./components/AnimatedText');
3437
},
35-
get View() {
38+
get View(): any {
3639
return require('./components/AnimatedView');
3740
},
38-
...AnimatedImplementation,
41+
...Animated,
3942
};

Libraries/Animated/src/AnimatedMock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const stagger = function(
110110
return emptyAnimation;
111111
};
112112

113-
type LoopAnimationConfig = {iterations: number};
113+
type LoopAnimationConfig = {iterations: number, resetBeforeIteration?: boolean};
114114

115115
const loop = function(
116116
animation: CompositeAnimation,

Libraries/Animated/src/nodes/AnimatedInterpolation.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ function checkInfiniteRange(name: string, arr: Array<number>) {
307307

308308
class AnimatedInterpolation extends AnimatedWithChildren {
309309
// Export for testing.
310-
static __createInterpolation = createInterpolation;
310+
static __createInterpolation: (
311+
config: InterpolationConfigType,
312+
) => (input: number) => number | string = createInterpolation;
311313

312314
_parent: AnimatedNode;
313315
_config: InterpolationConfigType;
@@ -347,7 +349,7 @@ class AnimatedInterpolation extends AnimatedWithChildren {
347349
super.__detach();
348350
}
349351

350-
__transformDataType(range: Array<any>) {
352+
__transformDataType(range: Array<any>): Array<any> {
351353
return range.map(NativeAnimatedHelper.transformDataType);
352354
}
353355

Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
1616
import type {ViewProps} from '../View/ViewPropTypes';
1717

1818
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
19+
import {type NativeComponentType} from '../../Utilities/codegenNativeComponent';
1920

2021
type NativeProps = $ReadOnly<{|
2122
...ViewProps,
@@ -50,6 +51,6 @@ type NativeProps = $ReadOnly<{|
5051
size?: WithDefault<'small' | 'large', 'small'>,
5152
|}>;
5253

53-
export default codegenNativeComponent<NativeProps>('ActivityIndicatorView', {
54+
export default (codegenNativeComponent<NativeProps>('ActivityIndicatorView', {
5455
paperComponentName: 'RCTActivityIndicatorView',
55-
});
56+
}): NativeComponentType<NativeProps>);

Libraries/Components/Button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ type ButtonProps = $ReadOnly<{|
128128
*/
129129

130130
class Button extends React.Component<ButtonProps> {
131-
render() {
131+
render(): React.Node {
132132
const {
133133
accessibilityLabel,
134134
color,

Libraries/Components/MaskedView/RCTMaskedViewNativeComponent.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010

1111
import type {ViewProps} from '../View/ViewPropTypes';
1212
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
13+
import {type NativeComponentType} from '../../Utilities/codegenNativeComponent';
1314

1415
type NativeProps = $ReadOnly<{|
1516
...ViewProps,
1617
|}>;
1718

18-
export default codegenNativeComponent<NativeProps>('RCTMaskedView');
19+
export default (codegenNativeComponent<NativeProps>(
20+
'RCTMaskedView',
21+
): NativeComponentType<NativeProps>);

Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {ViewProps} from '../View/ViewPropTypes';
1515
import type {Float, WithDefault} from '../../Types/CodegenTypes';
1616

1717
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
18+
import {type NativeComponentType} from '../../Utilities/codegenNativeComponent';
1819

1920
type NativeProps = $ReadOnly<{|
2021
...ViewProps,
@@ -29,4 +30,6 @@ type NativeProps = $ReadOnly<{|
2930
testID?: WithDefault<string, ''>,
3031
|}>;
3132

32-
export default codegenNativeComponent<NativeProps>('AndroidProgressBar');
33+
export default (codegenNativeComponent<NativeProps>(
34+
'AndroidProgressBar',
35+
): NativeComponentType<NativeProps>);

Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
1616
import type {ViewProps} from '../View/ViewPropTypes';
1717

1818
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
19+
import {type NativeComponentType} from '../../Utilities/codegenNativeComponent';
1920

2021
type NativeProps = $ReadOnly<{|
2122
...ViewProps,
@@ -29,4 +30,6 @@ type NativeProps = $ReadOnly<{|
2930
trackImage?: ?ImageSource,
3031
|}>;
3132

32-
export default codegenNativeComponent<NativeProps>('RCTProgressView');
33+
export default (codegenNativeComponent<NativeProps>(
34+
'RCTProgressView',
35+
): NativeComponentType<NativeProps>);

Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
'use strict';
1212

1313
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
14+
import {type NativeComponentType} from '../../Utilities/codegenNativeComponent';
1415

1516
import type {
1617
DirectEventHandler,
@@ -64,4 +65,6 @@ type NativeProps = $ReadOnly<{|
6465
refreshing: boolean,
6566
|}>;
6667

67-
export default codegenNativeComponent<NativeProps>('AndroidSwipeRefreshLayout');
68+
export default (codegenNativeComponent<NativeProps>(
69+
'AndroidSwipeRefreshLayout',
70+
): NativeComponentType<NativeProps>);

Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
1515
import type {ViewProps} from '../View/ViewPropTypes';
1616

1717
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
18+
import {type NativeComponentType} from '../../Utilities/codegenNativeComponent';
1819

1920
type NativeProps = $ReadOnly<{|
2021
...ViewProps,
@@ -43,6 +44,6 @@ type NativeProps = $ReadOnly<{|
4344
refreshing: boolean,
4445
|}>;
4546

46-
export default codegenNativeComponent<NativeProps>('PullToRefreshView', {
47+
export default (codegenNativeComponent<NativeProps>('PullToRefreshView', {
4748
paperComponentName: 'RCTRefreshControl',
48-
});
49+
}): NativeComponentType<NativeProps>);

0 commit comments

Comments
 (0)