Skip to content

Commit e706721

Browse files
authored
Update Flow to 0.84 (#17805)
* Update Flow to 0.84 * Fix violations * Use inexact object syntax in files from fbsource * Fix warning extraction to use a modern parser * Codemod inexact objects to new syntax * Tighten types that can be exact * Revert unintentional formatting changes from codemod
1 parent b979db4 commit e706721

File tree

97 files changed

+313
-233
lines changed

Some content is hidden

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

97 files changed

+313
-233
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@babel/code-frame": "^7.0.0",
99
"@babel/core": "^7.0.0",
1010
"@babel/helper-module-imports": "^7.0.0",
11+
"@babel/parser": "^7.0.0",
1112
"@babel/plugin-external-helpers": "^7.0.0",
1213
"@babel/plugin-proposal-class-properties": "^7.0.0",
1314
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
@@ -36,7 +37,6 @@
3637
"art": "^0.10.1",
3738
"babel-eslint": "^10.0.0",
3839
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
39-
"babylon": "6.18.0",
4040
"chalk": "^1.1.3",
4141
"cli-table": "^0.3.1",
4242
"coffee-script": "^1.8.0",
@@ -56,7 +56,7 @@
5656
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
5757
"fbjs-scripts": "^0.8.3",
5858
"filesize": "^3.5.6",
59-
"flow-bin": "^0.72.0",
59+
"flow-bin": "^0.84.0",
6060
"glob": "^6.0.4",
6161
"glob-stream": "^6.1.0",
6262
"google-closure-compiler": "20190301.0.0",

packages/create-subscription/src/createSubscription.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ export function createSubscription<Property, Value>(
2929
callback: (value: Value | void) => void,
3030
) => Unsubscribe,
3131
|}>,
32-
): React$ComponentType<{
32+
): React$ComponentType<{|
3333
children: (value: Value | void) => React$Node,
3434
source: Property,
35-
}> {
35+
|}> {
3636
const {getCurrentValue, subscribe} = config;
3737

3838
if (__DEV__) {
@@ -44,14 +44,14 @@ export function createSubscription<Property, Value>(
4444
}
4545
}
4646

47-
type Props = {
47+
type Props = {|
4848
children: (value: Value) => React$Element<any>,
4949
source: Property,
50-
};
51-
type State = {
50+
|};
51+
type State = {|
5252
source: Property,
5353
value: Value | void,
54-
};
54+
|};
5555

5656
// Reference: https://gist.github.com/bvaughn/d569177d70b50b58bff69c3c4a5353f3
5757
class Subscription extends React.Component<Props, State> {

packages/legacy-events/EventPluginRegistry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616

1717
import invariant from 'shared/invariant';
1818

19-
type NamesToPlugins = {[key: PluginName]: PluginModule<AnyNativeEvent>};
19+
type NamesToPlugins = {[key: PluginName]: PluginModule<AnyNativeEvent>, ...};
2020
type EventPluginOrder = null | Array<PluginName>;
2121

2222
/**

packages/legacy-events/PluginModuleType.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
import type {TopLevelType} from './TopLevelEventTypes';
1616
import type {EventSystemFlags} from 'legacy-events/EventSystemFlags';
1717

18-
export type EventTypes = {[key: string]: DispatchConfig};
18+
export type EventTypes = {[key: string]: DispatchConfig, ...};
1919

2020
export type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | Touch;
2121

@@ -31,4 +31,5 @@ export type PluginModule<NativeEvent> = {
3131
eventSystemFlags: EventSystemFlags,
3232
) => ?ReactSyntheticEvent,
3333
tapMoveThreshold?: number,
34+
...
3435
};

packages/legacy-events/ReactSyntheticEventType.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import type {Fiber} from 'react-reconciler/src/ReactFiber';
1212
import type {EventPriority} from 'shared/ReactTypes';
1313
import type {TopLevelType} from './TopLevelEventTypes';
1414

15-
export type DispatchConfig = {
15+
export type DispatchConfig = {|
1616
dependencies: Array<TopLevelType>,
17-
phasedRegistrationNames?: {
17+
phasedRegistrationNames?: {|
1818
bubbled: string,
1919
captured: string,
20-
},
20+
|},
2121
registrationName?: string,
2222
eventPriority: EventPriority,
23-
};
23+
|};
2424

25-
export type ReactSyntheticEvent = {
25+
export type ReactSyntheticEvent = {|
2626
dispatchConfig: DispatchConfig,
2727
getPooled: (
2828
dispatchConfig: DispatchConfig,
@@ -31,4 +31,4 @@ export type ReactSyntheticEvent = {
3131
nativeEventTarget: EventTarget,
3232
) => ReactSyntheticEvent,
3333
isPersistent: () => boolean,
34-
} & SyntheticEvent<>;
34+
|} & SyntheticEvent<>;

packages/legacy-events/ResponderTouchHistoryStore.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {isStartish, isMoveish, isEndish} from './ResponderTopLevelEventTypes';
1616
* should typically only see IDs in the range of 1-20 because IDs get recycled
1717
* when touches end and start again.
1818
*/
19-
type TouchRecord = {
19+
type TouchRecord = {|
2020
touchActive: boolean,
2121
startPageX: number,
2222
startPageY: number,
@@ -27,7 +27,7 @@ type TouchRecord = {
2727
previousPageX: number,
2828
previousPageY: number,
2929
previousTimeStamp: number,
30-
};
30+
|};
3131

3232
const MAX_TOUCH_BANK = 20;
3333
const touchBank: Array<TouchRecord> = [];
@@ -46,10 +46,12 @@ type Touch = {
4646
pageX: number,
4747
pageY: number,
4848
timestamp: number,
49+
...
4950
};
5051
type TouchEvent = {
5152
changedTouches: Array<Touch>,
5253
touches: Array<Touch>,
54+
...
5355
};
5456

5557
function timestampForTouch(touch: Touch): number {

packages/react-cache/src/ReactCache.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import {createLRU} from './LRU';
1313

1414
type Thenable<T> = {
1515
then(resolve: (T) => mixed, reject: (mixed) => mixed): mixed,
16+
...
1617
};
1718

18-
type Suspender = {
19-
then(resolve: () => mixed, reject: () => mixed): mixed,
20-
};
19+
type Suspender = {then(resolve: () => mixed, reject: () => mixed): mixed, ...};
2120

2221
type PendingResult = {|
2322
status: 0,
@@ -39,6 +38,7 @@ type Result<V> = PendingResult | ResolvedResult<V> | RejectedResult;
3938
type Resource<I, V> = {
4039
read(I): V,
4140
preload(I): void,
41+
...
4242
};
4343

4444
const Pending = 0;

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type HookLogEntry = {
3636
primitive: string,
3737
stackError: Error,
3838
value: mixed,
39+
...
3940
};
4041

4142
let hookLog: Array<HookLogEntry> = [];
@@ -142,7 +143,7 @@ function useReducer<S, I, A>(
142143
return [state, (action: A) => {}];
143144
}
144145

145-
function useRef<T>(initialValue: T): {current: T} {
146+
function useRef<T>(initialValue: T): {|current: T|} {
146147
let hook = nextHook();
147148
let ref = hook !== null ? hook.memoizedState : {current: initialValue};
148149
hookLog.push({
@@ -174,7 +175,7 @@ function useEffect(
174175
}
175176

176177
function useImperativeHandle<T>(
177-
ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
178+
ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
178179
create: () => T,
179180
inputs: Array<mixed> | void | null,
180181
): void {
@@ -285,6 +286,7 @@ export type HooksNode = {
285286
name: string,
286287
value: mixed,
287288
subHooks: Array<HooksNode>,
289+
...
288290
};
289291
export type HooksTree = Array<HooksNode>;
290292

packages/react-devtools-core/src/backend.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type ConnectOptions = {
2727
resolveRNStyle?: ResolveNativeStyle,
2828
isAppActive?: () => boolean,
2929
websocket?: ?WebSocket,
30+
...
3031
};
3132

3233
installHook(window);
@@ -120,7 +121,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
120121
});
121122
bridge.addListener(
122123
'inspectElement',
123-
({id, rendererID}: {id: number, rendererID: number}) => {
124+
({id, rendererID}: {id: number, rendererID: number, ...}) => {
124125
const renderer = agent.rendererInterfaces[rendererID];
125126
if (renderer != null) {
126127
// Send event for RN to highlight.

packages/react-devtools-shared/src/backend/agent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default class Agent extends EventEmitter<{|
109109
_bridge: BackendBridge;
110110
_isProfiling: boolean = false;
111111
_recordChangeDescriptions: boolean = false;
112-
_rendererInterfaces: {[key: RendererID]: RendererInterface} = {};
112+
_rendererInterfaces: {[key: RendererID]: RendererInterface, ...} = {};
113113
_persistedSelection: PersistedSelection | null = null;
114114
_persistedSelectionMatch: PathMatch | null = null;
115115
_traceUpdatesEnabled: boolean = false;
@@ -185,7 +185,7 @@ export default class Agent extends EventEmitter<{|
185185
setupTraceUpdates(this);
186186
}
187187

188-
get rendererInterfaces(): {[key: RendererID]: RendererInterface} {
188+
get rendererInterfaces(): {[key: RendererID]: RendererInterface, ...} {
189189
return this._rendererInterfaces;
190190
}
191191

0 commit comments

Comments
 (0)