Skip to content

Commit 6ddcbd4

Browse files
authored
[flow] enable LTI inference mode (#26104)
This is the next generation inference mode for Flow.
1 parent 53b1f69 commit 6ddcbd4

File tree

110 files changed

+378
-283
lines changed

Some content is hidden

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

110 files changed

+378
-283
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
6262
"fbjs-scripts": "^3.0.1",
6363
"filesize": "^6.0.1",
64-
"flow-bin": "^0.199.0",
64+
"flow-bin": "^0.199.1",
6565
"flow-remove-types": "^2.198.2",
6666
"glob": "^7.1.6",
6767
"glob-stream": "^6.1.0",

packages/jest-react/src/internalAct.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function act<T>(scope: () => Thenable<T> | T): Thenable<T> {
7777
) {
7878
const thenableResult: Thenable<T> = (result: any);
7979
return {
80-
then(resolve, reject) {
80+
then(resolve: T => mixed, reject: mixed => mixed) {
8181
thenableResult.then(
8282
returnValue => {
8383
flushActWork(
@@ -108,7 +108,7 @@ export function act<T>(scope: () => Thenable<T> | T): Thenable<T> {
108108
didFlushWork = Scheduler.unstable_flushAllWithoutAsserting();
109109
} while (didFlushWork);
110110
return {
111-
then(resolve, reject) {
111+
then(resolve: T => mixed, reject: mixed => mixed) {
112112
resolve(returnValue);
113113
},
114114
};

packages/react-cache/src/ReactCacheOld.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ function identityHashFn(input) {
8585
}
8686

8787
const CACHE_LIMIT = 500;
88-
const lru = createLRU(CACHE_LIMIT);
88+
const lru = createLRU<$FlowFixMe>(CACHE_LIMIT);
8989

9090
const entries: Map<Resource<any, any>, Map<any, any>> = new Map();
9191

92-
const CacheContext = React.createContext(null);
92+
const CacheContext = React.createContext<mixed>(null);
9393

9494
function accessResult<I, K, V>(
9595
resource: any,

packages/react-client/src/ReactFlightClient.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ Chunk.prototype.then = function <T>(
129129
case BLOCKED:
130130
if (resolve) {
131131
if (chunk.value === null) {
132-
chunk.value = [];
132+
chunk.value = ([]: Array<(T) => mixed>);
133133
}
134134
chunk.value.push(resolve);
135135
}
136136
if (reject) {
137137
if (chunk.reason === null) {
138-
chunk.reason = [];
138+
chunk.reason = ([]: Array<(mixed) => mixed>);
139139
}
140140
chunk.reason.push(reject);
141141
}
@@ -435,7 +435,7 @@ function createModelResolver<T>(
435435
chunk: SomeChunk<T>,
436436
parentObject: Object,
437437
key: string,
438-
) {
438+
): (value: any) => void {
439439
let blocked;
440440
if (initializingChunkBlockedModel) {
441441
blocked = initializingChunkBlockedModel;
@@ -446,7 +446,6 @@ function createModelResolver<T>(
446446
value: null,
447447
};
448448
}
449-
// $FlowFixMe[missing-local-annot]
450449
return value => {
451450
parentObject[key] = value;
452451
blocked.deps--;
@@ -465,7 +464,7 @@ function createModelResolver<T>(
465464
};
466465
}
467466

468-
function createModelReject<T>(chunk: SomeChunk<T>) {
467+
function createModelReject<T>(chunk: SomeChunk<T>): (error: mixed) => void {
469468
return (error: mixed) => triggerErrorOnChunk(chunk, error);
470469
}
471470

@@ -583,7 +582,7 @@ export function resolveModule(
583582
const chunks = response._chunks;
584583
const chunk = chunks.get(id);
585584
const moduleMetaData: ModuleMetaData = parseModel(response, model);
586-
const moduleReference = resolveClientReference(
585+
const moduleReference = resolveClientReference<$FlowFixMe>(
587586
response._bundlerConfig,
588587
moduleMetaData,
589588
);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
6060
// This initializes a cache of all primitive hooks so that the top
6161
// most stack frames added by calling the primitive hook can be removed.
6262
if (primitiveStackCache === null) {
63-
const cache = new Map();
63+
const cache = new Map<string, Array<any>>();
6464
let readHookLog;
6565
try {
6666
// Use all hooks here to add them to the hook log.
6767
Dispatcher.useContext(({_currentValue: null}: any));
6868
Dispatcher.useState(null);
69-
Dispatcher.useReducer((s, a) => s, null);
69+
Dispatcher.useReducer((s: mixed, a: mixed) => s, null);
7070
Dispatcher.useRef(null);
7171
if (typeof Dispatcher.useCacheRefresh === 'function') {
7272
// This type check is for Flow only.
@@ -809,7 +809,7 @@ export function inspectHooksOfFiber(
809809
// Set up the current hook so that we can step through and read the
810810
// current state from them.
811811
currentHook = (fiber.memoizedState: Hook);
812-
const contextMap = new Map();
812+
const contextMap = new Map<ReactContext<$FlowFixMe>, $FlowFixMe>();
813813
try {
814814
setupContexts(contextMap, fiber);
815815
if (fiber.tag === ForwardRef) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
6767
useHttps = false,
6868
port = 8097,
6969
websocket,
70-
resolveRNStyle = null,
70+
resolveRNStyle = (null: $FlowFixMe),
7171
retryConnectionDelay = 2000,
7272
isAppActive = () => true,
7373
devToolsSettingsManager,
@@ -230,7 +230,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
230230
get() {
231231
return lazyResolveRNStyle;
232232
},
233-
set(value) {
233+
set(value: $FlowFixMe) {
234234
lazyResolveRNStyle = value;
235235
initAfterTick();
236236
},
@@ -246,7 +246,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
246246
get() {
247247
return lazyNativeStyleEditorValidAttributes;
248248
},
249-
set(value) {
249+
set(value: $FlowFixMe) {
250250
lazyNativeStyleEditorValidAttributes = value;
251251
initAfterTick();
252252
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export function launchEditor(
188188
}
189189
childProcess.on('error', function () {});
190190
// $FlowFixMe[incompatible-use] found when upgrading Flow
191-
childProcess.on('exit', function (errorCode) {
191+
childProcess.on('exit', function () {
192192
childProcess = null;
193193
});
194194
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function onDisconnected() {
168168
}
169169

170170
// $FlowFixMe[missing-local-annot]
171-
function onError({code, message}) {
171+
function onError({code, message}: $FlowFixMe) {
172172
safeUnmount();
173173

174174
if (code === 'EADDRINUSE') {
@@ -335,13 +335,13 @@ function startServer(
335335
initialize(socket);
336336
});
337337

338-
server.on('error', event => {
338+
server.on('error', (event: $FlowFixMe) => {
339339
onError(event);
340340
log.error('Failed to start the DevTools server', event);
341341
startServerTimeoutID = setTimeout(() => startServer(port), 1000);
342342
});
343343

344-
httpServer.on('request', (request, response) => {
344+
httpServer.on('request', (request: $FlowFixMe, response: $FlowFixMe) => {
345345
// Serve a file that immediately sets up the connection.
346346
const backendFile = readFileSync(join(__dirname, 'backend.js'));
347347

@@ -377,7 +377,7 @@ function startServer(
377377
);
378378
});
379379

380-
httpServer.on('error', event => {
380+
httpServer.on('error', (event: $FlowFixMe) => {
381381
onError(event);
382382
statusListener('Failed to start the server.', 'error');
383383
startServerTimeoutID = setTimeout(() => startServer(port), 1000);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
let welcomeHasInitialized = false;
1010

1111
// $FlowFixMe[missing-local-annot]
12-
function welcome(event) {
12+
function welcome(event: $FlowFixMe) {
1313
if (
1414
event.source !== window ||
1515
event.data.source !== 'react-devtools-content-script'
@@ -56,8 +56,7 @@ function setup(hook: any) {
5656

5757
const bridge = new Bridge({
5858
listen(fn) {
59-
// $FlowFixMe[missing-local-annot]
60-
const listener = event => {
59+
const listener = (event: $FlowFixMe) => {
6160
if (
6261
event.source !== window ||
6362
!event.data ||

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import type {BackendBridge} from 'react-devtools-shared/src/bridge';
1010
import type {Wall} from 'react-devtools-shared/src/types';
1111

1212
function startActivation(contentWindow: any, bridge: BackendBridge) {
13-
// $FlowFixMe[missing-local-annot]
14-
const onSavedPreferences = data => {
13+
const onSavedPreferences = (data: $FlowFixMe) => {
1514
// This is the only message we're listening for,
1615
// so it's safe to cleanup after we've received it.
1716
bridge.removeListener('savedPreferences', onSavedPreferences);
@@ -102,8 +101,7 @@ export function createBridge(contentWindow: any, wall?: Wall): BackendBridge {
102101
if (wall == null) {
103102
wall = {
104103
listen(fn) {
105-
// $FlowFixMe[missing-local-annot]
106-
const onMessage = ({data}) => {
104+
const onMessage = ({data}: $FlowFixMe) => {
107105
fn(data);
108106
};
109107
contentWindow.addEventListener('message', onMessage);

0 commit comments

Comments
 (0)