Skip to content

Commit 1f5c2e0

Browse files
committed
[flow] enable LTI for some directories
1 parent 855b77c commit 1f5c2e0

32 files changed

+149
-88
lines changed

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-dom/src/client/ReactDOMLegacy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function legacyCreateRootFromDOMContainer(
127127
};
128128
}
129129

130-
const root = createHydrationContainer(
130+
const root: FiberRoot = createHydrationContainer(
131131
initialChildren,
132132
callback,
133133
container,

packages/react-dom/src/server/ReactDOMFizzServerBrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function renderToReadableStream(
4949
return new Promise((resolve, reject) => {
5050
let onFatalError;
5151
let onAllReady;
52-
const allReady = new Promise((res, rej) => {
52+
const allReady = new Promise<void>((res, rej) => {
5353
onAllReady = res;
5454
onFatalError = rej;
5555
});

packages/react-dom/src/server/ReactDOMFizzServerBun.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function renderToReadableStream(
4949
return new Promise((resolve, reject) => {
5050
let onFatalError;
5151
let onAllReady;
52-
const allReady = new Promise((res, rej) => {
52+
const allReady = new Promise<void>((res, rej) => {
5353
onAllReady = res;
5454
onFatalError = rej;
5555
});

packages/react-dom/src/server/ReactDOMFizzStaticNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function prerenderToNodeStreams(
6666
const onFatalError = reject;
6767

6868
function onAllReady() {
69-
const readable = new Readable({
69+
const readable: Readable = new Readable({
7070
read() {
7171
startFlowing(request, writable);
7272
},

packages/react-interactions/events/src/dom/create-event-handle/useEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function useEvent(
3232

3333
if (useEventHandle === null) {
3434
const setEventHandle = unstable_createEventHandle(event, options);
35-
const clears = new Map();
35+
const clears = new Map<EventTarget, () => void>();
3636
useEventHandle = {
3737
setListener(
3838
target: EventTarget,

packages/react-reconciler/src/ReactChildFiber.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ function createChildReconciler(
768768

769769
if (__DEV__) {
770770
// First, validate keys.
771-
let knownKeys = null;
771+
let knownKeys: Set<string> | null = null;
772772
for (let i = 0; i < newChildren.length; i++) {
773773
const child = newChildren[i];
774774
knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
@@ -961,7 +961,7 @@ function createChildReconciler(
961961
// We'll get a different iterator later for the main pass.
962962
const newChildren = iteratorFn.call(newChildrenIterable);
963963
if (newChildren) {
964-
let knownKeys = null;
964+
let knownKeys: Set<string> | null = null;
965965
let step = newChildren.next();
966966
for (; !step.done; step = newChildren.next()) {
967967
const child = step.value;

0 commit comments

Comments
 (0)