Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/react-native/Libraries/Animated/Animated.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import Platform from '../Utilities/Platform';
import AnimatedImplementation from './AnimatedImplementation';
import AnimatedMock from './AnimatedMock';

const Animated = ((Platform.isDisableAnimations
const Animated: typeof AnimatedImplementation = Platform.isDisableAnimations
? AnimatedMock
: AnimatedImplementation): typeof AnimatedImplementation);
: AnimatedImplementation;

export default {
get FlatList(): AnimatedFlatList {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const addPoolingTo = function <T>(
} {
// Casting as any so that flow ignores the actual implementation and trusts
// it to match the type we declared
const NewKlass = (CopyConstructor: any);
const NewKlass: any = CopyConstructor;
NewKlass.instancePool = [];
NewKlass.getPooled = pooler || DEFAULT_POOLER;
if (!NewKlass.poolSize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,12 @@ class TouchableHighlight extends React.Component<Props, State> {
}
}

const Touchable = (React.forwardRef((props, hostRef) => (
<TouchableHighlight {...props} hostRef={hostRef} />
)): React.AbstractComponent<
const Touchable: React.AbstractComponent<
$ReadOnly<$Diff<Props, {|hostRef: React.Ref<typeof View>|}>>,
React.ElementRef<typeof View>,
>);
> = React.forwardRef((props, hostRef) => (
<TouchableHighlight {...props} hostRef={hostRef} />
));

Touchable.displayName = 'TouchableHighlight';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,12 @@ class TouchableOpacity extends React.Component<Props, State> {
}
}

const Touchable = (React.forwardRef((props, ref) => (
const Touchable: React.AbstractComponent<
Props,
React.ElementRef<typeof Animated.View>,
> = React.forwardRef((props, ref) => (
<TouchableOpacity {...props} hostRef={ref} />
)): React.AbstractComponent<Props, React.ElementRef<typeof Animated.View>>);
));

Touchable.displayName = 'TouchableOpacity';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export default class MutationRecord {
_removedNodes: NodeList<ReadOnlyNode>;

constructor(nativeRecord: NativeMutationRecord) {
// $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type.
const target = (nativeRecord.target: ReactNativeElement);
// $FlowExpectedError[incompatible-type] the codegen doesn't support the actual type.
const target: ReactNativeElement = nativeRecord.target;
this._target = target;
// $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type.
const addedNodes = (nativeRecord.addedNodes: $ReadOnlyArray<ReadOnlyNode>);
// $FlowExpectedError[incompatible-type] the codegen doesn't support the actual type.
const addedNodes: $ReadOnlyArray<ReadOnlyNode> = nativeRecord.addedNodes;
this._addedNodes = createNodeList(addedNodes);
const removedNodes =
// $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type.
(nativeRecord.removedNodes: $ReadOnlyArray<ReadOnlyNode>);
const removedNodes: $ReadOnlyArray<ReadOnlyNode> =
// $FlowFixMe[incompatible-type]
nativeRecord.removedNodes;
this._removedNodes = createNodeList(removedNodes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = {
return;
}

let nativeViewTag = (instanceHandle.stateNode.canonical
.nativeTag: number);
let nativeViewTag: number =
instanceHandle.stateNode.canonical.nativeTag;

FabricUIManager.measure(
node,
Expand Down
5 changes: 2 additions & 3 deletions packages/react-native/Libraries/Text/TextAncestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ const React = require('react');
/**
* Whether the current element is the descendant of a <Text> element.
*/
const TextAncestorContext = (React.createContext(
false,
): React$Context<$FlowFixMe>);
const TextAncestorContext: React$Context<$FlowFixMe> =
React.createContext(false);
if (__DEV__) {
TextAncestorContext.displayName = 'TextAncestorContext';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function binaryToBase64(data: ArrayBuffer | $ArrayBufferView): string {
throw new Error('data must be ArrayBuffer or typed array');
}
// Already checked that `data` is `DataView` in `ArrayBuffer.isView(data)`
const {buffer, byteOffset, byteLength} = ((data: $FlowFixMe): DataView);
const {buffer, byteOffset, byteLength}: DataView = (data: $FlowFixMe);
return base64.fromByteArray(new Uint8Array(buffer, byteOffset, byteLength));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rn-tester/js/examples/Animated/EasingExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function EasingExample(props: Props): React.Node {
<SectionList
sections={easingSections}
renderItem={info => {
const item = (info.item: EasingListItem);
const item: EasingListItem = info.item;

return (
<EasingItem
Expand Down
6 changes: 3 additions & 3 deletions packages/rn-tester/js/examples/Modal/ModalExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
import ModalOnShow from './ModalOnShow';
import ModalPresentation from './ModalPresentation';

export const displayName = (undefined: ?string);
export const displayName: ?string = undefined;
export const framework = 'React';
export const title = 'Modal';
export const category = 'UI';
export const documentationURL = 'https://reactnative.dev/docs/modal';
export const description = 'Component for presenting modal views.';
export const examples = ([
export const examples: Array<RNTesterModuleExample> = [
ModalPresentation,
ModalOnShow,
]: Array<RNTesterModuleExample>);
];
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function VisualCompletionExampleScreen(props: {
style={styles.root}
ref={node => {
if (node != null) {
// $FlowExpectedError[incompatible-cast]
const element = (node: ReactNativeElement);
// $FlowExpectedError[incompatible-type]
const element: ReactNativeElement = node;
props.vcTracker.addMutationRoot(element);
}
}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ exports.documentationURL = 'https://reactnative.dev/docs/scrollview';
exports.category = 'Basic';
exports.description =
'Component that enables scrolling through child components';
const examples = ([
const examples: Array<RNTesterModuleExample> = [
{
name: 'scrollTo',
title: '<ScrollView>\n',
Expand Down Expand Up @@ -425,7 +425,7 @@ const examples = ([
return <AppendingList />;
},
},
]: Array<RNTesterModuleExample>);
];

if (Platform.OS === 'ios') {
examples.push({
Expand Down