Enable LTI in react-native

Summary: Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D41788271

fbshipit-source-id: 8e40dc3279ee0283b2845b9559a80862fdf59a17
This commit is contained in:
Sam Zhou
2022-12-06 19:34:14 -08:00
committed by Facebook GitHub Bot
parent 62a28e4bdb
commit ccefad049a
55 changed files with 110 additions and 61 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ suppress_type=$FlowFixMeState
suppress_type=$FlowFixMeEmpty
experimental.array_literal_providers=true
inference_mode=constrain_writes
inference_mode=experimental.lti
[lints]
sketchy-null-number=warn
+1 -1
View File
@@ -52,7 +52,7 @@ suppress_type=$FlowFixMeState
suppress_type=$FlowFixMeEmpty
experimental.array_literal_providers=true
inference_mode=constrain_writes
inference_mode=experimental.lti
[lints]
sketchy-null-number=warn
@@ -248,6 +248,7 @@ const API = {
}
// $FlowFixMe
API.queueOperation(
// $FlowFixMe[incompatible-call]
nativeOps.startAnimatingNode,
animationId,
nodeTag,
+1 -1
View File
@@ -105,7 +105,7 @@ export default function bezier(
// Precompute samples table
const sampleValues = float32ArraySupported
? new Float32Array(kSplineTableSize)
: new Array(kSplineTableSize);
: new Array<number>(kSplineTableSize);
if (mX1 !== mY1 || mX2 !== mY2) {
for (let i = 0; i < kSplineTableSize; ++i) {
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
@@ -67,12 +67,15 @@ const AnimatedScrollViewWithInvertedRefreshControl = React.forwardRef(
// $FlowFixMe[unclear-type] Same Flow type as `refreshControl` in ScrollView
refreshControl: React.Element<any>,
},
forwardedRef,
forwardedRef:
| {current: Instance | null, ...}
| ((Instance | null) => mixed),
) => {
// Split `props` into the animate-able props for the parent (RefreshControl)
// and child (ScrollView).
const {intermediatePropsForRefreshControl, intermediatePropsForScrollView} =
useMemo(() => {
// $FlowFixMe[underconstrained-implicit-instantiation]
const {outer, inner} = splitLayoutProps(flattenStyle(props.style));
return {
intermediatePropsForRefreshControl: {style: outer},
@@ -233,7 +233,8 @@ function createStringInterpolation(
isColor
? // $FlowIgnoreMe[incompatible-call]
output.components
: output.components.filter(c => typeof c === 'number'),
: // $FlowIgnoreMe[incompatible-call]
output.components.filter(c => typeof c === 'number'),
);
const interpolations = numericComponents[0].map((_, i) =>
createNumericInterpolation({
@@ -20,6 +20,7 @@ import AnimatedTransform from './AnimatedTransform';
import AnimatedWithChildren from './AnimatedWithChildren';
function createAnimatedStyle(inputStyle: any): Object {
// $FlowFixMe[underconstrained-implicit-instantiation]
const style = flattenStyle(inputStyle);
const animatedStyles: any = {};
for (const key in style) {
@@ -36,6 +37,7 @@ function createAnimatedStyle(inputStyle: any): Object {
}
function createStyleWithAnimatedTransform(inputStyle: any): Object {
// $FlowFixMe[underconstrained-implicit-instantiation]
let style = flattenStyle(inputStyle) || ({}: {[string]: any});
if (style.transform) {
+2 -1
View File
@@ -122,7 +122,7 @@ function validateBaseUrl(url: string) {
export class URL {
_url: string;
_searchParamsInstance = null;
_searchParamsInstance: ?URLSearchParams = null;
static createObjectURL(blob: Blob): string {
if (BLOB_URL_PREFIX === null) {
@@ -220,6 +220,7 @@ export class URL {
if (this._searchParamsInstance === null) {
return this._url;
}
// $FlowFixMe[incompatible-use]
const instanceString = this._searchParamsInstance.toString();
const separator = this._url.indexOf('?') > -1 ? '&' : '?';
return this._url + separator + instanceString;
+3 -2
View File
@@ -11,6 +11,7 @@
'use strict';
import type {TextStyleProp, ViewStyleProp} from '../StyleSheet/StyleSheet';
import type {PressEvent} from '../Types/CoreEventTypes';
import type {Button as ButtonType} from './Button.flow';
import type {
@@ -310,8 +311,8 @@ class Button extends React.Component<ButtonProps> {
accessibilityLanguage,
onAccessibilityAction,
} = this.props;
const buttonStyles = [styles.button];
const textStyles = [styles.text];
const buttonStyles: Array<ViewStyleProp> = [styles.button];
const textStyles: Array<TextStyleProp> = [styles.text];
if (color) {
if (Platform.OS === 'ios') {
textStyles.push({color: color});
@@ -753,7 +753,7 @@ class ScrollView extends React.Component<Props, State> {
_becameResponderWhileAnimating: boolean = false;
_preventNegativeScrollOffset: ?boolean = null;
_animated = null;
_animated: ?boolean = null;
_subscriptionKeyboardWillShow: ?EventSubscription = null;
_subscriptionKeyboardWillHide: ?EventSubscription = null;
@@ -1665,6 +1665,7 @@ class ScrollView extends React.Component<Props, State> {
this.props.contentContainerStyle,
];
if (__DEV__ && this.props.style !== undefined) {
// $FlowFixMe[underconstrained-implicit-instantiation]
const style = flattenStyle(this.props.style);
const childLayoutProps = ['alignItems', 'justifyContent'].filter(
prop => style && style[prop] !== undefined,
@@ -1838,6 +1839,7 @@ class ScrollView extends React.Component<Props, State> {
// AndroidSwipeRefreshLayout and use flex: 1 for the ScrollView.
// Note: we should split props.style on the inner and outer props
// however, the ScrollView still needs the baseStyle to be scrollable
// $FlowFixMe[underconstrained-implicit-instantiation]
const {outer, inner} = splitLayoutProps(flattenStyle(props.style));
return React.cloneElement(
refreshControl,
+1 -1
View File
@@ -157,7 +157,7 @@ const SwitchWithForwardedRef: React.AbstractComponent<
const ref = useMergeRefs(nativeSwitchRef, forwardedRef);
const [native, setNative] = React.useState({value: null});
const [native, setNative] = React.useState({value: (null: ?boolean)});
const handleChange = (event: SwitchChangeEvent) => {
onChange?.(event);
@@ -1418,6 +1418,7 @@ function InternalTextInput(props: Props): React.Node {
};
}
// $FlowFixMe[underconstrained-implicit-instantiation]
let style = flattenStyle(props.style);
if (Platform.OS === 'ios') {
@@ -1628,6 +1629,7 @@ const ExportedForwardRef: React.AbstractComponent<
},
forwardedRef: ReactRefSetter<TextInputInstance>,
) {
// $FlowFixMe[underconstrained-implicit-instantiation]
let style = flattenStyle(restProps.style);
if (style?.verticalAlign != null) {
@@ -240,7 +240,7 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
render(): React.Node {
const element = React.Children.only<$FlowFixMe>(this.props.children);
const children = [element.props.children];
const children: Array<React.Node> = [element.props.children];
if (__DEV__) {
if (element.type === View) {
children.push(
@@ -206,6 +206,7 @@ class TouchableOpacity extends React.Component<Props, State> {
}
_getChildStyleOpacityWithDefault(): number {
// $FlowFixMe[underconstrained-implicit-instantiation]
const opacity = flattenStyle(this.props.style)?.opacity;
return typeof opacity === 'number' ? opacity : 1;
}
@@ -301,7 +302,9 @@ class TouchableOpacity extends React.Component<Props, State> {
this.state.pressability.configure(this._createPressabilityConfig());
if (
this.props.disabled !== prevProps.disabled ||
// $FlowFixMe[underconstrained-implicit-instantiation]
flattenStyle(prevProps.style)?.opacity !==
// $FlowFixMe[underconstrained-implicit-instantiation]
flattenStyle(this.props.style)?.opacity
) {
this._opacityInactive(250);
@@ -122,7 +122,7 @@ class TouchableWithoutFeedback extends React.Component<Props, State> {
render(): React.Node {
const element = React.Children.only<$FlowFixMe>(this.props.children);
const children = [element.props.children];
const children: Array<React.Node> = [element.props.children];
const ariaLive = this.props['aria-live'];
if (__DEV__) {
+1
View File
@@ -98,6 +98,7 @@ const View: React.AbstractComponent<
};
}
// $FlowFixMe[underconstrained-implicit-instantiation]
let style = flattenStyle(otherProps.style);
const newPointerEvents = style?.pointerEvents || pointerEvents;
+1 -1
View File
@@ -48,7 +48,7 @@ function parseErrorStack(errorStack?: string): Array<StackFrame> {
? errorStack
: global.HermesInternal
? convertHermesStack(parseHermesStack(errorStack))
: stacktraceParser.parse(errorStack).map(frame => ({
: stacktraceParser.parse(errorStack).map((frame): StackFrame => ({
...frame,
column: frame.column != null ? frame.column - 1 : null,
}));
+1
View File
@@ -40,6 +40,7 @@ function setImmediate(callback: Function, ...args: any): number {
clearedImmediates.delete(id);
}
// $FlowFixMe[incompatible-call]
global.queueMicrotask(() => {
if (!clearedImmediates.has(id)) {
callback.apply(undefined, args);
+1 -1
View File
@@ -15,7 +15,7 @@
* You can use this module directly, or just require InitializeCore.
*/
if (!global.alert) {
global.alert = function (text) {
global.alert = function (text: string) {
// Require Alert on demand. Requiring it too early can lead to issues
// with things like Platform not being fully initialized.
require('../Alert/Alert').alert('Alert', '' + text);
+1 -1
View File
@@ -56,7 +56,7 @@ if (__DEV__) {
'debug',
].forEach(level => {
const originalFunction = console[level];
console[level] = function (...args) {
console[level] = function (...args: $ReadOnlyArray<mixed>) {
HMRClient.log(level, args);
originalFunction.apply(console, args);
};
+3
View File
@@ -152,10 +152,13 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => {
let style;
let sources;
if (Array.isArray(source)) {
// $FlowFixMe[underconstrained-implicit-instantiation]
style = flattenStyle([styles.base, props.style]);
sources = source;
} else {
// $FlowFixMe[incompatible-type]
const {width = props.width, height = props.height, uri} = source;
// $FlowFixMe[underconstrained-implicit-instantiation]
style = flattenStyle([{width, height}, styles.base, props.style]);
sources = [source];
if (uri === '') {
+3
View File
@@ -114,10 +114,13 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => {
let sources;
let style: ImageStyleProp;
if (Array.isArray(source)) {
// $FlowFixMe[underconstrained-implicit-instantiation]
style = flattenStyle([styles.base, props.style]) || {};
sources = source;
} else {
// $FlowFixMe[incompatible-type]
const {width = props.width, height = props.height, uri} = source;
// $FlowFixMe[underconstrained-implicit-instantiation]
style = flattenStyle([{width, height}, styles.base, props.style]) || {};
sources = [source];
+1
View File
@@ -76,6 +76,7 @@ class ImageBackground extends React.Component<ImageBackgroundProps> {
...props
} = this.props;
// $FlowFixMe[underconstrained-implicit-instantiation]
const flattenedStyle = flattenStyle(style);
return (
<View
+1
View File
@@ -20,6 +20,7 @@ const React = require('react');
class ElementBox extends React.Component<$FlowFixMeProps> {
render(): React.Node {
// $FlowFixMe[underconstrained-implicit-instantiation]
const style = flattenStyle(this.props.style) || {};
let margin = resolveBoxStyle('margin', style);
let padding = resolveBoxStyle('padding', style);
+1
View File
@@ -795,6 +795,7 @@ export default class VirtualizedList extends StateSafePureComponent<
render(): React.Node {
if (__DEV__) {
// $FlowFixMe[underconstrained-implicit-instantiation]
const flatStyles = flattenStyle(this.props.contentContainerStyle);
if (flatStyles != null && flatStyles.flexWrap === 'wrap') {
console.warn(
@@ -203,9 +203,13 @@ export default class CellRenderer<ItemT> extends React.Component<
: this._onLayout;
// NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
// called explicitly by `ScrollViewStickyHeader`.
const itemSeparator = React.isValidElement(ItemSeparatorComponent)
? ItemSeparatorComponent
: ItemSeparatorComponent && (
const itemSeparator: React.Node = React.isValidElement(
ItemSeparatorComponent,
)
? // $FlowFixMe[incompatible-type]
ItemSeparatorComponent
: // $FlowFixMe[incompatible-type]
ItemSeparatorComponent && (
<ItemSeparatorComponent {...this.state.separatorProps} />
);
const cellStyle = inversionStyle
@@ -530,6 +530,7 @@ function ItemWithSeparator(props: ItemWithSeparatorProps): React.Node {
React.useEffect(() => {
setSelfHighlightCallback(cellKey, setSeparatorHighlighted);
// $FlowFixMe[incompatible-call]
setSelfUpdatePropsCallback(cellKey, setSeparatorProps);
return () => {
@@ -93,6 +93,7 @@ module.exports = {
<FlatList
// $FlowExpectedError - bad title type number, should be string
renderItem={(info: {item: {title: number}}) => <span />}
// $FlowExpectedError - bad title type number, should be string
data={data}
/>,
// EverythingIsFine
@@ -20,6 +20,7 @@ describe('VirtualizedSectionList', () => {
const component = ReactTestRenderer.create(
<VirtualizedSectionList
sections={[
// $FlowFixMe[incompatible-type]
{title: 's1', data: [{key: 'i1'}, {key: 'i2'}, {key: 'i3'}]},
]}
renderItem={({item}) => <item value={item.key} />}
@@ -60,6 +61,7 @@ describe('VirtualizedSectionList', () => {
it('renders list with empty component', () => {
const component = ReactTestRenderer.create(
<VirtualizedSectionList
// $FlowFixMe[incompatible-type]
sections={[{title: 's1', data: [{key: 'hello'}]}]}
ListEmptyComponent={() => <empty />}
getItem={(data, key) => data[key]}
@@ -78,9 +80,10 @@ describe('VirtualizedSectionList', () => {
ListFooterComponent={() => <footer />}
ListHeaderComponent={() => <header />}
sections={[
// $FlowFixMe[incompatible-type]
{
title: 's1',
data: new Array(5).fill().map((_, ii) => ({id: String(ii)})),
data: new Array<void>(5).fill().map((_, ii) => ({id: String(ii)})),
},
]}
getItem={(data, key) => data[key]}
@@ -108,6 +111,7 @@ describe('VirtualizedSectionList', () => {
<VirtualizedSectionList
ItemSeparatorComponent={props => <separator {...props} />}
sections={[
// $FlowFixMe[incompatible-type]
{title: 's0', data: [{key: 'i0'}, {key: 'i1'}, {key: 'i2'}]},
]}
renderItem={info => {
@@ -138,10 +142,12 @@ describe('VirtualizedSectionList', () => {
it('handles nested lists', () => {
const component = ReactTestRenderer.create(
<VirtualizedSectionList
// $FlowFixMe[incompatible-type]
sections={[{title: 'outer', data: [{key: 'outer0'}, {key: 'outer1'}]}]}
renderItem={outerInfo => (
<VirtualizedSectionList
sections={[
// $FlowFixMe[incompatible-type]
{
title: 'inner',
data: [
@@ -174,7 +180,9 @@ describe('VirtualizedSectionList', () => {
const component = ReactTestRenderer.create(
<VirtualizedSectionList
sections={[
// $FlowFixMe[incompatible-type]
{title: 's1', data: [{key: 'i1.1'}, {key: 'i1.2'}, {key: 'i1.3'}]},
// $FlowFixMe[incompatible-type]
{title: 's2', data: [{key: 'i2.1'}, {key: 'i2.2'}, {key: 'i2.3'}]},
]}
renderItem={({item}) => <item value={item.key} />}
@@ -41,6 +41,7 @@ function LogBoxInspectorSourceMapStatus(props: Props): React.Node {
useNativeDriver: true,
}),
);
// $FlowFixMe[incompatible-call]
setState({
animation,
rotate: animated.interpolate({
@@ -85,6 +85,7 @@ describe('LogBoxInspectorStackFrame', () => {
expect(
getCollapseMessage(
createCollapsedFrames(
// $FlowFixMe[incompatible-call]
[stackOne, stackTwo, stackThree].filter(i => i != null),
),
collapsed,
+1
View File
@@ -32,6 +32,7 @@ export function createViewConfig(
PlatformBaseViewConfig.directEventTypes,
partialViewConfig.directEventTypes,
),
// $FlowFixMe[incompatible-return]
validAttributes: composeIndexers(
// $FlowFixMe[incompatible-call] `style` property confuses Flow.
PlatformBaseViewConfig.validAttributes,
+2 -2
View File
@@ -559,8 +559,8 @@ export default class Pressability {
ReactNativeFeatureFlags.shouldPressibilityUseW3CPointerEventsForHover()
) {
const hoverPointerEvents = {
onPointerEnter: undefined,
onPointerLeave: undefined,
onPointerEnter: (undefined: void | (PointerEvent => void)),
onPointerLeave: (undefined: void | (PointerEvent => void)),
};
const {onHoverIn, onHoverOut} = this._config;
if (onHoverIn != null) {
@@ -187,7 +187,7 @@ const createMockPressEvent = (
}
const nativeEvent = {
changedTouches: [],
changedTouches: ([]: Array<PressEvent['nativeEvent']>),
force: 1,
identifier: 42,
locationX: pageX,
@@ -196,7 +196,7 @@ const createMockPressEvent = (
pageY,
target: 42,
timestamp: 1075881600000,
touches: [],
touches: ([]: Array<PressEvent['nativeEvent']>),
};
nativeEvent.changedTouches.push(nativeEvent);
@@ -57,6 +57,7 @@ module.exports = {
return require('../Utilities/deepFreezeAndThrowOnMutationInDev');
},
get flattenStyle(): flattenStyle<DangerouslyImpreciseStyleProp> {
// $FlowFixMe[underconstrained-implicit-instantiation]
return require('../StyleSheet/flattenStyle');
},
get ReactFiberErrorDialog(): ReactFiberErrorDialog {
@@ -6,7 +6,7 @@
*
* @noformat
* @flow strict-local
* @generated SignedSource<<bda490a01513d4526005c1e029d5ce93>>
* @generated SignedSource<<7b69bfde64e35b7f706c2f6b9ef91e7c>>
*
* This file was sync'd from the facebook/react repository.
*/
@@ -37,8 +37,8 @@ const customDirectEventTypes: {
exports.customBubblingEventTypes = customBubblingEventTypes;
exports.customDirectEventTypes = customDirectEventTypes;
const viewConfigCallbacks = new Map();
const viewConfigs = new Map();
const viewConfigCallbacks = new Map<string, ?() => ViewConfig>();
const viewConfigs = new Map<string, ViewConfig>();
function processEventTypes(viewConfig: ViewConfig): void {
const {bubblingEventTypes, directEventTypes} = viewConfig;
+2
View File
@@ -15,6 +15,7 @@ import type {____FlattenStyleProp_Internal} from './StyleSheetTypes';
function flattenStyle<+TStyleProp: DangerouslyImpreciseStyleProp>(
style: ?TStyleProp,
// $FlowFixMe[underconstrained-implicit-instantiation]
): ?____FlattenStyleProp_Internal<TStyleProp> {
if (style === null || typeof style !== 'object') {
return undefined;
@@ -26,6 +27,7 @@ function flattenStyle<+TStyleProp: DangerouslyImpreciseStyleProp>(
const result: {[string]: $FlowFixMe} = {};
for (let i = 0, styleLength = style.length; i < styleLength; ++i) {
// $FlowFixMe[underconstrained-implicit-instantiation]
const computedStyle = flattenStyle(style[i]);
if (computedStyle) {
for (const key in computedStyle) {
+1
View File
@@ -207,6 +207,7 @@ const Text: React.AbstractComponent<
default: accessible,
});
// $FlowFixMe[underconstrained-implicit-instantiation]
style = flattenStyle(style);
if (typeof style?.fontWeight === 'number') {
+3 -3
View File
@@ -25,7 +25,7 @@ let hmrClient = null;
let hmrUnavailableReason: string | null = null;
let currentCompileErrorMessage: string | null = null;
let didConnect: boolean = false;
let pendingLogs: Array<[LogLevel, Array<mixed>]> = [];
let pendingLogs: Array<[LogLevel, $ReadOnlyArray<mixed>]> = [];
type LogLevel =
| 'trace'
@@ -42,7 +42,7 @@ export type HMRClientNativeInterface = {|
enable(): void,
disable(): void,
registerBundle(requestUrl: string): void,
log(level: LogLevel, data: Array<mixed>): void,
log(level: LogLevel, data: $ReadOnlyArray<mixed>): void,
setup(
platform: string,
bundleEntry: string,
@@ -105,7 +105,7 @@ const HMRClient: HMRClientNativeInterface = {
registerBundleEntryPoints(hmrClient);
},
log(level: LogLevel, data: Array<mixed>) {
log(level: LogLevel, data: $ReadOnlyArray<mixed>) {
if (!hmrClient) {
// Catch a reasonable number of early logs
// in case hmrClient gets initialized later.
@@ -19,6 +19,7 @@ function codegenNativeCommands<T: interface {}>(options: Options<$Keys<T>>): T {
options.supportedCommands.forEach(command => {
commandObj[command] = (ref, ...args) => {
// $FlowFixMe[incompatible-call]
dispatchCommand(ref, command, args);
};
});
@@ -66,7 +66,11 @@ describe('wrapNullable', () => {
describe('unwrapNullable', () => {
describe('when type annotation is nullable', () => {
it('returns original type annotation', () => {
const result = unwrapNullable({
// $FlowFixMe[incompatible-call]
const result = unwrapNullable<{
type: 'NullableTypeAnnotation',
typeAnnotation: {type: 'BooleanTypeAnnotation'},
}>({
type: 'NullableTypeAnnotation',
typeAnnotation: {
type: 'BooleanTypeAnnotation',
@@ -84,7 +88,7 @@ describe('unwrapNullable', () => {
});
describe('when type annotation is not nullable', () => {
it('returns original type annotation', () => {
const result = unwrapNullable({
const result = unwrapNullable<{type: 'BooleanTypeAnnotation'}>({
type: 'BooleanTypeAnnotation',
});
const expected = [
@@ -324,12 +324,12 @@ describe('buildSchemaFromConfigType', () => {
};
const wrapComponentSchemaMock = jest.fn();
const buildComponentSchemaMock = jest.fn(() => componentSchemaMock);
const buildComponentSchemaMock = jest.fn(_ => componentSchemaMock);
const wrapModuleSchemaMock = jest.spyOn(
require('../parsers-commons'),
'wrapModuleSchema',
);
const buildModuleSchemaMock = jest.fn(() => moduleSchemaMock);
const buildModuleSchemaMock = jest.fn((_0, _1, _2) => moduleSchemaMock);
const buildSchemaFromConfigTypeHelper = (
configType: 'module' | 'component' | 'none',
@@ -196,7 +196,7 @@ function flattenProperties(
);
}
})
.reduce((acc, item) => {
.reduce((acc: Array<PropAST>, item) => {
if (Array.isArray(item)) {
item.forEach(prop => {
verifyPropNotAlreadyDefined(acc, prop);
@@ -360,7 +360,7 @@ function buildModuleSchema(
return $moduleName;
});
const moduleNames = moduleName == null ? [] : [moduleName];
const moduleNames: Array<string> = moduleName == null ? [] : [moduleName];
// Some module names use platform suffix to indicate platform-exclusive modules.
// Eventually this should be made explicit in the Flow type itself.
@@ -498,9 +498,9 @@ function flattenProperties(
}
})
.filter(Boolean)
.reduce((acc, item) => {
.reduce((acc: Array<PropAST>, item) => {
if (Array.isArray(item)) {
item.forEach(prop => {
item.forEach((prop: PropAST) => {
verifyPropNotAlreadyDefined(acc, prop);
});
return acc.concat(item);
@@ -107,7 +107,11 @@ function findEventArgumentsAndType(
types: TypeDeclarationMap,
bubblingType: void | 'direct' | 'bubble',
paperName: ?$FlowFixMe,
) {
): {
argumentProps: ?$ReadOnlyArray<$FlowFixMe>,
paperTopLevelNameDeprecated: ?$FlowFixMe,
bubblingType: ?'direct' | 'bubble',
} {
if (typeAnnotation.type === 'TSInterfaceDeclaration') {
return {
argumentProps: flattenProperties([typeAnnotation], types),
@@ -368,7 +368,7 @@ function buildModuleSchema(
return $moduleName;
});
const moduleNames = moduleName == null ? [] : [moduleName];
const moduleNames: Array<string> = moduleName == null ? [] : [moduleName];
// Some module names use platform suffix to indicate platform-exclusive modules.
// Eventually this should be made explicit in the Flow type itself.
@@ -125,6 +125,7 @@ function AnimatedTransformStyleExample(): React.Node {
<AnimatedView
key={`animated-view-use-${useNativeDriver ? 'native' : 'js'}-driver`}
useNativeDriver={useNativeDriver}
// $FlowFixMe[incompatible-call]
properties={Object.keys(properties).filter(
property =>
properties[property].selected &&
@@ -11,11 +11,16 @@
import * as React from 'react';
import {useState, useEffect} from 'react';
import {Appearance, Text, useColorScheme, View} from 'react-native';
import type {AppearancePreferences} from 'react-native/Libraries/Utilities/NativeAppearance';
import type {
AppearancePreferences,
ColorSchemeName,
} from 'react-native/Libraries/Utilities/NativeAppearance';
import {RNTesterThemeContext, themes} from '../../components/RNTesterTheme';
function ColorSchemeSubscription() {
const [colorScheme, setScheme] = useState(Appearance.getColorScheme());
const [colorScheme, setScheme] = useState<?ColorSchemeName | string>(
Appearance.getColorScheme(),
);
useEffect(() => {
const subscription = Appearance.addChangeListener(
@@ -64,7 +64,7 @@ export default function EventfulView(props: {|
onCancelCapture,
...restProps
} = props;
const [tag, setTag] = React.useState('');
const [tag, setTag] = React.useState<?string>('');
const eventLog =
(eventName: string, handler: ?(e: PointerEvent) => void) =>
@@ -255,7 +255,7 @@ class LayoutUpdateExample extends React.Component<
height: 100,
};
timeout = null;
timeout: TimeoutID | null = null;
componentWillUnmount() {
this._clearTimeout();
@@ -181,6 +181,7 @@ export function SectionList_scrollable(Props: {
let startIndex = 0;
const endIndex = filteredData.length - 1;
for (let ii = 10; ii <= endIndex + 10; ii += 10) {
// $FlowFixMe[incompatible-call]
filteredSectionData.push({
key: `${filteredData[startIndex].key} - ${
filteredData[Math.min(ii - 1, endIndex)].key
@@ -542,7 +542,7 @@ const TouchableTouchSoundDisabled = () => {
function TouchableOnFocus<T: React.AbstractComponent<any, any>>() {
const ref = useRef<?React.ElementRef<T> | {focus: Function}>(null);
const [isFocused, setIsFocused] = useState(false);
const [isFocused, setIsFocused] = useState<string | boolean>(false);
const [focusStatus, setFocusStatus] = useState(
'This touchable is not focused.',
);
@@ -161,7 +161,7 @@ class NativeCxxModuleExampleExample extends React.Component<{||}, State> {
<FlatList
data={Object.keys(this._tests)}
keyExtractor={item => item}
renderItem={({item}) => (
renderItem={({item}: {item: Examples, ...}) => (
<View style={styles.item}>
<TouchableOpacity
style={[styles.column, styles.button]}
@@ -115,22 +115,7 @@ class SampleTurboModuleExample extends React.Component<{||}, State> {
}));
}
_renderResult(
name:
| 'callback'
| 'getArray'
| 'getBool'
| 'getConstants'
| 'getNumber'
| 'getObject'
| 'getRootTag'
| 'getString'
| 'getUnsafeObject'
| 'getValue'
| 'promise'
| 'rejectPromise'
| 'voidFunc',
): React.Node {
_renderResult(name: string): React.Node {
const result = this.state.testResults[name] || {};
return (
<View style={styles.result}>