mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Replace Object/Function annotations with any (#59094)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/59094 With `experimental.function_and_object_type_is_no_longer_any`, Flow resolves `Object` and `Function` to the builtin class types instead of `any`. Changelog: [Internal] Reviewed By: panagosg7 Differential Revision: D125312021 fbshipit-source-id: 1646441aa3c2728313cf56b347d04e62d69712e4
This commit is contained in:
1 parent
43c9b88d5c
commit
80ca42ea96
29 files changed
+40
-41
No files matched your search
@@ -22,7 +22,7 @@ import type {TypeDeclarationMap} from '../../utils';
|
||||
const {getValueFromTypes} = require('../utils.js');
|
||||
|
||||
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
||||
type EventTypeAST = Object;
|
||||
type EventTypeAST = any;
|
||||
|
||||
function buildCommandSchema(
|
||||
property: EventTypeAST,
|
||||
|
||||
@@ -266,11 +266,11 @@ function buildEventSchema(
|
||||
}
|
||||
|
||||
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
||||
type EventTypeAST = Object;
|
||||
type EventTypeAST = any;
|
||||
|
||||
type TypeMap = {
|
||||
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
||||
[string]: Object,
|
||||
[string]: any,
|
||||
...
|
||||
};
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ export type CommandOptions = Readonly<{
|
||||
}>;
|
||||
|
||||
// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser
|
||||
type OptionsAST = Object;
|
||||
type OptionsAST = any;
|
||||
|
||||
type ExtendedPropResult = {
|
||||
type: 'ReactNativeBuiltInType',
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ const {parseTopLevelType} = require('../parseTopLevelType');
|
||||
const {getPrimitiveTypeAnnotation} = require('./componentsUtils');
|
||||
|
||||
// $FlowFixMe[unclear-type] there's no flowtype for ASTs
|
||||
type EventTypeAST = Object;
|
||||
type EventTypeAST = any;
|
||||
|
||||
function buildCommandSchemaInternal(
|
||||
name: string,
|
||||
|
||||
@@ -238,7 +238,7 @@ function findEventArgumentsAndType(
|
||||
}
|
||||
|
||||
// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser
|
||||
type EventTypeAST = Object;
|
||||
type EventTypeAST = any;
|
||||
|
||||
function buildEventSchema(
|
||||
types: TypeDeclarationMap,
|
||||
|
||||
@@ -24,7 +24,7 @@ function isEvent(typeAnnotation: $FlowFixMe, parser: Parser): boolean {
|
||||
}
|
||||
|
||||
// $FlowFixMe[unclear-type] TODO(T108222691): Use flow-types for @babel/parser
|
||||
type PropsAST = Object;
|
||||
type PropsAST = any;
|
||||
|
||||
function categorizeProps(
|
||||
typeDefinition: ReadonlyArray<PropsAST>,
|
||||
|
||||
@@ -156,7 +156,7 @@ function validateMapping(argMapping: ReadonlyArray<?Mapping>, args: any) {
|
||||
export class AnimatedEvent {
|
||||
_argMapping: ReadonlyArray<?Mapping>;
|
||||
// $FlowFixMe[unclear-type]
|
||||
_listeners: Array<Function> = [];
|
||||
_listeners: Array<any> = [];
|
||||
_attachedEvent: ?{detach: () => void, ...};
|
||||
__isNative: boolean;
|
||||
__platformConfig: ?PlatformConfig;
|
||||
|
||||
@@ -128,9 +128,9 @@ const _combineCallbacks = function (
|
||||
const maybeVectorAnim = function (
|
||||
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
|
||||
// $FlowFixMe[unclear-type]
|
||||
config: Object,
|
||||
config: any,
|
||||
// $FlowFixMe[unclear-type]
|
||||
anim: (value: AnimatedValue, config: Object) => CompositeAnimation,
|
||||
anim: (value: AnimatedValue, config: any) => CompositeAnimation,
|
||||
): ?CompositeAnimation {
|
||||
if (value instanceof AnimatedValueXY) {
|
||||
const configX = {...config};
|
||||
|
||||
@@ -228,7 +228,7 @@ export default class AnimatedNode {
|
||||
}
|
||||
|
||||
// $FlowFixMe[unclear-type]
|
||||
__getNativeConfig(): Object {
|
||||
__getNativeConfig(): any {
|
||||
throw new Error(
|
||||
'This JS animated node type cannot be used as native animated node',
|
||||
);
|
||||
|
||||
@@ -120,7 +120,7 @@ export default class AnimatedProps extends AnimatedNode {
|
||||
}
|
||||
|
||||
// $FlowFixMe[unclear-type]
|
||||
__getValue(): Object {
|
||||
__getValue(): any {
|
||||
const props: {[string]: unknown} = {};
|
||||
|
||||
const keys = Object.keys(this._props);
|
||||
@@ -146,7 +146,7 @@ export default class AnimatedProps extends AnimatedNode {
|
||||
* created by this `AnimatedProps` instance.
|
||||
*/
|
||||
// $FlowFixMe[unclear-type]
|
||||
__getValueWithStaticProps(staticProps: Object): Object {
|
||||
__getValueWithStaticProps(staticProps: any): any {
|
||||
const props: {[string]: unknown} = {...staticProps};
|
||||
|
||||
const keys = Object.keys(staticProps);
|
||||
|
||||
@@ -96,7 +96,7 @@ export default class AnimatedTransform extends AnimatedWithChildren {
|
||||
|
||||
__getValueWithStaticTransforms(
|
||||
// $FlowFixMe[unclear-type]
|
||||
staticTransforms: ReadonlyArray<Object>,
|
||||
staticTransforms: ReadonlyArray<any>,
|
||||
// $FlowFixMe[unclear-type]
|
||||
): ReadonlyArray<Object> {
|
||||
const values = [];
|
||||
|
||||
@@ -77,7 +77,7 @@ function reportException(
|
||||
}
|
||||
|
||||
// $FlowFixMe[unclear-type]
|
||||
const extraData: Object = {
|
||||
const extraData: any = {
|
||||
// $FlowFixMe[incompatible-use] we can't define a type with a Symbol-keyed field in flow
|
||||
...e[decoratedExtraDataKey],
|
||||
jsEngine: e.jsEngine,
|
||||
|
||||
@@ -279,8 +279,7 @@ class PushNotificationIOS {
|
||||
* See https://reactnative.dev/docs/pushnotificationios#getdeliverednotifications
|
||||
*/
|
||||
static getDeliveredNotifications(
|
||||
// $FlowFixMe[unclear-type]
|
||||
callback: (notifications: Array<Object>) => void,
|
||||
callback: (notifications: Array<LegacyObject>) => void,
|
||||
): void {
|
||||
invariant(
|
||||
NativePushNotificationManagerIOS,
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ function deriveAppName(
|
||||
}
|
||||
|
||||
// $FlowFixMe[unclear-type] JSON data has dynamic shape
|
||||
function readPackageJson(dir /*: string */) /*: Object | null */ {
|
||||
function readPackageJson(dir /*: string */) /*: any | null */ {
|
||||
const pkgPath = path.join(dir, 'package.json');
|
||||
if (!fs.existsSync(pkgPath)) {
|
||||
return null;
|
||||
|
||||
@@ -35,7 +35,7 @@ interface NativeAnimatedModuleSpec extends NativeAnimatedTurboModuleSpec {
|
||||
readonly connectAnimatedNodeToShadowNodeFamily?: (
|
||||
nodeTag: number,
|
||||
// $FlowExpectedError[unclear-type].
|
||||
shadowNode: Object,
|
||||
shadowNode: any,
|
||||
) => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ const {TestModule} = NativeModules;
|
||||
const TEST_PAYLOAD = {foo: 'bar'};
|
||||
|
||||
type AppEvent = {
|
||||
data: Object,
|
||||
data: any,
|
||||
ts: number,
|
||||
};
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ function renderSmallSwitchOption(
|
||||
);
|
||||
}
|
||||
|
||||
function PlainInput(props: Object): React.Node {
|
||||
function PlainInput(props: any): React.Node {
|
||||
return (
|
||||
<TextInput
|
||||
autoCapitalize="none"
|
||||
|
||||
@@ -25,8 +25,8 @@ const {
|
||||
} = require('react-native');
|
||||
|
||||
type Props<T> = {
|
||||
filter: Function,
|
||||
render: Function,
|
||||
filter: any,
|
||||
render: any,
|
||||
disableSearch?: boolean,
|
||||
testID?: string,
|
||||
hideFilterPills?: boolean,
|
||||
|
||||
@@ -121,7 +121,7 @@ class Circle extends React.Component<any, any> {
|
||||
},
|
||||
};
|
||||
}
|
||||
const animatedStyle: Object = {
|
||||
const animatedStyle: any = {
|
||||
shadowOpacity: this.state.pop, // no need for interpolation (step2d: uncomment)
|
||||
transform: [
|
||||
{
|
||||
|
||||
@@ -138,7 +138,7 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
function computeNewSelected(gestureState: Object): ?number {
|
||||
function computeNewSelected(gestureState: any): ?number {
|
||||
const {dx, dy} = gestureState;
|
||||
let minDist = Infinity;
|
||||
let newSelected = null;
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ export default class RNTesterPlatformTestEventRecorder {
|
||||
export function useRecorderTestEventHandlers(
|
||||
eventRecorder: RNTesterPlatformTestEventRecorder,
|
||||
targetNames: ReadonlyArray<string>,
|
||||
callback?: (event: Object, eventType: string, targetName: string) => void,
|
||||
callback?: (event: any, eventType: string, targetName: string) => void,
|
||||
): Readonly<{[targetName: string]: ViewProps}> {
|
||||
return useMemo(
|
||||
() => eventRecorder.createRecorderTestEventHandlers(targetNames, callback),
|
||||
|
||||
@@ -23,7 +23,7 @@ const OrientationChangeExample = (): React.Node => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const onOrientationChange = (orientation: Object) => {
|
||||
const onOrientationChange = (orientation: any) => {
|
||||
setState({
|
||||
currentOrientation: orientation.name,
|
||||
orientationDegrees: orientation.rotationDegrees,
|
||||
|
||||
@@ -34,7 +34,7 @@ type RTLToggleState = {isRTL: boolean, ...};
|
||||
|
||||
type AnimationState = {
|
||||
toggleStatus: any,
|
||||
linear: Object,
|
||||
linear: any,
|
||||
windowWidth: number,
|
||||
...
|
||||
};
|
||||
@@ -297,13 +297,13 @@ class AnimationExample extends React.Component<any, AnimationState> {
|
||||
);
|
||||
}
|
||||
|
||||
_onLayout = (e: Object) => {
|
||||
_onLayout = (e: any) => {
|
||||
this.setState({
|
||||
windowWidth: e.nativeEvent.layout.width,
|
||||
});
|
||||
};
|
||||
|
||||
_linearTap = (e: Object) => {
|
||||
_linearTap = (e: any) => {
|
||||
this.setState({
|
||||
toggleStatus: {
|
||||
...this.state.toggleStatus,
|
||||
|
||||
@@ -235,7 +235,7 @@ export component SectionList_scrollable() {
|
||||
if (logViewable) {
|
||||
console.log(
|
||||
'onViewableItemsChanged: ',
|
||||
info.changed.map((v: Object) => ({
|
||||
info.changed.map((v: any) => ({
|
||||
...v,
|
||||
item: '...',
|
||||
section: v.section.key,
|
||||
|
||||
@@ -29,8 +29,8 @@ function roundKilo(value: number): number {
|
||||
return Math.round(value / 1000);
|
||||
}
|
||||
|
||||
class XHRExampleDownload extends React.Component<{...}, Object> {
|
||||
state: Object = {
|
||||
class XHRExampleDownload extends React.Component<{...}, any> {
|
||||
state: any = {
|
||||
downloading: false,
|
||||
// set by onreadystatechange
|
||||
contentLength: 1,
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
|
||||
class XHRExampleFetch extends React.Component<any, any> {
|
||||
responseURL: ?string;
|
||||
responseHeaders: ?Object;
|
||||
responseHeaders: ?any;
|
||||
intervalId: ?ReturnType<typeof setInterval>;
|
||||
|
||||
constructor(props: any) {
|
||||
|
||||
@@ -348,7 +348,7 @@ class VirtualizedList extends StateSafePureComponent<
|
||||
}
|
||||
}
|
||||
|
||||
setNativeProps(props: Object) {
|
||||
setNativeProps(props: LegacyObject) {
|
||||
if (this._scrollRef) {
|
||||
this._scrollRef.setNativeProps(props);
|
||||
}
|
||||
@@ -929,7 +929,7 @@ class VirtualizedList extends StateSafePureComponent<
|
||||
}
|
||||
|
||||
_pushCells(
|
||||
cells: Array<Object>,
|
||||
cells: Array<any>,
|
||||
stickyHeaderIndices: Array<number>,
|
||||
stickyIndicesFromProps: ?Set<number>,
|
||||
first: number,
|
||||
@@ -1015,7 +1015,7 @@ class VirtualizedList extends StateSafePureComponent<
|
||||
};
|
||||
}
|
||||
|
||||
_onUpdateSeparators = (keys: Array<?string>, newProps: Object) => {
|
||||
_onUpdateSeparators = (keys: Array<?string>, newProps: any) => {
|
||||
keys.forEach(key => {
|
||||
const ref = key != null && this._cellRefs[key];
|
||||
ref && ref.updateSeparatorProps(newProps);
|
||||
@@ -1939,7 +1939,7 @@ class VirtualizedList extends StateSafePureComponent<
|
||||
this._onScroll(e);
|
||||
}
|
||||
|
||||
_onScroll = (e: Object) => {
|
||||
_onScroll = (e: any) => {
|
||||
this._nestedChildLists.forEach(childList => {
|
||||
childList._onScroll(e);
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ export type Item = any;
|
||||
export type Separators = {
|
||||
highlight: () => void,
|
||||
unhighlight: () => void,
|
||||
updateProps: (select: 'leading' | 'trailing', newProps: Object) => void,
|
||||
updateProps: (select: 'leading' | 'trailing', newProps: LegacyObject) => void,
|
||||
...
|
||||
};
|
||||
|
||||
|
||||
@@ -446,7 +446,7 @@ class VirtualizedSectionList<
|
||||
|
||||
_getSeparatorComponent(
|
||||
index: number,
|
||||
info?: ?Object,
|
||||
info?: ?any,
|
||||
listItemCount: number,
|
||||
): ?(React.ComponentType<any> | React.MixedElement) {
|
||||
info = info || this._subExtractor(index);
|
||||
@@ -502,7 +502,7 @@ type ItemWithSeparatorProps<ItemT> = Readonly<{
|
||||
prevCellKey?: ?string,
|
||||
updateHighlightFor: (prevCellKey: string, value: boolean) => void,
|
||||
updatePropsFor: (prevCellKey: string, value: Object) => void,
|
||||
renderItem: Function,
|
||||
renderItem: any,
|
||||
inverted: boolean,
|
||||
}>;
|
||||
|
||||
|
||||
Reference in new issue
Block a user