@samitouri / QOS-React-1 / commits / 900ae094d8

[flow] Bump flow to v0.317.0 (#36701)

## Summary Mostly changing the casting syntax from `(x: Y)` to `x as Y`, as the old syntax was deprecated and always causing an error in Flow ## How did you test this change? `yarn flow-ci`

Sam Zhou committed Jun 5, 2026 at 19:17 UTC 900ae094d85b11c67d53dd14af50a2bda5db4495
330 files changed +2423 -2422
package.json
+2 -2
@@ -75,8 +75,8 @@
75 "eslint-plugin-react-internal": "link:./scripts/eslint-rules",
76 "fbjs-scripts": "^3.0.1",
77 "filesize": "^6.0.1",
78 - "flow-bin": "^0.307.1",
79 - "flow-remove-types": "^2.307.1",
78 + "flow-bin": "^0.317.0",
79 + "flow-remove-types": "^2.317.0",
80 "flow-typed": "^4.1.1",
81 "glob": "^7.1.6",
82 "glob-stream": "^6.1.0",
packages/react-cache/src/LRU.js
+8 -8
@@ -56,21 +56,21 @@ export function createLRU<T>(limit: number): LRU<T> {
56 function deleteLeastRecentlyUsedEntries(targetSize: number) {
57 // Delete entries from the cache, starting from the end of the list.
58 if (first !== null) {
59 - const resolvedFirst: Entry<T> = (first: any);
59 + const resolvedFirst: Entry<T> = first as any;
60 let last: null | Entry<T> = resolvedFirst.previous;
61 while (size > targetSize && last !== null) {
62 const onDelete = last.onDelete;
63 const previous = last.previous;
64 - last.onDelete = (null: any);
64 + last.onDelete = null as any;
65
66 // Remove from the list
67 - last.previous = last.next = (null: any);
67 + last.previous = last.next = null as any;
68 if (last === first) {
69 // Reached the head of the list.
70 first = last = null;
71 } else {
72 - (first: any).previous = previous;
73 - previous.next = (first: any);
72 + (first as any).previous = previous;
73 + previous.next = first as any;
74 last = previous;
75 }
76
@@ -88,8 +88,8 @@ export function createLRU<T>(limit: number): LRU<T> {
88 const entry = {
89 value,
90 onDelete,
91 - next: (null: any),
92 - previous: (null: any),
91 + next: null as any,
92 + previous: null as any,
93 };
94 if (first === null) {
95 entry.previous = entry.next = entry;
@@ -118,7 +118,7 @@ export function createLRU<T>(limit: number): LRU<T> {
118 // $FlowFixMe[invalid-compare]
119 if (next !== null) {
120 // Entry already cached
121 - const resolvedFirst: Entry<T> = (first: any);
121 + const resolvedFirst: Entry<T> = first as any;
122 if (first !== entry) {
123 // Remove from current position
124 const previous = entry.previous;
packages/react-cache/src/ReactCacheOld.js
+5 -5
@@ -107,14 +107,14 @@ function accessResult<I, K, V>(
107 thenable.then(
108 value => {
109 if (newResult.status === Pending) {
110 - const resolvedResult: ResolvedResult<V> = (newResult: any);
110 + const resolvedResult: ResolvedResult<V> = newResult as any;
111 resolvedResult.status = Resolved;
112 resolvedResult.value = value;
113 }
114 },
115 error => {
116 if (newResult.status === Pending) {
117 - const rejectedResult: RejectedResult = (newResult: any);
117 + const rejectedResult: RejectedResult = newResult as any;
118 rejectedResult.status = Rejected;
119 rejectedResult.value = error;
120 }
@@ -128,7 +128,7 @@ function accessResult<I, K, V>(
128 entriesForResource.set(key, newEntry);
129 return newResult;
130 } else {
131 - return (lru.access(entry): any);
131 + return lru.access(entry) as any;
132 }
133 }
134
@@ -147,7 +147,7 @@ export function unstable_createResource<I, K: string | number, V>(
147 maybeHashInput?: I => K,
148 ): Resource<I, V> {
149 const hashInput: I => K =
150 - maybeHashInput !== undefined ? maybeHashInput : (identityHashFn: any);
150 + maybeHashInput !== undefined ? maybeHashInput : (identityHashFn as any);
151
152 const resource = {
153 read(input: I): V {
@@ -171,7 +171,7 @@ export function unstable_createResource<I, K: string | number, V>(
171 }
172 default:
173 // Should be unreachable
174 - return (undefined: any);
174 + return undefined as any;
175 }
176 },
177
packages/react-client/src/ReactFlightClient.js
+102 -102
@@ -116,7 +116,7 @@ import type {SharedStateClient} from 'react/src/ReactSharedInternalsClient';
116 // client both in the RSC environment, in the SSR environments as well as the
117 // browser client. We should probably have a separate RSC build. This is DEV
118 // only though.
119 -const ReactSharedInteralsServer: void | SharedStateServer = (React: any)
119 +const ReactSharedInteralsServer: void | SharedStateServer = (React as any)
120 .__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
121 const ReactSharedInternals: SharedStateServer | SharedStateClient =
122 React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ||
@@ -254,7 +254,7 @@ function ReactPromise(status: any, value: any, reason: any) {
254 }
255 }
256 // We subclass Promise.prototype so that we get other methods like .catch
257 -ReactPromise.prototype = (Object.create(Promise.prototype): any);
257 +ReactPromise.prototype = Object.create(Promise.prototype) as any;
258 // TODO: This doesn't return a new Promise chain unlike the real .then
259 ReactPromise.prototype.then = function <T>(
260 this: SomeChunk<T>,
@@ -304,15 +304,15 @@ ReactPromise.prototype.then = function <T>(
304 case BLOCKED:
305 if (typeof resolve === 'function') {
306 if (chunk.value === null) {
307 - chunk.value = ([]: Array<InitializationReference | (T => mixed)>);
307 + chunk.value = [] as Array<InitializationReference | (T => mixed)>;
308 }
309 chunk.value.push(resolve);
310 }
311 if (typeof reject === 'function') {
312 if (chunk.reason === null) {
313 - chunk.reason = ([]: Array<
313 + chunk.reason = [] as Array<
314 InitializationReference | (mixed => mixed),
315 - >);
315 + >;
316 }
317 chunk.reason.push(reject);
318 }
@@ -394,7 +394,7 @@ function unwrapWeakResponse(weakResponse: WeakResponse): Response {
394 }
395 return response;
396 } else {
397 - return (weakResponse: any); // In prod we just use the real Response directly.
397 + return weakResponse as any; // In prod we just use the real Response directly.
398 }
399 }
400
@@ -402,7 +402,7 @@ function getWeakResponse(response: Response): WeakResponse {
402 if (__DEV__) {
403 return response._weakResponse;
404 } else {
405 - return (response: any); // In prod we just use the real Response directly.
405 + return response as any; // In prod we just use the real Response directly.
406 }
407 }
408
@@ -437,7 +437,7 @@ function readChunk<T>(chunk: SomeChunk<T>): T {
437 case BLOCKED:
438 case HALTED:
439 // eslint-disable-next-line no-throw-literal
440 - throw ((chunk: any): Thenable<T>);
440 + throw chunk as any as Thenable<T>;
441 default:
442 throw chunk.reason;
443 }
@@ -446,7 +446,7 @@ function readChunk<T>(chunk: SomeChunk<T>): T {
446 export function getRoot<T>(weakResponse: WeakResponse): Thenable<T> {
447 const response = unwrapWeakResponse(weakResponse);
448 const chunk = getChunk(response, 0);
449 - return (chunk: any);
449 + return chunk as any;
450 }
451
452 function createPendingChunk<T>(response: Response): PendingChunk<T> {
@@ -547,7 +547,7 @@ function moveDebugInfoFromChunkToInnerValue<T>(
547 debugInfo,
548 );
549 } else if (!Object.isFrozen(resolvedValue)) {
550 - Object.defineProperty((resolvedValue: any), '_debugInfo', {
550 + Object.defineProperty(resolvedValue as any, '_debugInfo', {
551 configurable: false,
552 enumerable: false,
553 writable: true,
@@ -665,9 +665,9 @@ function wakeChunkIfInitialized<T>(
665 }
666 }
667 // The status might have changed after fulfilling the reference.
668 - switch ((chunk: SomeChunk<T>).status) {
668 + switch ((chunk as SomeChunk<T>).status) {
669 case INITIALIZED:
670 - const initializedChunk: InitializedChunk<T> = (chunk: any);
670 + const initializedChunk: InitializedChunk<T> = chunk as any;
671 wakeChunk(
672 response,
673 resolveListeners,
@@ -721,7 +721,7 @@ function triggerErrorOnChunk<T>(
721 if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
722 // If we get more data to an already resolved ID, we assume that it's
723 // a stream chunk since any other row shouldn't have more than one entry.
724 - const streamChunk: InitializedStreamChunk<any> = (chunk: any);
724 + const streamChunk: InitializedStreamChunk<any> = chunk as any;
725 const controller = streamChunk.reason;
726 // $FlowFixMe[incompatible-type]: The error method should accept mixed.
727 controller.error(error);
@@ -736,7 +736,7 @@ function triggerErrorOnChunk<T>(
736 const prevHandler = initializingHandler;
737 const prevChunk = initializingChunk;
738 initializingHandler = null;
739 - const cyclicChunk: BlockedChunk<T> = (chunk: any);
739 + const cyclicChunk: BlockedChunk<T> = chunk as any;
740 cyclicChunk.status = BLOCKED;
741 cyclicChunk.value = null;
742 cyclicChunk.reason = null;
@@ -761,7 +761,7 @@ function triggerErrorOnChunk<T>(
761 }
762 }
763
764 - const erroredChunk: ErroredChunk<T> = (chunk: any);
764 + const erroredChunk: ErroredChunk<T> = chunk as any;
765 erroredChunk.status = ERRORED;
766 erroredChunk.reason = error;
767 if (listeners !== null) {
@@ -861,7 +861,7 @@ function resolveModelChunk<T>(
861 if (chunk.status !== PENDING) {
862 // If we get more data to an already resolved ID, we assume that it's
863 // a stream chunk since any other row shouldn't have more than one entry.
864 - const streamChunk: InitializedStreamChunk<any> = (chunk: any);
864 + const streamChunk: InitializedStreamChunk<any> = chunk as any;
865 const controller = streamChunk.reason;
866 controller.enqueueModel(value);
867 return;
@@ -869,7 +869,7 @@ function resolveModelChunk<T>(
869 releasePendingChunk(response, chunk);
870 const resolveListeners = chunk.value;
871 const rejectListeners = chunk.reason;
872 - const resolvedChunk: ResolvedModelChunk<T> = (chunk: any);
872 + const resolvedChunk: ResolvedModelChunk<T> = chunk as any;
873 resolvedChunk.status = RESOLVED_MODEL;
874 resolvedChunk.value = value;
875 resolvedChunk.reason = response;
@@ -895,7 +895,7 @@ function resolveModuleChunk<T>(
895 releasePendingChunk(response, chunk);
896 const resolveListeners = chunk.value;
897 const rejectListeners = chunk.reason;
898 - const resolvedChunk: ResolvedModuleChunk<T> = (chunk: any);
898 + const resolvedChunk: ResolvedModuleChunk<T> = chunk as any;
899 resolvedChunk.status = RESOLVED_MODULE;
900 resolvedChunk.value = value;
901 resolvedChunk.reason = null;
@@ -960,7 +960,7 @@ function initializeDebugChunk(
960 }
961 // Initializing the model for the first time.
962 initializeModelChunk(debugChunk);
963 - const initializedChunk = ((debugChunk: any): SomeChunk<any>);
963 + const initializedChunk = debugChunk as any as SomeChunk<any>;
964 switch (initializedChunk.status) {
965 case INITIALIZED: {
966 debugInfo[idx] = initializeDebugInfo(
@@ -1028,7 +1028,7 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
1028 // We go to the BLOCKED state until we've fully resolved this.
1029 // We do this before parsing in case we try to initialize the same chunk
1030 // while parsing the model. Such as in a cyclic reference.
1031 - const cyclicChunk: BlockedChunk<T> = (chunk: any);
1031 + const cyclicChunk: BlockedChunk<T> = chunk as any;
1032 cyclicChunk.status = BLOCKED;
1033 cyclicChunk.value = null;
1034 cyclicChunk.reason = null;
@@ -1075,7 +1075,7 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
1075 return;
1076 }
1077 }
1078 - const initializedChunk: InitializedChunk<T> = (chunk: any);
1078 + const initializedChunk: InitializedChunk<T> = chunk as any;
1079 initializedChunk.status = INITIALIZED;
1080 initializedChunk.value = value;
1081 initializedChunk.reason = null;
@@ -1084,7 +1084,7 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
1084 processChunkDebugInfo(response, initializedChunk, value);
1085 }
1086 } catch (error) {
1087 - const erroredChunk: ErroredChunk<T> = (chunk: any);
1087 + const erroredChunk: ErroredChunk<T> = chunk as any;
1088 erroredChunk.status = ERRORED;
1089 erroredChunk.reason = error;
1090 } finally {
@@ -1098,12 +1098,12 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
1098 function initializeModuleChunk<T>(chunk: ResolvedModuleChunk<T>): void {
1099 try {
1100 const value: T = requireModule(chunk.value);
1101 - const initializedChunk: InitializedChunk<T> = (chunk: any);
1101 + const initializedChunk: InitializedChunk<T> = chunk as any;
1102 initializedChunk.status = INITIALIZED;
1103 initializedChunk.value = value;
1104 initializedChunk.reason = null;
1105 } catch (error) {
1106 - const erroredChunk: ErroredChunk<T> = (chunk: any);
1106 + const erroredChunk: ErroredChunk<T> = chunk as any;
1107 erroredChunk.status = ERRORED;
1108 erroredChunk.reason = error;
1109 }
@@ -1240,7 +1240,7 @@ function initializeElement(
1240 element._debugStack = normalizedStackTrace;
1241 let task: null | ConsoleTask = null;
1242 if (supportsCreateTask && stack !== null) {
1243 - const createTaskFn = (console: any).createTask.bind(
1243 + const createTaskFn = (console as any).createTask.bind(
1244 console,
1245 getTaskName(element.type),
1246 );
@@ -1322,19 +1322,19 @@ function createElement(
1322 let element: any;
1323 if (__DEV__) {
1324 // `ref` is non-enumerable in dev
1325 - element = ({
1325 + element = {
1326 $$typeof: REACT_ELEMENT_TYPE,
1327 type,
1328 key,
1329 props,
1330 _owner: owner === undefined ? null : owner,
1331 - }: any);
1331 + } as any;
1332 Object.defineProperty(element, 'ref', {
1333 enumerable: false,
1334 get: nullRefGetter,
1335 });
1336 } else {
1337 - element = ({
1337 + element = {
1338 // This tag allows us to uniquely identify this as a React Element
1339 $$typeof: REACT_ELEMENT_TYPE,
1340
@@ -1342,16 +1342,16 @@ function createElement(
1342 key,
1343 ref: null,
1344 props,
1345 - }: any);
1345 + } as any;
1346 }
1347
1348 if (__DEV__) {
1349 // We don't really need to add any of these but keeping them for good measure.
1350 // Unfortunately, _store is enumerable in jest matchers so for equality to
1351 // work, I need to keep it or make _store non-enumerable in the other file.
1352 - element._store = ({}: {
1352 + element._store = {} as {
1353 validated?: number,
1354 - });
1354 + };
1355 Object.defineProperty(element._store, 'validated', {
1356 configurable: false,
1357 enumerable: false,
@@ -1463,7 +1463,7 @@ function getChunk(response: Response, id: number): SomeChunk<any> {
1463 // For partial streams, chunks accessed after close should be HALTED
1464 // (never resolve).
1465 chunk = createPendingChunk(response);
1466 - const haltedChunk: HaltedChunk<any> = (chunk: any);
1466 + const haltedChunk: HaltedChunk<any> = chunk as any;
1467 haltedChunk.status = HALTED;
1468 haltedChunk.value = null;
1469 haltedChunk.reason = null;
@@ -1673,7 +1673,7 @@ function fulfillReference(
1673 return;
1674 }
1675 const resolveListeners = chunk.value;
1676 - const initializedChunk: InitializedChunk<any> = (chunk: any);
1676 + const initializedChunk: InitializedChunk<any> = chunk as any;
1677 initializedChunk.status = INITIALIZED;
1678 initializedChunk.value = handler.value;
1679 initializedChunk.reason = handler.reason; // Used by streaming chunks
@@ -1762,7 +1762,7 @@ function waitForReference<T>(
1762 // If it's still pending that suggests that it was referencing an object in the debug
1763 // channel, but no debug channel was wired up so it's missing. In this case we can just
1764 // drop the debug info instead of halting the whole stream.
1765 - return (null: any);
1765 + return null as any;
1766 }
1767 }
1768
@@ -1805,7 +1805,7 @@ function waitForReference<T>(
1805 }
1806
1807 // Return a place holder value for now.
1808 - return (null: any);
1808 + return null as any;
1809 }
1810
1811 function loadServerReference<A: Iterable<any>, T>(
@@ -1840,7 +1840,7 @@ function loadServerReference<A: Iterable<any>, T>(
1840 let promise: null | Thenable<any> = preloadModule(serverReference);
1841 if (!promise) {
1842 if (!metaData.bound) {
1843 - const resolvedValue = (requireModule(serverReference): any);
1843 + const resolvedValue = requireModule(serverReference) as any;
1844 registerBoundServerReference(
1845 resolvedValue,
1846 metaData.id,
@@ -1871,11 +1871,11 @@ function loadServerReference<A: Iterable<any>, T>(
1871 }
1872
1873 function fulfill(): void {
1874 - let resolvedValue = (requireModule(serverReference): any);
1874 + let resolvedValue = requireModule(serverReference) as any;
1875
1876 if (metaData.bound) {
1877 // This promise is coming from us and should have initilialized by now.
1878 - const boundArgs: Array<any> = (metaData.bound: any).value.slice(0);
1878 + const boundArgs: Array<any> = (metaData.bound as any).value.slice(0);
1879 boundArgs.unshift(null); // this
1880 resolvedValue = resolvedValue.bind.apply(resolvedValue, boundArgs);
1881 }
@@ -1927,7 +1927,7 @@ function loadServerReference<A: Iterable<any>, T>(
1927 return;
1928 }
1929 const resolveListeners = chunk.value;
1930 - const initializedChunk: InitializedChunk<T> = (chunk: any);
1930 + const initializedChunk: InitializedChunk<T> = chunk as any;
1931 initializedChunk.status = INITIALIZED;
1932 initializedChunk.value = handler.value;
1933 initializedChunk.reason = null;
@@ -1990,7 +1990,7 @@ function loadServerReference<A: Iterable<any>, T>(
1990 promise.then(fulfill, reject);
1991
1992 // Return a place holder value for now.
1993 - return (null: any);
1993 + return null as any;
1994 }
1995
1996 function resolveLazy(value: any): mixed {
@@ -2025,7 +2025,7 @@ function transferReferencedDebugInfo(
2025 for (let i = 0; i < referencedDebugInfo.length; ++i) {
2026 const debugInfoEntry = referencedDebugInfo[i];
2027 if (debugInfoEntry.name != null) {
2028 - (debugInfoEntry: ReactComponentInfo);
2028 + debugInfoEntry as ReactComponentInfo;
2029 // We're not transferring Component info since we use Component info
2030 // in Debug info to fill in gaps between Fibers for the parent stack.
2031 } else {
@@ -2112,7 +2112,7 @@ function getOutlinedModel<T>(
2112 errored: false,
2113 };
2114 }
2115 - return (null: any);
2115 + return null as any;
2116 }
2117 default: {
2118 // This is an error. Instead of erroring directly, we're going to encode this on
@@ -2131,7 +2131,7 @@ function getOutlinedModel<T>(
2131 errored: true,
2132 };
2133 }
2134 - return (null: any);
2134 + return null as any;
2135 }
2136 }
2137 }
@@ -2209,7 +2209,7 @@ function getOutlinedModel<T>(
2209 errored: false,
2210 };
2211 }
2212 - return (null: any);
2212 + return null as any;
2213 }
2214 default:
2215 // This is an error. Instead of erroring directly, we're going to encode this on
@@ -2229,7 +2229,7 @@ function getOutlinedModel<T>(
2229 };
2230 }
2231 // Placeholder
2232 - return (null: any);
2232 + return null as any;
2233 }
2234 }
2235
@@ -2651,7 +2651,7 @@ function parseModelTuple(
2651 response: Response,
2652 value: {+[key: string]: JSONValue} | $ReadOnlyArray<JSONValue>,
2653 ): any {
2654 - const tuple: [mixed, mixed, mixed, mixed] = (value: any);
2654 + const tuple: [mixed, mixed, mixed, mixed] = value as any;
2655
2656 if (tuple[0] === REACT_ELEMENT_TYPE) {
2657 // TODO: Consider having React just directly accept these arrays as elements.
@@ -2661,9 +2661,9 @@ function parseModelTuple(
2661 tuple[1],
2662 tuple[2],
2663 tuple[3],
2664 - __DEV__ ? (tuple: any)[4] : null,
2665 - __DEV__ ? (tuple: any)[5] : null,
2666 - __DEV__ ? (tuple: any)[6] : 0,
2664 + __DEV__ ? (tuple as any)[4] : null,
2665 + __DEV__ ? (tuple as any)[5] : null,
2666 + __DEV__ ? (tuple as any)[6] : 0,
2667 );
2668 }
2669 return value;
@@ -2730,7 +2730,7 @@ function ResponseInstance(
2730 ReactSharedInteralsServer === undefined ||
2731 ReactSharedInteralsServer.A === null
2732 ? null
2733 - : (ReactSharedInteralsServer.A.getOwner(): any);
2733 + : (ReactSharedInteralsServer.A.getOwner() as any);
2734
2735 this._debugRootOwner = rootOwner;
2736 this._debugRootStack =
@@ -2746,7 +2746,7 @@ function ResponseInstance(
2746 // elements created by the server. We use the "use server" string to indicate that
2747 // this is where we enter the server from the client.
2748 // TODO: Make this string configurable.
2749 - this._debugRootTask = (console: any).createTask(
2749 + this._debugRootTask = (console as any).createTask(
2750 '"use ' + rootEnv.toLowerCase() + '"',
2751 );
2752 }
@@ -2850,19 +2850,19 @@ export function createStreamState(
2850 weakResponse: WeakResponse, // DEV-only
2851 streamDebugValue: mixed, // DEV-only
2852 ): StreamState {
2853 - const streamState: StreamState = (({
2853 + const streamState: StreamState = {
2854 _rowState: 0,
2855 _rowID: 0,
2856 _rowTag: 0,
2857 _rowLength: 0,
2858 _buffer: [],
2859 - }: Omit<StreamState, '_debugInfo' | '_debugTargetChunkSize'>): any);
2859 + } as Omit<StreamState, '_debugInfo' | '_debugTargetChunkSize'> as any;
2860 if (__DEV__ && enableAsyncDebugInfo) {
2861 const response = unwrapWeakResponse(weakResponse);
2862 // Create an entry for the I/O to load the stream itself.
2863 const debugValuePromise = Promise.resolve(streamDebugValue);
2864 - (debugValuePromise: any).status = 'fulfilled';
2865 - (debugValuePromise: any).value = streamDebugValue;
2864 + (debugValuePromise as any).status = 'fulfilled';
2865 + (debugValuePromise as any).value = streamDebugValue;
2866 streamState._debugInfo = {
2867 name: 'rsc stream',
2868 start: response._debugStartTime,
@@ -2896,7 +2896,7 @@ function incrementChunkDebugInfo(
2896 const debugInfo: ReactIOInfo = streamState._debugInfo;
2897 const endTime = performance.now();
2898 const previousEndTime = debugInfo.end;
2899 - const newByteLength = ((debugInfo.byteSize: any): number) + chunkLength;
2899 + const newByteLength = (debugInfo.byteSize as any as number) + chunkLength;
2900 if (
2901 newByteLength > streamState._debugTargetChunkSize ||
2902 endTime > previousEndTime + 10
@@ -2942,7 +2942,7 @@ function addAsyncInfo(chunk: SomeChunk<any>, asyncInfo: ReactAsyncInfo): void {
2942 } else if (!Object.isFrozen(value)) {
2943 // TODO: Debug info is dropped for frozen elements. See the TODO in
2944 // moveDebugInfoFromChunkToInnerValue.
2945 - Object.defineProperty((value: any), '_debugInfo', {
2945 + Object.defineProperty(value as any, '_debugInfo', {
2946 configurable: false,
2947 enumerable: false,
2948 writable: true,
@@ -2988,7 +2988,7 @@ function resolveDebugHalt(response: Response, id: number): void {
2988 return;
2989 }
2990 releasePendingChunk(response, chunk);
2991 - const haltedChunk: HaltedChunk<any> = (chunk: any);
2991 + const haltedChunk: HaltedChunk<any> = chunk as any;
2992 haltedChunk.status = HALTED;
2993 haltedChunk.value = null;
2994 haltedChunk.reason = null;
@@ -3030,7 +3030,7 @@ function resolveText(
3030 if (chunk && chunk.status !== PENDING) {
3031 // If we get more data to an already resolved ID, we assume that it's
3032 // a stream chunk since any other row shouldn't have more than one entry.
3033 - const streamChunk: InitializedStreamChunk<any> = (chunk: any);
3033 + const streamChunk: InitializedStreamChunk<any> = chunk as any;
3034 const controller = streamChunk.reason;
3035 controller.enqueueValue(text);
3036 return;
@@ -3056,7 +3056,7 @@ function resolveBuffer(
3056 if (chunk && chunk.status !== PENDING) {
3057 // If we get more data to an already resolved ID, we assume that it's
3058 // a stream chunk since any other row shouldn't have more than one entry.
3059 - const streamChunk: InitializedStreamChunk<any> = (chunk: any);
3059 + const streamChunk: InitializedStreamChunk<any> = chunk as any;
3060 const controller = streamChunk.reason;
3061 controller.enqueueValue(buffer);
3062 return;
@@ -3109,7 +3109,7 @@ function resolveModule(
3109 releasePendingChunk(response, chunk);
3110 // This can't actually happen because we don't have any forward
3111 // references to modules.
3112 - blockedChunk = (chunk: any);
3112 + blockedChunk = chunk as any;
3113 blockedChunk.status = BLOCKED;
3114 }
3115 if (__DEV__) {
@@ -3171,7 +3171,7 @@ function resolveStream<T: ReadableStream | $AsyncIterable<any, any, void>>(
3171 const prevHandler = initializingHandler;
3172 const prevChunk = initializingChunk;
3173 initializingHandler = null;
3174 - const cyclicChunk: BlockedChunk<T> = (chunk: any);
3174 + const cyclicChunk: BlockedChunk<T> = chunk as any;
3175 cyclicChunk.status = BLOCKED;
3176 cyclicChunk.value = null;
3177 cyclicChunk.reason = null;
@@ -3198,12 +3198,12 @@ function resolveStream<T: ReadableStream | $AsyncIterable<any, any, void>>(
3198 }
3199 }
3200
3201 - const resolvedChunk: InitializedStreamChunk<T> = (chunk: any);
3201 + const resolvedChunk: InitializedStreamChunk<T> = chunk as any;
3202 resolvedChunk.status = INITIALIZED;
3203 resolvedChunk.value = stream;
3204 resolvedChunk.reason = controller;
3205 if (resolveListeners !== null) {
3206 - wakeChunk(response, resolveListeners, chunk.value, (chunk: any));
3206 + wakeChunk(response, resolveListeners, chunk.value, chunk as any);
3207 } else {
3208 if (__DEV__) {
3209 processChunkDebugInfo(response, resolvedChunk, stream);
@@ -3217,7 +3217,7 @@ function startReadableStream<T>(
3217 type: void | 'bytes',
3218 streamState: StreamState,
3219 ): void {
3220 - let controller: ReadableStreamController = (null: any);
3220 + let controller: ReadableStreamController = null as any;
3221 let closed = false;
3222 const stream = new ReadableStream({
3223 type: type,
@@ -3252,7 +3252,7 @@ function startReadableStream<T>(
3252 } else {
3253 chunk.then(
3254 v => controller.enqueue(v),
3255 - e => controller.error((e: any)),
3255 + e => controller.error(e as any),
3256 );
3257 previousBlockedChunk = chunk;
3258 }
@@ -3262,7 +3262,7 @@ function startReadableStream<T>(
3262 const chunk: SomeChunk<T> = createPendingChunk(response);
3263 chunk.then(
3264 v => controller.enqueue(v),
3265 - e => controller.error((e: any)),
3265 + e => controller.error(e as any),
3266 );
3267 previousBlockedChunk = chunk;
3268 blockedChunk.then(function () {
@@ -3301,7 +3301,7 @@ function startReadableStream<T>(
3301 const blockedChunk = previousBlockedChunk;
3302 // We shouldn't get any more enqueues after this so we can set it back to null.
3303 previousBlockedChunk = null;
3304 - blockedChunk.then(() => controller.error((error: any)));
3304 + blockedChunk.then(() => controller.error(error as any));
3305 }
3306 },
3307 };
@@ -3323,7 +3323,7 @@ function createIterator<T>(
3323 // TODO: The iterator could inherit the AsyncIterator prototype which is not exposed as
3324 // a global but exists as a prototype of an AsyncGenerator. However, it's not needed
3325 // to satisfy the iterable protocol.
3326 - (iterator: any)[ASYNC_ITERATOR] = asyncIterator;
3326 + (iterator as any)[ASYNC_ITERATOR] = asyncIterator;
3327 return iterator;
3328 }
3329
@@ -3345,13 +3345,13 @@ function startAsyncIterable<T>(
3345 false,
3346 );
3347 } else {
3348 - const chunk: PendingChunk<IteratorResult<T, T>> = (buffer[
3348 + const chunk: PendingChunk<IteratorResult<T, T>> = buffer[
3349 nextWriteIndex
3350 - ]: any);
3350 + ] as any;
3351 const resolveListeners = chunk.value;
3352 const rejectListeners = chunk.reason;
3353 const initializedChunk: InitializedChunk<IteratorResult<T, T>> =
3354 - (chunk: any);
3354 + chunk as any;
3355 initializedChunk.status = INITIALIZED;
3356 initializedChunk.value = {done: false, value: value};
3357 initializedChunk.reason = null;
@@ -3428,7 +3428,7 @@ function startAsyncIterable<T>(
3428 },
3429 };
3430
3431 - const iterable: $AsyncIterable<T, T, void> = ({}: any);
3431 + const iterable: $AsyncIterable<T, T, void> = {} as any;
3432 // $FlowFixMe[cannot-write]
3433 iterable[ASYNC_ITERATOR] = (): $AsyncIterator<T, T, void> => {
3434 let nextReadIndex = 0;
@@ -3484,7 +3484,7 @@ function stopStream(
3484 response._weakResponse.response = null;
3485 }
3486 }
3487 - const streamChunk: InitializedStreamChunk<any> = (chunk: any);
3487 + const streamChunk: InitializedStreamChunk<any> = chunk as any;
3488 const controller = streamChunk.reason;
3489 controller.close(row === '' ? '"$undefined"' : row);
3490 }
@@ -3533,7 +3533,7 @@ function resolveErrorDev(
3533 cause: reviveModel(
3534 response,
3535 // $FlowFixMe[incompatible-type] -- Flow thinks `cause` in `cause?: JSONValue` can be undefined after `in` check.
3536 - (errorInfo.cause: JSONValue),
3536 + errorInfo.cause as JSONValue,
3537 errorInfo,
3538 'cause',
3539 ),
@@ -3547,7 +3547,7 @@ function resolveErrorDev(
3547 ? reviveModel(
3548 response,
3549 // $FlowFixMe[incompatible-type]
3550 - (errorInfo.errors: JSONValue),
3550 + errorInfo.errors as JSONValue,
3551 errorInfo,
3552 'errors',
3553 )
@@ -3597,8 +3597,8 @@ function resolveErrorDev(
3597 error = ownerTask.run(callStack);
3598 }
3599
3600 - (error: any).name = name;
3601 - (error: any).environmentName = env;
3600 + (error as any).name = name;
3601 + (error as any).environmentName = env;
3602 return error;
3603 }
3604
@@ -3617,8 +3617,8 @@ function resolveErrorModel(
3617 } else {
3618 error = resolveErrorProd(response);
3619 }
3620 - (error: any).digest = errorInfo.digest;
3621 - const errorWithDigest: ErrorWithDigest = (error: any);
3620 + (error as any).digest = errorInfo.digest;
3621 + const errorWithDigest: ErrorWithDigest = error as any;
3622 if (!chunk) {
3623 const newChunk: ErroredChunk<any> = createErrorChunk(
3624 response,
@@ -3645,12 +3645,12 @@ function resolveHint<Code: HintCode>(
3645 dispatchHint(code, hintModel);
3646 }
3647
3648 -const supportsCreateTask = __DEV__ && !!(console: any).createTask;
3648 +const supportsCreateTask = __DEV__ && !!(console as any).createTask;
3649
3650 type FakeFunction<T> = (() => T) => T;
3651 const fakeFunctionCache: Map<string, FakeFunction<any>> = __DEV__
3652 ? new Map()
3653 - : (null: any);
3653 + : (null as any);
3654
3655 let fakeFunctionIdx = 0;
3656 function createFakeFunction<T>(
@@ -3882,7 +3882,7 @@ function getRootTask(
3882 // If the root most owner component is itself in a different environment than the requested
3883 // environment then we create an extra task to indicate that we're transitioning into it.
3884 // Like if one environment just requests another environment.
3885 - const createTaskFn = (console: any).createTask.bind(
3885 + const createTaskFn = (console as any).createTask.bind(
3886 console,
3887 '"use ' + childEnvironmentName.toLowerCase() + '"',
3888 );
@@ -3935,10 +3935,10 @@ function initializeFakeTask(
3935 ? '"use ' + env.toLowerCase() + '"'
3936 : // Some unfortunate pattern matching to refine the type.
3937 debugInfo.key !== undefined
3938 - ? getServerComponentTaskName(((debugInfo: any): ReactComponentInfo))
3938 + ? getServerComponentTaskName(debugInfo as any as ReactComponentInfo)
3939 : debugInfo.name !== undefined
3940 - ? getIOInfoTaskName(((debugInfo: any): ReactIOInfo))
3941 - : getAsyncInfoTaskName(((debugInfo: any): ReactAsyncInfo));
3940 + ? getIOInfoTaskName(debugInfo as any as ReactIOInfo)
3941 + : getAsyncInfoTaskName(debugInfo as any as ReactAsyncInfo);
3942 // $FlowFixMe[cannot-write]: We consider this part of initialization.
3943 return (debugInfo.debugTask = buildFakeTask(
3944 response,
@@ -3958,7 +3958,7 @@ function buildFakeTask(
3958 env: string,
3959 useEnclosingLine: boolean,
3960 ): ConsoleTask {
3961 - const createTaskFn = (console: any).createTask.bind(console, taskName);
3961 + const createTaskFn = (console as any).createTask.bind(console, taskName);
3962 const callStack = buildFakeCallStack(
3963 response,
3964 stack,
@@ -4003,8 +4003,8 @@ const createFakeJSXCallStackInDEV: (
4003 ? // We use this technique to trick minifiers to preserve the function name.
4004 (createFakeJSXCallStack.react_stack_bottom_frame.bind(
4005 createFakeJSXCallStack,
4006 - ): any)
4007 - : (null: any);
4006 + ) as any)
4007 + : (null as any);
4008
4009 /** @noinline */
4010 function fakeJSXCallSite() {
@@ -4120,7 +4120,7 @@ function resolveDebugModel(
4120 initializeDebugChunk(response, parentChunk);
4121 if (
4122 __DEV__ &&
4123 - ((debugChunk: any): SomeChunk<any>).status === BLOCKED &&
4123 + (debugChunk as any as SomeChunk<any>).status === BLOCKED &&
4124 (response._debugChannel === undefined ||
4125 !response._debugChannel.hasReadable)
4126 ) {
@@ -4167,7 +4167,7 @@ const replayConsoleWithCallStack = {
4167 const prevStack = ReactSharedInternals.getCurrentStack;
4168 ReactSharedInternals.getCurrentStack = getCurrentStackInDEV;
4169 currentOwnerInDEV =
4170 - owner === null ? (response._debugRootOwner: any) : owner;
4170 + owner === null ? (response._debugRootOwner as any) : owner;
4171
4172 try {
4173 const callStack = buildFakeCallStack(
@@ -4205,8 +4205,8 @@ const replayConsoleWithCallStackInDEV: (
4205 ? // We use this technique to trick minifiers to preserve the function name.
4206 (replayConsoleWithCallStack.react_stack_bottom_frame.bind(
4207 replayConsoleWithCallStack,
4208 - ): any)
4209 - : (null: any);
4208 + ) as any)
4209 + : (null as any);
4210
4211 type ConsoleEntry = [
4212 string,
@@ -4290,7 +4290,7 @@ function initializeIOInfo(response: Response, ioInfo: ReactIOInfo): void {
4290 const env = response._rootEnvironmentName;
4291 const promise = ioInfo.value;
4292 if (promise) {
4293 - const thenable: Thenable<mixed> = (promise: any);
4293 + const thenable: Thenable<mixed> = promise as any;
4294 switch (thenable.status) {
4295 case INITIALIZED:
4296 logIOInfo(ioInfo, env, thenable.value);
@@ -4621,7 +4621,7 @@ function flushComponentPerformance(
4621 const env = response._rootEnvironmentName;
4622 const promise = asyncInfo.awaited.value;
4623 if (promise) {
4624 - const thenable: Thenable<mixed> = (promise: any);
4624 + const thenable: Thenable<mixed> = promise as any;
4625 switch (thenable.status) {
4626 case INITIALIZED:
4627 logComponentAwait(
@@ -4889,7 +4889,7 @@ function processFullStringRow(
4889 return;
4890 }
4891 case 72 /* "H" */: {
4892 - const code: HintCode = (row[0]: any);
4892 + const code: HintCode = row[0] as any;
4893 resolveHint(response, code, row.slice(1));
4894 return;
4895 }
@@ -5323,7 +5323,7 @@ function reviveModel(
5323 }
5324 if (isArray(value)) {
5325 for (let i = 0; i < value.length; i++) {
5326 - (value: any)[i] = reviveModel(response, value[i], value, '' + i);
5326 + (value as any)[i] = reviveModel(response, value[i], value, '' + i);
5327 }
5328 // $FlowFixMe[invalid-compare]
5329 if (value[0] === REACT_ELEMENT_TYPE) {
@@ -5335,13 +5335,13 @@ function reviveModel(
5335 // Plain object
5336 for (const k in value) {
5337 if (k === __PROTO__) {
5338 - delete (value: any)[k];
5338 + delete (value as any)[k];
5339 } else {
5340 - const walked = reviveModel(response, (value: any)[k], value, k);
5340 + const walked = reviveModel(response, (value as any)[k], value, k);
5341 if (walked !== undefined) {
5342 - (value: any)[k] = walked;
5342 + (value as any)[k] = walked;
5343 } else {
5344 - delete (value: any)[k];
5344 + delete (value as any)[k];
5345 }
5346 }
5347 }
@@ -5366,7 +5366,7 @@ export function close(weakResponse: WeakResponse): void {
5366 // Clear listeners to release closures and transition to HALTED.
5367 // Future .then() calls on HALTED chunks are no-ops.
5368 releasePendingChunk(response, chunk);
5369 - const haltedChunk: HaltedChunk<any> = (chunk: any);
5369 + const haltedChunk: HaltedChunk<any> = chunk as any;
5370 haltedChunk.status = HALTED;
5371 haltedChunk.value = null;
5372 haltedChunk.reason = null;
packages/react-client/src/ReactFlightReplyClient.js
+22 -21
@@ -415,7 +415,7 @@ export function processReply(
415 }
416
417 if (typeof value === 'object') {
418 - switch ((value: any).$$typeof) {
418 + switch ((value as any).$$typeof) {
419 case REACT_ELEMENT_TYPE: {
420 if (temporaryReferences !== undefined && key.indexOf(':') === -1) {
421 // TODO: If the property name contains a colon, we don't dedupe. Escape instead.
@@ -445,7 +445,7 @@ export function processReply(
445 }
446 case REACT_LAZY_TYPE: {
447 // Resolve lazy as if it wasn't here. In the future this will be encoded as a Promise.
448 - const lazy: LazyComponent<any, any> = (value: any);
448 + const lazy: LazyComponent<any, any> = value as any;
449 const payload = lazy._payload;
450 const init = lazy._init;
451 if (formData === null) {
@@ -472,7 +472,7 @@ export function processReply(
472 // Suspended
473 pendingParts++;
474 const lazyId = nextPartId++;
475 - const thenable: Thenable<any> = (x: any);
475 + const thenable: Thenable<any> = x as any;
476 const retry = function () {
477 // While the first promise resolved, its value isn't necessarily what we'll
478 // resolve into because we might suspend again.
@@ -529,7 +529,7 @@ export function processReply(
529 const promiseId = nextPartId++;
530 const promiseReference = serializePromiseID(promiseId);
531 writtenObjects.set(value, promiseReference);
532 - const thenable: Thenable<any> = (value: any);
532 + const thenable: Thenable<any> = value as any;
533 thenable.then(
534 partValue => {
535 try {
@@ -702,7 +702,7 @@ export function processReply(
702 // Iterator, not Iterable
703 const iteratorId = nextPartId++;
704 const partJSON = serializeModel(
705 - Array.from((iterator: any)),
705 + Array.from(iterator as any),
706 iteratorId,
707 );
708 if (formData === null) {
@@ -711,7 +711,7 @@ export function processReply(
711 formData.append(formFieldPrefix + iteratorId, partJSON);
712 return serializeIteratorID(iteratorId);
713 }
714 - return Array.from((iterator: any));
714 + return Array.from(iterator as any);
715 }
716
717 // TODO: ReadableStream is not available in old Node. Remove the typeof check later.
@@ -721,13 +721,14 @@ export function processReply(
721 ) {
722 return serializeReadableStream(value);
723 }
724 - const getAsyncIterator: void | (() => $AsyncIterator<any, any, any>) =
725 - (value: any)[ASYNC_ITERATOR];
724 + const getAsyncIterator: void | (() => $AsyncIterator<any, any, any>) = (
725 + value as any
726 + )[ASYNC_ITERATOR];
727 if (typeof getAsyncIterator === 'function') {
728 // We treat AsyncIterables as a Fragment and as such we might need to key them.
729 return serializeAsyncIterable(
729 - (value: any),
730 - getAsyncIterator.call((value: any)),
730 + value as any,
731 + getAsyncIterator.call(value as any),
732 );
733 }
734
@@ -749,7 +750,7 @@ export function processReply(
750 return serializeTemporaryReferenceMarker();
751 }
752 if (__DEV__) {
752 - if ((value: any).$$typeof === REACT_CONTEXT_TYPE) {
753 + if ((value as any).$$typeof === REACT_CONTEXT_TYPE) {
754 console.error(
755 'React Context Providers cannot be passed to Server Functions from the Client.%s',
756 describeObjectForErrorMessage(parent, key),
@@ -945,13 +946,13 @@ function encodeFormData(reference: any): Thenable<FormData> {
946 data.append('0', body);
947 body = data;
948 }
948 - const fulfilled: FulfilledThenable<FormData> = (thenable: any);
949 + const fulfilled: FulfilledThenable<FormData> = thenable as any;
950 fulfilled.status = 'fulfilled';
951 fulfilled.value = body;
952 resolve(body);
953 },
954 e => {
954 - const rejected: RejectedThenable<FormData> = (thenable: any);
955 + const rejected: RejectedThenable<FormData> = thenable as any;
956 rejected.status = 'rejected';
957 rejected.reason = e;
958 reject(e);
@@ -1023,7 +1024,7 @@ function customEncodeFormAction(
1024 'This is a bug in React.',
1025 );
1026 }
1026 - let boundPromise: Promise<Array<any>> = (referenceClosure.bound: any);
1027 + let boundPromise: Promise<Array<any>> = referenceClosure.bound as any;
1028 // $FlowFixMe[invalid-compare]
1029 if (boundPromise === null) {
1030 boundPromise = Promise.resolve([]);
@@ -1072,18 +1073,18 @@ function isSignatureEqual(
1073 // Only instrument the thenable if the status if not defined.
1074 } else {
1075 const pendingThenable: PendingThenable<Array<any>> =
1075 - (boundPromise: any);
1076 + boundPromise as any;
1077 pendingThenable.status = 'pending';
1078 pendingThenable.then(
1079 (boundArgs: Array<any>) => {
1080 const fulfilledThenable: FulfilledThenable<Array<any>> =
1080 - (boundPromise: any);
1081 + boundPromise as any;
1082 fulfilledThenable.status = 'fulfilled';
1083 fulfilledThenable.value = boundArgs;
1084 },
1085 (error: mixed) => {
1086 const rejectedThenable: RejectedThenable<number> =
1086 - (boundPromise: any);
1087 + boundPromise as any;
1088 rejectedThenable.status = 'rejected';
1089 rejectedThenable.reason = error;
1090 },
@@ -1220,7 +1221,7 @@ export function registerBoundServerReference<T: Function>(
1221 encodeFormAction,
1222 );
1223 };
1223 - Object.defineProperties((reference: any), {
1224 + Object.defineProperties(reference as any, {
1225 $$FORM_ACTION: {value: $$FORM_ACTION},
1226 $$IS_SIGNATURE_EQUAL: {value: isSignatureEqual},
1227 bind: {value: bind},
@@ -1266,7 +1267,7 @@ function bind(this: Function): Function {
1267 const args = ArraySlice.call(arguments, 1);
1268 let boundPromise = null;
1269 if (referenceClosure.bound !== null) {
1269 - boundPromise = Promise.resolve((referenceClosure.bound: any)).then(
1270 + boundPromise = Promise.resolve(referenceClosure.bound as any).then(
1271 boundArgs => boundArgs.concat(args),
1272 );
1273 } else {
@@ -1284,7 +1285,7 @@ function bind(this: Function): Function {
1285 // $FlowFixMe[constant-condition]
1286 if (usedWithSSR) {
1287 // Only expose this in builds that would actually use it. Not needed on the client.
1287 - Object.defineProperties((newFn: any), {
1288 + Object.defineProperties(newFn as any, {
1289 $$FORM_ACTION: {value: this.$$FORM_ACTION},
1290 $$IS_SIGNATURE_EQUAL: {value: isSignatureEqual},
1291 bind: {value: bind},
@@ -1326,7 +1327,7 @@ export function createBoundServerReference<A: Iterable<any>, T>(
1327 }
1328 // Since this is a fake Promise whose .then doesn't chain, we have to wrap it.
1329 // TODO: Remove the wrapper once that's fixed.
1329 - return ((Promise.resolve(p): any): Promise<Array<any>>).then(
1330 + return (Promise.resolve(p) as any as Promise<Array<any>>).then(
1331 function (boundArgs) {
1332 return callServer(id, boundArgs.concat(args));
1333 },
packages/react-client/src/ReactFlightTemporaryReferences.js
+1 -1
@@ -27,5 +27,5 @@ export function readTemporaryReference<T>(
27 set: TemporaryReferenceSet,
28 reference: string,
29 ): T {
30 - return (set.get(reference): any);
30 + return set.get(reference) as any;
31 }
packages/react-debug-tools/src/ReactDebugHooks.js
+28 -32
@@ -74,7 +74,7 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
74 let readHookLog;
75 try {
76 // Use all hooks here to add them to the hook log.
77 - Dispatcher.useContext(({_currentValue: null}: any));
77 + Dispatcher.useContext({_currentValue: null} as any);
78 Dispatcher.useState(null);
79 Dispatcher.useReducer((s: mixed, a: mixed) => s, null);
80 Dispatcher.useRef(null);
@@ -106,23 +106,19 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
106 }
107 if (typeof Dispatcher.use === 'function') {
108 // This type check is for Flow only.
109 - Dispatcher.use(
110 - ({
111 - $$typeof: REACT_CONTEXT_TYPE,
112 - _currentValue: null,
113 - }: any),
114 - );
109 + Dispatcher.use({
110 + $$typeof: REACT_CONTEXT_TYPE,
111 + _currentValue: null,
112 + } as any);
113 Dispatcher.use({
114 then() {},
115 status: 'fulfilled',
116 value: null,
117 });
118 try {
121 - Dispatcher.use(
122 - ({
123 - then() {},
124 - }: any),
125 - );
119 + Dispatcher.use({
120 + then() {},
121 + } as any);
122 } catch (x) {}
123 }
124
@@ -174,7 +170,7 @@ function readContext<T>(context: ReactContext<T>): T {
170 // For now we don't expose readContext usage in the hooks debugging info.
171 if (hasOwnProperty.call(currentContextDependency, 'memoizedValue')) {
172 // $FlowFixMe[incompatible-use] Flow thinks `hasOwnProperty` mutates `currentContextDependency`
177 - value = ((currentContextDependency.memoizedValue: any): T);
173 + value = currentContextDependency.memoizedValue as any as T;
174
175 // $FlowFixMe[incompatible-use] Flow thinks `hasOwnProperty` mutates `currentContextDependency`
176 currentContextDependency = currentContextDependency.next;
@@ -211,7 +207,7 @@ function use<T>(usable: Usable<T>): T {
207 currentThenableState !== null &&
208 currentThenableIndex < currentThenableState.length
209 ? currentThenableState[currentThenableIndex++]
214 - : (usable: any);
210 + : (usable as any);
211
212 switch (thenable.status) {
213 case 'fulfilled': {
@@ -245,7 +241,7 @@ function use<T>(usable: Usable<T>): T {
241 });
242 throw SuspenseException;
243 } else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
248 - const context: ReactContext<T> = (usable: any);
244 + const context: ReactContext<T> = usable as any;
245 const value = readContext(context);
246
247 hookLog.push({
@@ -310,7 +306,7 @@ function useReducer<S, I, A>(
306 if (hook !== null) {
307 state = hook.memoizedState;
308 } else {
313 - state = init !== undefined ? init(initialArg) : ((initialArg: any): S);
309 + state = init !== undefined ? init(initialArg) : (initialArg as any as S);
310 }
311 hookLog.push({
312 displayName: null,
@@ -608,7 +604,7 @@ function useFormState<S, P>(
604 // $FlowFixMe[method-unbinding]
605 typeof actionResult.then === 'function'
606 ) {
611 - const thenable: Thenable<Awaited<S>> = (actionResult: any);
607 + const thenable: Thenable<Awaited<S>> = actionResult as any;
608 switch (thenable.status) {
609 case 'fulfilled': {
610 value = thenable.value;
@@ -630,7 +626,7 @@ function useFormState<S, P>(
626 value = thenable;
627 }
628 } else {
633 - value = (actionResult: any);
629 + value = actionResult as any;
630 }
631 } else {
632 value = initialState;
@@ -651,7 +647,7 @@ function useFormState<S, P>(
647
648 // value being a Thenable is equivalent to error being not null
649 // i.e. we only reach this point with Awaited<S>
654 - const state = ((value: any): Awaited<S>);
650 + const state = value as any as Awaited<S>;
651
652 // TODO: support displaying pending value
653 return [state, (payload: P) => {}, false];
@@ -678,7 +674,7 @@ function useActionState<S, P>(
674 // $FlowFixMe[method-unbinding]
675 typeof actionResult.then === 'function'
676 ) {
681 - const thenable: Thenable<Awaited<S>> = (actionResult: any);
677 + const thenable: Thenable<Awaited<S>> = actionResult as any;
678 switch (thenable.status) {
679 case 'fulfilled': {
680 value = thenable.value;
@@ -700,7 +696,7 @@ function useActionState<S, P>(
696 value = thenable;
697 }
698 } else {
703 - value = (actionResult: any);
699 + value = actionResult as any;
700 }
701 } else {
702 value = initialState;
@@ -721,7 +717,7 @@ function useActionState<S, P>(
717
718 // value being a Thenable is equivalent to error being not null
719 // i.e. we only reach this point with Awaited<S>
724 - const state = ((value: any): Awaited<S>);
720 + const state = value as any as Awaited<S>;
721
722 // TODO: support displaying pending value
723 return [state, (payload: P) => {}, false];
@@ -731,10 +727,10 @@ function useHostTransitionStatus(): TransitionStatus {
727 const status = readContext<TransitionStatus>(
728 // $FlowFixMe[prop-missing] `readContext` only needs _currentValue
729 // $FlowFixMe[incompatible-type]
734 - ({
730 + {
731 // $FlowFixMe[incompatible-type] TODO: Incorrect bottom value without access to Fiber config.
732 _currentValue: null,
737 - }: ReactContext<TransitionStatus>),
733 + } as ReactContext<TransitionStatus>,
734 );
735
736 hookLog.push({
@@ -1228,7 +1224,7 @@ export function inspectHooks<Props>(
1224 }
1225 const rootStack =
1226 ancestorStackError === undefined
1231 - ? ([]: ParsedStackFrame[])
1227 + ? ([] as Array<ParsedStackFrame>)
1228 : ErrorStackParser.parse(ancestorStackError);
1229 return buildTree(rootStack, readHookLog);
1230 }
@@ -1238,9 +1234,9 @@ function setupContexts(contextMap: Map<ReactContext<any>, any>, fiber: Fiber) {
1234 while (current) {
1235 if (current.tag === ContextProvider) {
1236 let context: ReactContext<any> = current.type;
1241 - if ((context: any)._context !== undefined) {
1237 + if ((context as any)._context !== undefined) {
1238 // Support inspection of pre-19+ providers.
1243 - context = (context: any)._context;
1239 + context = (context as any)._context;
1240 }
1241 if (!contextMap.has(context)) {
1242 // Store the current value that we're going to restore later.
@@ -1279,7 +1275,7 @@ function inspectHooksOfForwardRef<Props, Ref>(
1275 }
1276 const rootStack =
1277 ancestorStackError === undefined
1282 - ? ([]: ParsedStackFrame[])
1278 + ? ([] as Array<ParsedStackFrame>)
1279 : ErrorStackParser.parse(ancestorStackError);
1280 return buildTree(rootStack, readHookLog);
1281 }
@@ -1324,7 +1320,7 @@ export function inspectHooksOfFiber(
1320
1321 // Set up the current hook so that we can step through and read the
1322 // current state from them.
1327 - currentHook = (fiber.memoizedState: Hook);
1323 + currentHook = fiber.memoizedState as Hook;
1324 currentFiber = fiber;
1325 const thenableState =
1326 fiber.dependencies && fiber.dependencies._debugThenableState;
@@ -1341,17 +1337,17 @@ export function inspectHooksOfFiber(
1337 currentContextDependency =
1338 dependencies !== null ? dependencies.firstContext : null;
1339 } else if (hasOwnProperty.call(currentFiber, 'dependencies_old')) {
1344 - const dependencies: Dependencies = (currentFiber: any).dependencies_old;
1340 + const dependencies: Dependencies = (currentFiber as any).dependencies_old;
1341 currentContextDependency =
1342 // $FlowFixMe[invalid-compare]
1343 dependencies !== null ? dependencies.firstContext : null;
1344 } else if (hasOwnProperty.call(currentFiber, 'dependencies_new')) {
1349 - const dependencies: Dependencies = (currentFiber: any).dependencies_new;
1345 + const dependencies: Dependencies = (currentFiber as any).dependencies_new;
1346 currentContextDependency =
1347 // $FlowFixMe[invalid-compare]
1348 dependencies !== null ? dependencies.firstContext : null;
1349 } else if (hasOwnProperty.call(currentFiber, 'contextDependencies')) {
1354 - const contextDependencies = (currentFiber: any).contextDependencies;
1350 + const contextDependencies = (currentFiber as any).contextDependencies;
1351 currentContextDependency =
1352 contextDependencies !== null ? contextDependencies.first : null;
1353 } else {
packages/react-devtools-core/src/backend.js
+23 -31
@@ -99,7 +99,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
99 useHttps = false,
100 port = 8097,
101 websocket,
102 - resolveRNStyle = (null: $FlowFixMe),
102 + resolveRNStyle = null as $FlowFixMe,
103 retryConnectionDelay = 2000,
104 isAppActive = () => true,
105 onSettingsUpdated,
@@ -217,7 +217,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
217 bridge,
218 agent,
219 // $FlowFixMe[constant-condition]
220 - ((resolveRNStyle || hook.resolveRNStyle: any): ResolveNativeStyle),
220 + (resolveRNStyle || hook.resolveRNStyle) as any as ResolveNativeStyle,
221 nativeStyleEditorValidAttributes ||
222 hook.nativeStyleEditorValidAttributes ||
223 null,
@@ -241,36 +241,28 @@ export function connectToDevTools(options: ?ConnectOptions) {
241 };
242
243 if (!hook.hasOwnProperty('resolveRNStyle')) {
244 - Object.defineProperty(
245 - hook,
246 - 'resolveRNStyle',
247 - ({
248 - enumerable: false,
249 - get() {
250 - return lazyResolveRNStyle;
251 - },
252 - set(value: $FlowFixMe) {
253 - lazyResolveRNStyle = value;
254 - initAfterTick();
255 - },
256 - }: Object),
257 - );
244 + Object.defineProperty(hook, 'resolveRNStyle', {
245 + enumerable: false,
246 + get() {
247 + return lazyResolveRNStyle;
248 + },
249 + set(value: $FlowFixMe) {
250 + lazyResolveRNStyle = value;
251 + initAfterTick();
252 + },
253 + } as Object);
254 }
255 if (!hook.hasOwnProperty('nativeStyleEditorValidAttributes')) {
260 - Object.defineProperty(
261 - hook,
262 - 'nativeStyleEditorValidAttributes',
263 - ({
264 - enumerable: false,
265 - get() {
266 - return lazyNativeStyleEditorValidAttributes;
267 - },
268 - set(value: $FlowFixMe) {
269 - lazyNativeStyleEditorValidAttributes = value;
270 - initAfterTick();
271 - },
272 - }: Object),
273 - );
256 + Object.defineProperty(hook, 'nativeStyleEditorValidAttributes', {
257 + enumerable: false,
258 + get() {
259 + return lazyNativeStyleEditorValidAttributes;
260 + },
261 + set(value: $FlowFixMe) {
262 + lazyNativeStyleEditorValidAttributes = value;
263 + initAfterTick();
264 + },
265 + } as Object);
266 }
267 }
268 };
@@ -311,7 +303,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
303 }
304 } catch (e) {
305 console.error(
314 - '[React DevTools] Failed to parse JSON: ' + (event.data: any),
306 + '[React DevTools] Failed to parse JSON: ' + (event.data as any),
307 );
308 return;
309 }
packages/react-devtools-core/src/standalone.js
+4 -4
@@ -32,7 +32,7 @@ export type StatusTypes = 'server-connected' | 'devtools-connected' | 'error';
32 export type StatusListener = (message: string, status: StatusTypes) => void;
33 export type OnDisconnectedCallback = () => void;
34
35 -let node: HTMLElement = ((null: any): HTMLElement);
35 +let node: HTMLElement = null as any as HTMLElement;
36 let nodeWaitingToConnectHTML: string = '';
37 let projectRoots: Array<string> = [];
38 let statusListener: StatusListener = (
@@ -112,11 +112,11 @@ function reload() {
112 root = createRoot(node);
113 root.render(
114 createElement(DevTools, {
115 - bridge: ((bridge: any): FrontendBridge),
115 + bridge: bridge as any as FrontendBridge,
116 canViewElementSourceFunction,
117 hookNamesModuleLoaderFunction,
118 showTabBar: true,
119 - store: ((store: any): Store),
119 + store: store as any as Store,
120 warnIfLegacyBackendDetected: true,
121 viewElementSourceFunction,
122 fetchFileWithCaching,
@@ -263,7 +263,7 @@ function initialize(socket: WebSocket) {
263 }
264 },
265 });
266 - ((bridge: any): FrontendBridge).addListener('shutdown', () => {
266 + (bridge as any as FrontendBridge).addListener('shutdown', () => {
267 socket.close();
268 });
269
packages/react-devtools-extensions/src/main/index.js
+15 -15
@@ -486,10 +486,10 @@ function performInTabNavigationCleanup() {
486 // Do not clean mostRecentOverrideTab on purpose, so we remember last opened
487 // React DevTools tab, when user does in-tab navigation
488
489 - store = (null: $FlowFixMe);
490 - bridge = (null: $FlowFixMe);
491 - render = (null: $FlowFixMe);
492 - root = (null: $FlowFixMe);
489 + store = null as $FlowFixMe;
490 + bridge = null as $FlowFixMe;
491 + render = null as $FlowFixMe;
492 + root = null as $FlowFixMe;
493 }
494
495 function performFullCleanup() {
@@ -511,15 +511,15 @@ function performFullCleanup() {
511 componentsPortalContainer = null;
512 profilerPortalContainer = null;
513 suspensePortalContainer = null;
514 - root = (null: $FlowFixMe);
514 + root = null as $FlowFixMe;
515
516 mostRecentOverrideTab = null;
517 - store = (null: $FlowFixMe);
518 - bridge = (null: $FlowFixMe);
519 - render = (null: $FlowFixMe);
517 + store = null as $FlowFixMe;
518 + bridge = null as $FlowFixMe;
519 + render = null as $FlowFixMe;
520
521 port?.disconnect();
522 - port = (null: $FlowFixMe);
522 + port = null as $FlowFixMe;
523 }
524
525 function connectExtensionPort(): void {
@@ -546,7 +546,7 @@ function connectExtensionPort(): void {
546 // so, when we call `port.disconnect()` from this script,
547 // this should not trigger this callback and port reconnection
548 port.onDisconnect.addListener(() => {
549 - port = (null: $FlowFixMe);
549 + port = null as $FlowFixMe;
550 connectExtensionPort();
551 });
552 }
@@ -599,9 +599,9 @@ function mountReactDevToolsWhenReactHasLoaded() {
599 );
600 }
601
602 -let bridge: FrontendBridge = (null: $FlowFixMe);
602 +let bridge: FrontendBridge = null as $FlowFixMe;
603 let lastSubscribedBridgeListener = null;
604 -let store: Store = (null: $FlowFixMe);
604 +let store: Store = null as $FlowFixMe;
605
606 let profilingData = null;
607
@@ -617,12 +617,12 @@ let editorPortalContainer = null;
617 let inspectedElementPortalContainer = null;
618
619 let mostRecentOverrideTab: null | TabID = null;
620 -let render: (overrideTab?: TabID) => void = (null: $FlowFixMe);
621 -let root: RootType = (null: $FlowFixMe);
620 +let render: (overrideTab?: TabID) => void = null as $FlowFixMe;
621 +let root: RootType = null as $FlowFixMe;
622
623 let currentSelectedSource: null | SourceSelection = null;
624
625 -let port: ExtensionRuntimePort = (null: $FlowFixMe);
625 +let port: ExtensionRuntimePort = null as $FlowFixMe;
626
627 // In case when multiple navigation events emitted in a short period of time
628 // This debounced callback primarily used to avoid mounting React DevTools multiple times, which results
packages/react-devtools-inline/src/backend.js
+1 -1
@@ -109,7 +109,7 @@ export function createBridge(contentWindow: any, wall?: Wall): BackendBridge {
109 };
110 }
111
112 - return (new Bridge(wall): BackendBridge);
112 + return new Bridge(wall) as BackendBridge;
113 }
114
115 export function initialize(contentWindow: any): void {
packages/react-devtools-inline/src/frontend.js
+2 -2
@@ -40,7 +40,7 @@ export function createBridge(contentWindow: any, wall?: Wall): FrontendBridge {
40 };
41 }
42
43 - return (new Bridge(wall): FrontendBridge);
43 + return new Bridge(wall) as FrontendBridge;
44 }
45
46 export function initialize(
@@ -58,7 +58,7 @@ export function initialize(
58 }
59
60 // Type refinement.
61 - const frontendBridge = ((bridge: any): FrontendBridge);
61 + const frontendBridge = bridge as any as FrontendBridge;
62
63 if (store == null) {
64 store = createStore(frontendBridge);
packages/react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor.js
+30 -42
@@ -97,14 +97,11 @@ function measureStyle(
97 ) {
98 const data = agent.getInstanceAndStyle({id, rendererID});
99 if (!data || !data.style) {
100 - bridge.send(
101 - 'NativeStyleEditor_styleAndLayout',
102 - ({
103 - id,
104 - layout: null,
105 - style: null,
106 - }: StyleAndLayout),
107 - );
100 + bridge.send('NativeStyleEditor_styleAndLayout', {
101 + id,
102 + layout: null,
103 + style: null,
104 + } as StyleAndLayout);
105 return;
106 }
107
@@ -119,14 +116,11 @@ function measureStyle(
116 }
117
118 if (!instance || typeof instance.measure !== 'function') {
122 - bridge.send(
123 - 'NativeStyleEditor_styleAndLayout',
124 - ({
125 - id,
126 - layout: null,
127 - style: resolvedStyle || null,
128 - }: StyleAndLayout),
129 - );
119 + bridge.send('NativeStyleEditor_styleAndLayout', {
120 + id,
121 + layout: null,
122 + style: resolvedStyle || null,
123 + } as StyleAndLayout);
124 return;
125 }
126
@@ -134,14 +128,11 @@ function measureStyle(
128 // RN Android sometimes returns undefined here. Don't send measurements in this case.
129 // https://github.com/jhen0409/react-native-debugger/issues/84#issuecomment-304611817
130 if (typeof x !== 'number') {
137 - bridge.send(
138 - 'NativeStyleEditor_styleAndLayout',
139 - ({
140 - id,
141 - layout: null,
142 - style: resolvedStyle || null,
143 - }: StyleAndLayout),
144 - );
131 + bridge.send('NativeStyleEditor_styleAndLayout', {
132 + id,
133 + layout: null,
134 + style: resolvedStyle || null,
135 + } as StyleAndLayout);
136 return;
137 }
138 const margin =
@@ -150,23 +141,20 @@ function measureStyle(
141 const padding =
142 (resolvedStyle != null && resolveBoxStyle('padding', resolvedStyle)) ||
143 EMPTY_BOX_STYLE;
153 - bridge.send(
154 - 'NativeStyleEditor_styleAndLayout',
155 - ({
156 - id,
157 - layout: {
158 - x,
159 - y,
160 - width,
161 - height,
162 - left,
163 - top,
164 - margin,
165 - padding,
166 - },
167 - style: resolvedStyle || null,
168 - }: StyleAndLayout),
169 - );
144 + bridge.send('NativeStyleEditor_styleAndLayout', {
145 + id,
146 + layout: {
147 + x,
148 + y,
149 + width,
150 + height,
151 + left,
152 + top,
153 + margin,
154 + padding,
155 + },
156 + style: resolvedStyle || null,
157 + } as StyleAndLayout);
158 });
159 }
160
@@ -194,7 +182,7 @@ function renameStyle(
182 const {instance, style} = data;
183
184 const newStyle = newName
197 - ? {[oldName]: (undefined: string | void), [newName]: value}
185 + ? {[oldName]: undefined as string | void, [newName]: value}
186 : {[oldName]: undefined};
187
188 let customStyle;
packages/react-devtools-shared/src/backend/StyleX/utils.js
+4 -4
@@ -82,7 +82,7 @@ function crawlObjectProperties(
82
83 function getPropertyValueForStyleName(styleName: string): string | null {
84 if (cachedStyleNameToValueMap.has(styleName)) {
85 - return ((cachedStyleNameToValueMap.get(styleName): any): string);
85 + return cachedStyleNameToValueMap.get(styleName) as any as string;
86 }
87
88 for (
@@ -90,9 +90,9 @@ function getPropertyValueForStyleName(styleName: string): string | null {
90 styleSheetIndex < document.styleSheets.length;
91 styleSheetIndex++
92 ) {
93 - const styleSheet = ((document.styleSheets[
93 + const styleSheet = document.styleSheets[
94 styleSheetIndex
95 - ]: any): CSSStyleSheet);
95 + ] as any as CSSStyleSheet;
96 let rules: CSSRuleList | null = null;
97 // this might throw if CORS rules are enforced https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
98 try {
@@ -105,7 +105,7 @@ function getPropertyValueForStyleName(styleName: string): string | null {
105 if (!(rules[ruleIndex] instanceof CSSStyleRule)) {
106 continue;
107 }
108 - const rule = ((rules[ruleIndex]: any): CSSStyleRule);
108 + const rule = rules[ruleIndex] as any as CSSStyleRule;
109 const {cssText, selectorText, style} = rule;
110
111 if (selectorText != null) {
packages/react-devtools-shared/src/backend/agent.js
+35 -35
@@ -226,9 +226,9 @@ function mergeRoots(
226 }
227
228 const leftSuspendedBy: DehydratedData = left.suspendedBy;
229 - const {data, cleaned, unserializable} = (right.suspendedBy: DehydratedData);
230 - const leftSuspendedByData = ((leftSuspendedBy.data: any): Array<mixed>);
231 - const rightSuspendedByData = ((data: any): Array<mixed>);
229 + const {data, cleaned, unserializable} = right.suspendedBy as DehydratedData;
230 + const leftSuspendedByData = leftSuspendedBy.data as any as Array<mixed>;
231 + const rightSuspendedByData = data as any as Array<mixed>;
232 for (let i = 0; i < rightSuspendedByData.length; i++) {
233 leftSuspendedByData.push(rightSuspendedByData[i]);
234 }
@@ -464,9 +464,9 @@ export default class Agent extends EventEmitter<{
464 if (isReactNativeEnvironment() || typeof target.nodeType !== 'number') {
465 // In React Native or non-DOM we simply pick any renderer that has a match.
466 for (const rendererID in this._rendererInterfaces) {
467 - const renderer = ((this._rendererInterfaces[
468 - (rendererID: any)
469 - ]: any): RendererInterface);
467 + const renderer = this._rendererInterfaces[
468 + rendererID as any
469 + ] as any as RendererInterface;
470 try {
471 const id = onlySuspenseNodes
472 ? renderer.getSuspenseNodeIDForHostInstance(target)
@@ -491,11 +491,11 @@ export default class Agent extends EventEmitter<{
491 let bestRendererID: number = 0;
492 // Find the nearest ancestor which is mounted by a React.
493 for (const rendererID in this._rendererInterfaces) {
494 - const renderer = ((this._rendererInterfaces[
495 - (rendererID: any)
496 - ]: any): RendererInterface);
494 + const renderer = this._rendererInterfaces[
495 + rendererID as any
496 + ] as any as RendererInterface;
497 const nearestNode: null | Element = renderer.getNearestMountedDOMNode(
498 - (target: any),
498 + target as any,
499 );
500 if (nearestNode !== null) {
501 if (nearestNode === target) {
@@ -537,9 +537,9 @@ export default class Agent extends EventEmitter<{
537 getComponentNameForHostInstance(target: HostInstance): string | null {
538 const match = this.getIDForHostInstance(target);
539 if (match !== null) {
540 - const renderer = ((this._rendererInterfaces[
541 - (match.rendererID: any)
542 - ]: any): RendererInterface);
540 + const renderer = this._rendererInterfaces[
541 + match.rendererID as any
542 + ] as any as RendererInterface;
543 return renderer.getDisplayNameForElementID(match.id);
544 }
545 return null;
@@ -575,7 +575,7 @@ export default class Agent extends EventEmitter<{
575 console.warn(`Invalid renderer id "${rendererID}" for element "${id}"`);
576 } else {
577 const owners = renderer.getOwnersList(id);
578 - this._bridge.send('ownersList', ({id, owners}: OwnersList));
578 + this._bridge.send('ownersList', {id, owners} as OwnersList);
579 }
580 };
581
@@ -653,9 +653,9 @@ export default class Agent extends EventEmitter<{
653 }
654
655 for (const rendererID in this._rendererInterfaces) {
656 - const renderer = ((this._rendererInterfaces[
657 - (rendererID: any)
658 - ]: any): RendererInterface);
656 + const renderer = this._rendererInterfaces[
657 + rendererID as any
658 + ] as any as RendererInterface;
659 let path: InspectElementParams['path'] = null;
660 if (suspendedByPathIndex !== null && rendererPath !== null) {
661 const suspendedByPathRendererIndex =
@@ -709,14 +709,14 @@ export default class Agent extends EventEmitter<{
709 mergeRoots(inspectedScreen, inspectedRoots, suspendedByOffset);
710 const dehydratedSuspendedBy: DehydratedData =
711 inspectedRoots.suspendedBy;
712 - const suspendedBy = ((dehydratedSuspendedBy.data: any): Array<mixed>);
712 + const suspendedBy = dehydratedSuspendedBy.data as any as Array<mixed>;
713 suspendedByOffset += suspendedBy.length;
714 found = true;
715 break;
716 case 'no-change':
717 found = true;
718 const rootsSuspendedBy: Array<mixed> =
719 - (renderer.getElementAttributeByPath(id, ['suspendedBy']): any);
719 + renderer.getElementAttributeByPath(id, ['suspendedBy']) as any;
720 suspendedByOffset += rootsSuspendedBy.length;
721 break;
722 case 'not-found':
@@ -792,9 +792,9 @@ export default class Agent extends EventEmitter<{
792 rendererID,
793 suspendedSet,
794 }) => {
795 - const renderer = ((this._rendererInterfaces[
796 - (rendererID: any)
797 - ]: any): RendererInterface);
795 + const renderer = this._rendererInterfaces[
796 + rendererID as any
797 + ] as any as RendererInterface;
798 if (renderer.supportsTogglingSuspense) {
799 renderer.overrideSuspenseMilestone(suspendedSet);
800 }
@@ -978,9 +978,9 @@ export default class Agent extends EventEmitter<{
978 setTraceUpdatesEnabled(traceUpdatesEnabled);
979
980 for (const rendererID in this._rendererInterfaces) {
981 - const renderer = ((this._rendererInterfaces[
982 - (rendererID: any)
983 - ]: any): RendererInterface);
981 + const renderer = this._rendererInterfaces[
982 + rendererID as any
983 + ] as any as RendererInterface;
984 renderer.setTraceUpdatesEnabled(traceUpdatesEnabled);
985 }
986 };
@@ -1004,9 +1004,9 @@ export default class Agent extends EventEmitter<{
1004 }) => void = ({recordChangeDescriptions, recordTimeline}) => {
1005 this._isProfiling = true;
1006 for (const rendererID in this._rendererInterfaces) {
1007 - const renderer = ((this._rendererInterfaces[
1008 - (rendererID: any)
1009 - ]: any): RendererInterface);
1007 + const renderer = this._rendererInterfaces[
1008 + rendererID as any
1009 + ] as any as RendererInterface;
1010 renderer.startProfiling(recordChangeDescriptions, recordTimeline);
1011 }
1012 this._bridge.send('profilingStatus', this._isProfiling);
@@ -1015,9 +1015,9 @@ export default class Agent extends EventEmitter<{
1015 stopProfiling: () => void = () => {
1016 this._isProfiling = false;
1017 for (const rendererID in this._rendererInterfaces) {
1018 - const renderer = ((this._rendererInterfaces[
1019 - (rendererID: any)
1020 - ]: any): RendererInterface);
1018 + const renderer = this._rendererInterfaces[
1019 + rendererID as any
1020 + ] as any as RendererInterface;
1021 renderer.stopProfiling();
1022 }
1023 this._bridge.send('profilingStatus', this._isProfiling);
@@ -1060,9 +1060,9 @@ export default class Agent extends EventEmitter<{
1060 componentFilters => {
1061 for (const rendererIDString in this._rendererInterfaces) {
1062 const rendererID = +rendererIDString;
1063 - const renderer = ((this._rendererInterfaces[
1064 - (rendererID: any)
1065 - ]: any): RendererInterface);
1063 + const renderer = this._rendererInterfaces[
1064 + rendererID as any
1065 + ] as any as RendererInterface;
1066 if (this._lastSelectedRendererID === rendererID) {
1067 // Changing component filters will unmount and remount the DevTools tree.
1068 // Track the last selection's path so we can restore the selection.
@@ -1204,7 +1204,7 @@ export default class Agent extends EventEmitter<{
1204 if (path !== null) {
1205 sessionStorageSetItem(
1206 SESSION_STORAGE_LAST_SELECTION_KEY,
1207 - JSON.stringify(({rendererID, path}: PersistedSelection)),
1207 + JSON.stringify({rendererID, path} as PersistedSelection),
1208 );
1209 } else {
1210 sessionStorageRemoveItem(SESSION_STORAGE_LAST_SELECTION_KEY);
packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js
+2 -2
@@ -165,7 +165,7 @@ export function getOwnerStackByFiberInDev(
165 if (workInProgress.tag === HostText) {
166 // Text nodes never have an owner/stack because they're not created through JSX.
167 // We use the parent since text nodes are always created through a host parent.
168 - workInProgress = (workInProgress.return: any);
168 + workInProgress = workInProgress.return as any;
169 }
170
171 // The owner stack of the current fiber will be where it was created, i.e. inside its owner.
@@ -197,7 +197,7 @@ export function getOwnerStackByFiberInDev(
197
198 while (owner) {
199 if (typeof owner.tag === 'number') {
200 - const fiber: Fiber = (owner: any);
200 + const fiber: Fiber = owner as any;
201 owner = fiber._debugOwner;
202 let debugStack: void | null | string | Error = fiber._debugStack;
203 // If we don't actually print the stack if there is no owner of this JSX element.
packages/react-devtools-shared/src/backend/fiber/renderer.js
+60 -57
@@ -215,7 +215,7 @@ function createFiberInstance(fiber: Fiber): FiberInstance {
215
216 // This is used to represent a filtered Fiber but still lets us find its host instance.
217 function createFilteredFiberInstance(fiber: Fiber): FilteredFiberInstance {
218 - return ({
218 + return {
219 kind: FILTERED_FIBER_INSTANCE,
220 id: 0,
221 parent: null,
@@ -227,7 +227,7 @@ function createFilteredFiberInstance(fiber: Fiber): FilteredFiberInstance {
227 suspendedBy: null,
228 suspenseNode: null,
229 data: fiber,
230 - }: any);
230 + } as any;
231 }
232
233 function createVirtualInstance(
@@ -290,14 +290,14 @@ export function getDispatcherRef(renderer: {
290 // We got a legacy dispatcher injected, let's create a wrapper proxy to translate.
291 return {
292 get H() {
293 - return (injectedRef: any).current;
293 + return (injectedRef as any).current;
294 },
295 set H(value) {
296 - (injectedRef: any).current = value;
296 + (injectedRef as any).current = value;
297 },
298 };
299 }
300 - return (injectedRef: any);
300 + return injectedRef as any;
301 }
302
303 // All environment names we've seen so far. This lets us create a list of filters to apply.
@@ -971,7 +971,7 @@ export function attach(
971 currentRoot = rootInstance;
972 unmountInstanceRecursively(rootInstance);
973 rootToFiberInstanceMap.delete(root);
974 - currentRoot = (null: any);
974 + currentRoot = null as any;
975 });
976
977 if (
@@ -1040,7 +1040,7 @@ export function attach(
1040 currentRoot = newRoot;
1041 setRootPseudoKey(currentRoot.id, root.current);
1042 mountFiberRecursively(root.current, false);
1043 - currentRoot = (null: any);
1043 + currentRoot = null as any;
1044 });
1045
1046 // We need to write back the new ID for the focused Fiber.
@@ -1278,7 +1278,7 @@ export function attach(
1278 }
1279
1280 // When a mount or update is in progress, this value tracks the root that is being operated on.
1281 - let currentRoot: FiberInstance = (null: any);
1281 + let currentRoot: FiberInstance = null as any;
1282
1283 // Removes a Fiber (and its alternate) from the Maps used to track their id.
1284 // This method should always be called when a Fiber is unmounting.
@@ -2884,7 +2884,7 @@ export function attach(
2884 for (let i = 0; i < debugInfo.length; i++) {
2885 const debugEntry = debugInfo[i];
2886 if (debugEntry.awaited) {
2887 - const asyncInfo: ReactAsyncInfo = (debugEntry: any);
2887 + const asyncInfo: ReactAsyncInfo = debugEntry as any;
2888 insertSuspendedBy(asyncInfo);
2889 }
2890 }
@@ -2917,7 +2917,7 @@ export function attach(
2917 for (let j = 0; j < debugInfo.length; j++) {
2918 const debugEntry = debugInfo[j];
2919 if (debugEntry.awaited) {
2920 - const asyncInfo: ReactAsyncInfo = (debugEntry: any);
2920 + const asyncInfo: ReactAsyncInfo = debugEntry as any;
2921 insertSuspendedBy(asyncInfo);
2922 }
2923 }
@@ -2989,14 +2989,14 @@ export function attach(
2989 start = resourceEntry.startTime;
2990 end = start + resourceEntry.duration;
2991 // $FlowFixMe[prop-missing]
2992 - byteSize = (resourceEntry.transferSize: any) || 0;
2992 + byteSize = (resourceEntry.transferSize as any) || 0;
2993 }
2994 }
2995 }
2996 const value = instance.sheet;
2997 const promise = Promise.resolve(value);
2998 - (promise: any).status = 'fulfilled';
2999 - (promise: any).value = value;
2998 + (promise as any).status = 'fulfilled';
2999 + (promise as any).value = value;
3000 const ioInfo: ReactIOInfo = {
3001 name: 'stylesheet',
3002 start,
@@ -3085,9 +3085,9 @@ export function attach(
3085 start = resourceEntry.startTime;
3086 end = start + resourceEntry.duration;
3087 // $FlowFixMe[prop-missing]
3088 - fileSize = (resourceEntry.decodedBodySize: any) || 0;
3088 + fileSize = (resourceEntry.decodedBodySize as any) || 0;
3089 // $FlowFixMe[prop-missing]
3090 - byteSize = (resourceEntry.transferSize: any) || 0;
3090 + byteSize = (resourceEntry.transferSize as any) || 0;
3091 }
3092 }
3093 }
@@ -3111,8 +3111,8 @@ export function attach(
3111 value.fileSize = fileSize;
3112 }
3113 const promise = Promise.resolve(value);
3114 - (promise: any).status = 'fulfilled';
3115 - (promise: any).value = value;
3114 + (promise as any).status = 'fulfilled';
3115 + (promise as any).value = value;
3116 const ioInfo: ReactIOInfo = {
3117 name: 'img',
3118 start,
@@ -3175,7 +3175,7 @@ export function attach(
3175 const debugEntry = fiber._debugInfo[i];
3176 if (debugEntry.awaited) {
3177 // Async Info
3178 - const asyncInfo: ReactAsyncInfo = (debugEntry: any);
3178 + const asyncInfo: ReactAsyncInfo = debugEntry as any;
3179 if (level === virtualLevel) {
3180 // Track any async info between the previous virtual instance up until to this
3181 // instance and add it to the parent. This can add the same set multiple times
@@ -3189,7 +3189,7 @@ export function attach(
3189 continue;
3190 }
3191 // Scan up until the next Component to see if this component changed environment.
3192 - const componentInfo: ReactComponentInfo = (debugEntry: any);
3192 + const componentInfo: ReactComponentInfo = debugEntry as any;
3193 const secondaryEnv = getSecondaryEnvironmentName(fiber._debugInfo, i);
3194 if (componentInfo.env != null) {
3195 knownEnvironmentNames.add(componentInfo.env);
@@ -3789,7 +3789,7 @@ export function attach(
3789 // In some cases actualDuration might be 0 for fibers we worked on (particularly if we're using Date.now)
3790 // In other cases (e.g. Memo) actualDuration might be greater than 0 even if we "bailed out".
3791 const metadata =
3792 - ((currentCommitProfilingMetadata: any): CommitProfilingData);
3792 + currentCommitProfilingMetadata as any as CommitProfilingData;
3793 metadata.durations.push(id, actualDuration, selfDuration);
3794 metadata.maxActualDuration = Math.max(
3795 metadata.maxActualDuration,
@@ -3819,7 +3819,7 @@ export function attach(
3819 (fiber.alternate !== null && updaters.has(fiber.alternate)))
3820 ) {
3821 const metadata =
3822 - ((currentCommitProfilingMetadata: any): CommitProfilingData);
3822 + currentCommitProfilingMetadata as any as CommitProfilingData;
3823 if (metadata.updaters === null) {
3824 metadata.updaters = [];
3825 }
@@ -4044,7 +4044,7 @@ export function attach(
4044 const debugEntry = nextChild._debugInfo[i];
4045 if (debugEntry.awaited) {
4046 // Async Info
4047 - const asyncInfo: ReactAsyncInfo = (debugEntry: any);
4047 + const asyncInfo: ReactAsyncInfo = debugEntry as any;
4048 if (level === virtualLevel) {
4049 // Track any async info between the previous virtual instance up until to this
4050 // instance and add it to the parent. This can add the same set multiple times
@@ -4057,7 +4057,7 @@ export function attach(
4057 // Not a Component. Some other Debug Info.
4058 continue;
4059 }
4060 - const componentInfo: ReactComponentInfo = (debugEntry: any);
4060 + const componentInfo: ReactComponentInfo = debugEntry as any;
4061 const secondaryEnv = getSecondaryEnvironmentName(
4062 nextChild._debugInfo,
4063 i,
@@ -4218,7 +4218,7 @@ export function attach(
4218 if (existingInstance !== null) {
4219 // Common case. Match in the same parent.
4220 const fiberInstance: FiberInstance | FilteredFiberInstance =
4221 - (existingInstance: any); // Only matches if it's a Fiber.
4221 + existingInstance as any; // Only matches if it's a Fiber.
4222
4223 // We keep track if the order of the children matches the previous order.
4224 // They are always different referentially, but if the instances line up
@@ -4235,7 +4235,7 @@ export function attach(
4235 updateFlags |= updateFiberRecursively(
4236 fiberInstance,
4237 nextChild,
4238 - (prevChild: any),
4238 + prevChild as any,
4239 traceNearestHostComponentUpdate,
4240 );
4241 } else if (prevChild !== null && shouldFilterFiber(nextChild)) {
@@ -5054,7 +5054,7 @@ export function attach(
5054
5055 flushPendingEvents(currentRoot);
5056
5057 - currentRoot = (null: any);
5057 + currentRoot = null as any;
5058 });
5059
5060 needsToFlushComponentLogs = false;
@@ -5169,20 +5169,20 @@ export function attach(
5169
5170 if (isProfiling && isProfilingSupported) {
5171 if (!shouldBailoutWithPendingOperations()) {
5172 - const commitProfilingMetadata =
5173 - ((rootToCommitProfilingMetadataMap: any): CommitProfilingMetadataMap).get(
5174 - currentRoot.id,
5175 - );
5172 + const commitProfilingMetadata = (
5173 + rootToCommitProfilingMetadataMap as any as CommitProfilingMetadataMap
5174 + ).get(currentRoot.id);
5175
5176 if (commitProfilingMetadata != null) {
5177 commitProfilingMetadata.push(
5179 - ((currentCommitProfilingMetadata: any): CommitProfilingData),
5178 + currentCommitProfilingMetadata as any as CommitProfilingData,
5179 );
5180 } else {
5182 - ((rootToCommitProfilingMetadataMap: any): CommitProfilingMetadataMap).set(
5183 - currentRoot.id,
5184 - [((currentCommitProfilingMetadata: any): CommitProfilingData)],
5185 - );
5181 + (
5182 + rootToCommitProfilingMetadataMap as any as CommitProfilingMetadataMap
5183 + ).set(currentRoot.id, [
5184 + currentCommitProfilingMetadata as any as CommitProfilingData,
5185 + ]);
5186 }
5187 }
5188 }
@@ -5196,7 +5196,7 @@ export function attach(
5196 hook.emit('traceUpdates', traceUpdatesForNodes);
5197 }
5198
5199 - currentRoot = (null: any);
5199 + currentRoot = null as any;
5200 }
5201
5202 function getResourceInstance(fiber: Fiber): HostInstance | null {
@@ -5331,7 +5331,7 @@ export function attach(
5331 const owner = getUnfilteredOwner(fiber);
5332 if (owner != null) {
5333 if (typeof owner.tag === 'number') {
5334 - return getDisplayNameForFiber((owner: any));
5334 + return getDisplayNameForFiber(owner as any);
5335 } else {
5336 return owner.name || '';
5337 }
@@ -5371,7 +5371,7 @@ export function attach(
5371 if (instance !== undefined) {
5372 if (instance.kind === FILTERED_FIBER_INSTANCE) {
5373 // A Filtered Fiber Instance will always have a Virtual Instance as a parent.
5374 - return ((instance.parent: any): VirtualInstance).id;
5374 + return (instance.parent as any as VirtualInstance).id;
5375 }
5376 return instance.id;
5377 }
@@ -5406,7 +5406,7 @@ export function attach(
5406 ): mixed {
5407 if (isMostRecentlyInspectedElement(id)) {
5408 return getInObject(
5409 - ((mostRecentlyInspectedElement: any): InspectedElement),
5409 + mostRecentlyInspectedElement as any as InspectedElement,
5410 path,
5411 );
5412 }
@@ -5532,21 +5532,21 @@ export function attach(
5532 return null;
5533 }
5534 if (typeof owner.tag === 'number') {
5535 - const ownerFiber: Fiber = (owner: any); // Refined
5535 + const ownerFiber: Fiber = owner as any; // Refined
5536 owner = ownerFiber._debugOwner;
5537 } else {
5538 - const ownerInfo: ReactComponentInfo = (owner: any); // Refined
5538 + const ownerInfo: ReactComponentInfo = owner as any; // Refined
5539 owner = ownerInfo.owner;
5540 }
5541 while (owner) {
5542 if (typeof owner.tag === 'number') {
5543 - const ownerFiber: Fiber = (owner: any); // Refined
5543 + const ownerFiber: Fiber = owner as any; // Refined
5544 if (!shouldFilterFiber(ownerFiber)) {
5545 return ownerFiber;
5546 }
5547 owner = ownerFiber._debugOwner;
5548 } else {
5549 - const ownerInfo: ReactComponentInfo = (owner: any); // Refined
5549 + const ownerInfo: ReactComponentInfo = owner as any; // Refined
5550 if (!shouldFilterVirtual(ownerInfo, null)) {
5551 return ownerInfo;
5552 }
@@ -5572,7 +5572,7 @@ export function attach(
5572 // isn't propagated down as the new owner. In that case we might match the alternate
5573 // instead. This is a bit hacky but the fastest check since type casting owner to a Fiber
5574 // needs a duck type check anyway.
5575 - parentInstance.data === (owner: any).alternate
5575 + parentInstance.data === (owner as any).alternate
5576 ) {
5577 if (parentInstance.kind === FILTERED_FIBER_INSTANCE) {
5578 return null;
@@ -5653,7 +5653,7 @@ export function attach(
5653 }
5654 let firstInstance: null | DevToolsInstance = null;
5655 if (filterByChildInstance === null) {
5656 - firstInstance = (set.values().next().value: any);
5656 + firstInstance = set.values().next().value as any;
5657 } else {
5658 // eslint-disable-next-line no-for-of-loops/no-for-of-loops
5659 for (const childInstance of set.values()) {
@@ -6089,7 +6089,7 @@ export function attach(
6089 ? inspectRootsRaw(devtoolsInstance.id)
6090 : inspectFiberInstanceRaw(devtoolsInstance);
6091 }
6092 - (devtoolsInstance: FilteredFiberInstance); // assert exhaustive
6092 + devtoolsInstance as FilteredFiberInstance; // assert exhaustive
6093 throw new Error('Unsupported instance kind');
6094 }
6095
@@ -6170,7 +6170,7 @@ export function attach(
6170 context = consumerResolvedContext._currentValue || null;
6171
6172 // Look for overridden value.
6173 - let current = ((fiber: any): Fiber).return;
6173 + let current = (fiber as any as Fiber).return;
6174 while (current !== null) {
6175 const currentType = current.type;
6176 const currentTypeSymbol = getTypeSymbol(currentType);
@@ -6203,7 +6203,7 @@ export function attach(
6203 context = consumerResolvedContext._currentValue || null;
6204
6205 // Look for overridden value.
6206 - let current = ((fiber: any): Fiber).return;
6206 + let current = (fiber as any as Fiber).return;
6207 while (current !== null) {
6208 const currentType = current.type;
6209 const currentTypeSymbol = getTypeSymbol(currentType);
@@ -6703,7 +6703,7 @@ export function attach(
6703 ): void {
6704 if (isMostRecentlyInspectedElement(id)) {
6705 const value = getInObject(
6706 - ((mostRecentlyInspectedElement: any): InspectedElement),
6706 + mostRecentlyInspectedElement as any as InspectedElement,
6707 path,
6708 );
6709 const key = `$reactTemp${count}`;
@@ -6721,7 +6721,7 @@ export function attach(
6721 ): ?string {
6722 if (isMostRecentlyInspectedElement(id)) {
6723 const valueToCopy = getInObject(
6724 - ((mostRecentlyInspectedElement: any): InspectedElement),
6724 + mostRecentlyInspectedElement as any as InspectedElement,
6725 path,
6726 );
6727
@@ -6756,7 +6756,7 @@ export function attach(
6756 path,
6757 value: cleanForBridge(
6758 getInObject(
6759 - ((mostRecentlyInspectedElement: any): InspectedElement),
6759 + mostRecentlyInspectedElement as any as InspectedElement,
6760 path,
6761 ),
6762 createIsPathAllowed(null, secondaryCategory),
@@ -7071,7 +7071,7 @@ export function attach(
7071 break;
7072 case 'hooks':
7073 if (typeof overrideHookStateDeletePath === 'function') {
7074 - overrideHookStateDeletePath(fiber, ((hookID: any): number), path);
7074 + overrideHookStateDeletePath(fiber, hookID as any as number, path);
7075 }
7076 break;
7077 case 'props':
@@ -7145,7 +7145,7 @@ export function attach(
7145 if (typeof overrideHookStateRenamePath === 'function') {
7146 overrideHookStateRenamePath(
7147 fiber,
7148 - ((hookID: any): number),
7148 + hookID as any as number,
7149 oldPath,
7150 newPath,
7151 );
@@ -7227,7 +7227,7 @@ export function attach(
7227 break;
7228 case 'hooks':
7229 if (typeof overrideHookState === 'function') {
7230 - overrideHookState(fiber, ((hookID: any): number), path, value);
7230 + overrideHookState(fiber, hookID as any as number, path, value);
7231 }
7232 break;
7233 case 'props':
@@ -7445,13 +7445,16 @@ export function attach(
7445 );
7446 }
7447 const rootID = rootInstance.id;
7448 - ((displayNamesByRootID: any): DisplayNamesByRootID).set(
7448 + (displayNamesByRootID as any as DisplayNamesByRootID).set(
7449 rootID,
7450 getDisplayNameForRoot(root.current),
7451 );
7452 const initialTreeBaseDurations: Array<[number, number]> = [];
7453 snapshotTreeBaseDurations(rootInstance, initialTreeBaseDurations);
7454 - (initialTreeBaseDurationsMap: any).set(rootID, initialTreeBaseDurations);
7454 + (initialTreeBaseDurationsMap as any).set(
7455 + rootID,
7456 + initialTreeBaseDurations,
7457 + );
7458 });
7459
7460 isProfiling = true;
@@ -8113,7 +8116,7 @@ export function attach(
8116 // but it's at least somewhere within it.
8117 if (isError(unresolvedSource)) {
8118 return (instance.source = extractLocationFromOwnerStack(
8116 - (unresolvedSource: any),
8119 + unresolvedSource as any,
8120 ));
8121 }
8122 if (typeof unresolvedSource === 'string') {
packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInspection.js
+2 -2
@@ -21,7 +21,7 @@ export function isError(object: mixed): boolean {
21
22 export function getFiberFlags(fiber: Fiber): number {
23 // The name of this field changed from "effectTag" to "flags"
24 - return fiber.flags !== undefined ? fiber.flags : (fiber: any).effectTag;
24 + return fiber.flags !== undefined ? fiber.flags : (fiber as any).effectTag;
25 }
26
27 export function rootSupportsProfiling(root: any): boolean {
@@ -61,7 +61,7 @@ export function getSecondaryEnvironmentName(
61 index: number,
62 ): null | string {
63 if (debugInfo != null) {
64 - const componentInfo: ReactComponentInfo = (debugInfo[index]: any);
64 + const componentInfo: ReactComponentInfo = debugInfo[index] as any;
65 for (let i = index + 1; i < debugInfo.length; i++) {
66 const debugEntry = debugInfo[i];
67 if (typeof debugEntry.env === 'string') {
packages/react-devtools-shared/src/backend/fiber/shared/DevToolsFiberInternalReactConstants.js
+1 -1
@@ -99,7 +99,7 @@ export function getInternalReactConstants(version: string): {
99
100 const SuspenseyImagesMode = 0b0100000;
101
102 - let ReactTypeOfWork: WorkTagMap = ((null: any): WorkTagMap);
102 + let ReactTypeOfWork: WorkTagMap = null as any as WorkTagMap;
103
104 // **********************************************************
105 // The section below is copied from files in React repo.
packages/react-devtools-shared/src/backend/legacy/renderer.js
+3 -3
@@ -146,7 +146,7 @@ export function attach(
146 new WeakMap();
147
148 let getElementIDForHostInstance: GetElementIDForHostInstance =
149 - ((null: any): GetElementIDForHostInstance);
149 + null as any as GetElementIDForHostInstance;
150 let findHostInstanceForInternalID: (id: number) => ?HostInstance;
151 let getNearestMountedDOMNode = (node: Element): null | Element => {
152 // Not implemented.
@@ -198,7 +198,7 @@ export function attach(
198 internalInstanceToIDMap.set(internalInstance, id);
199 idToInternalInstanceMap.set(id, internalInstance);
200 }
201 - return ((internalInstanceToIDMap.get(internalInstance): any): number);
201 + return internalInstanceToIDMap.get(internalInstance) as any as number;
202 }
203
204 function areEqualArrays(a: Array<any>, b: Array<any>) {
@@ -832,7 +832,7 @@ export function attach(
832
833 let owner = element._owner;
834 if (owner) {
835 - owners = ([]: Array<SerializedElement>);
835 + owners = [] as Array<SerializedElement>;
836 while (owner != null) {
837 owners.push({
838 displayName: getData(owner).displayName || 'Unknown',
packages/react-devtools-shared/src/backend/profilingHooks.js
+4 -4
@@ -213,8 +213,8 @@ export function createProfilingHooks({
213
214 function markAndClear(markName: string) {
215 // This method won't be called unless these functions are defined, so we can skip the extra typeof check.
216 - ((performanceTarget: any): Performance).mark(markName);
217 - ((performanceTarget: any): Performance).clearMarks(markName);
216 + (performanceTarget as any as Performance).mark(markName);
217 + (performanceTarget as any as Performance).clearMarks(markName);
218 }
219
220 function recordReactMeasureStarted(
@@ -605,7 +605,7 @@ export function createProfilingHooks({
605 if (!wakeableIDs.has(wakeable)) {
606 wakeableIDs.set(wakeable, wakeableID++);
607 }
608 - return ((wakeableIDs.get(wakeable): any): number);
608 + return wakeableIDs.get(wakeable) as any as number;
609 }
610
611 function markComponentSuspended(
@@ -626,7 +626,7 @@ export function createProfilingHooks({
626 // frameworks like Relay may also annotate Promises with a displayName,
627 // describing what operation/data the thrown Promise is related to.
628 // When this is available we should pass it along to the Timeline.
629 - const displayName = (wakeable: any).displayName || '';
629 + const displayName = (wakeable as any).displayName || '';
630
631 let suspenseEvent: SuspenseEvent | null = null;
632 // TODO (timeline) Record and cache component stack
packages/react-devtools-shared/src/backend/shared/ReactSymbols.js
+2 -2
@@ -75,6 +75,6 @@ export const REACT_MEMO_CACHE_SENTINEL: symbol = Symbol.for(
75
76 import type {ReactOptimisticKey} from 'shared/ReactTypes';
77
78 -export const REACT_OPTIMISTIC_KEY: ReactOptimisticKey = (Symbol.for(
78 +export const REACT_OPTIMISTIC_KEY: ReactOptimisticKey = Symbol.for(
79 'react.optimistic_key',
80 -): any);
80 +) as any;
packages/react-devtools-shared/src/backend/utils/index.js
+2 -2
@@ -61,7 +61,7 @@ export function copyWithDelete(
61 const updated = isArray(obj) ? obj.slice() : {...obj};
62 if (index + 1 === path.length) {
63 if (isArray(updated)) {
64 - updated.splice(((key: any): number), 1);
64 + updated.splice(key as any as number, 1);
65 } else {
66 delete updated[key];
67 }
@@ -87,7 +87,7 @@ export function copyWithRename(
87 // $FlowFixMe[incompatible-use] number or string is fine here
88 updated[newKey] = updated[oldKey];
89 if (isArray(updated)) {
90 - updated.splice(((oldKey: any): number), 1);
90 + updated.splice(oldKey as any as number, 1);
91 } else {
92 delete updated[oldKey];
93 }
packages/react-devtools-shared/src/backend/utils/parseStackTrace.js
+2 -2
@@ -224,12 +224,12 @@ function collectStackTrace(
224 const enclosingLine: number =
225 // $FlowFixMe[prop-missing]
226 typeof callSite.getEnclosingLineNumber === 'function'
227 - ? (callSite: any).getEnclosingLineNumber() || 0
227 + ? (callSite as any).getEnclosingLineNumber() || 0
228 : 0;
229 const enclosingCol: number =
230 // $FlowFixMe[prop-missing]
231 typeof callSite.getEnclosingColumnNumber === 'function'
232 - ? (callSite: any).getEnclosingColumnNumber() || 0
232 + ? (callSite as any).getEnclosingColumnNumber() || 0
233 : 0;
234 const isAsync =
235 // $FlowFixMe[prop-missing]
packages/react-devtools-shared/src/backend/views/Highlighter/Highlighter.js
+1 -1
@@ -75,7 +75,7 @@ export function showOverlay(
75 return isReactNativeEnvironment()
76 ? showOverlayNative(elements, agent)
77 : showOverlayWeb(
78 - (elements: $ReadOnlyArray<any>),
78 + elements as $ReadOnlyArray<any>,
79 componentName,
80 agent,
81 hideAfterTimeout,
packages/react-devtools-shared/src/backend/views/Highlighter/Overlay.js
+2 -2
@@ -191,9 +191,9 @@ export default class Overlay {
191 // We can't get the size of text nodes or comment nodes. React as of v15
192 // heavily uses comment nodes to delimit text.
193 // TODO: We actually can measure text nodes. We should.
194 - const elements: $ReadOnlyArray<HTMLElement> = (nodes.filter(
194 + const elements: $ReadOnlyArray<HTMLElement> = nodes.filter(
195 node => node.nodeType === Node.ELEMENT_NODE,
196 - ): any);
196 + ) as any;
197
198 while (this.rects.length > elements.length) {
199 const rect = this.rects.pop();
packages/react-devtools-shared/src/backend/views/Highlighter/index.js
+3 -3
@@ -434,7 +434,7 @@ export default function setupHighlighter(
434 lastHoveredNode = target;
435
436 if (target.tagName === 'IFRAME') {
437 - const iframe: HTMLIFrameElement = (target: any);
437 + const iframe: HTMLIFrameElement = target as any;
438 try {
439 if (!iframesListeningTo.has(iframe)) {
440 const window = iframe.contentWindow;
@@ -493,9 +493,9 @@ export default function setupHighlighter(
493
494 function getEventTarget(event: MouseEvent): HTMLElement {
495 if (event.composed) {
496 - return (event.composedPath()[0]: any);
496 + return event.composedPath()[0] as any;
497 }
498
499 - return (event.target: any);
499 + return event.target as any;
500 }
501 }
packages/react-devtools-shared/src/backend/views/TraceUpdates/canvas.js
+1 -1
@@ -48,7 +48,7 @@ function drawWeb(nodeToData: Map<HostInstance, Data>) {
48 }
49
50 const dpr = window.devicePixelRatio || 1;
51 - const canvasFlow: HTMLCanvasElement = ((canvas: any): HTMLCanvasElement);
51 + const canvasFlow: HTMLCanvasElement = canvas as any as HTMLCanvasElement;
52 canvasFlow.width = window.innerWidth * dpr;
53 canvasFlow.height = window.innerHeight * dpr;
54 canvasFlow.style.width = `${window.innerWidth}px`;
packages/react-devtools-shared/src/backend/views/TraceUpdates/index.js
+1 -1
@@ -47,7 +47,7 @@ export type Data = {
47
48 const nodeToData: Map<HostInstance, Data> = new Map();
49
50 -let agent: Agent = ((null: any): Agent);
50 +let agent: Agent = null as any as Agent;
51 let drawAnimationFrameID: AnimationFrameID | null = null;
52 let isEnabled: boolean = false;
53 let redrawTimeoutID: TimeoutID | null = null;
packages/react-devtools-shared/src/backendAPI.js
+1 -1
@@ -204,7 +204,7 @@ function getPromiseForRequestID<T>(
204 const onInspectedElement = (data: any) => {
205 if (data.responseID === requestID) {
206 cleanup();
207 - resolve((data: T));
207 + resolve(data as T);
208 }
209 };
210
packages/react-devtools-shared/src/bridge.js
+1 -1
@@ -323,7 +323,7 @@ class Bridge<
323 this._wallUnlisten =
324 wall.listen((message: Message) => {
325 if (message && message.event) {
326 - (this: any).emit(message.event, message.payload);
326 + (this as any).emit(message.event, message.payload);
327 }
328 }) || null;
329
packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-fb.js
+1 -1
@@ -27,4 +27,4 @@ import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default';
27 import typeof * as ExportsType from './DevToolsFeatureFlags.core-fb';
28
29 // Flow magic to verify the exports of this file match the original version.
30 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
30 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-oss.js
+1 -1
@@ -27,4 +27,4 @@ import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default';
27 import typeof * as ExportsType from './DevToolsFeatureFlags.core-oss';
28
29 // Flow magic to verify the exports of this file match the original version.
30 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
30 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-fb.js
+1 -1
@@ -27,4 +27,4 @@ import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default';
27 import typeof * as ExportsType from './DevToolsFeatureFlags.extension-fb';
28
29 // Flow magic to verify the exports of this file match the original version.
30 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
30 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/react-devtools-shared/src/config/DevToolsFeatureFlags.extension-oss.js
+1 -1
@@ -27,4 +27,4 @@ import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default';
27 import typeof * as ExportsType from './DevToolsFeatureFlags.extension-oss';
28
29 // Flow magic to verify the exports of this file match the original version.
30 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
30 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js
+2 -2
@@ -84,10 +84,10 @@ export default function ContextMenu({
84 "Can't access context menu element. This is a bug in React DevTools.",
85 );
86 }
87 - const menu = (maybeMenu: HTMLDivElement);
87 + const menu = maybeMenu as HTMLDivElement;
88
89 function hideUnlessContains(event: Event) {
90 - if (!menu.contains(((event.target: any): Node))) {
90 + if (!menu.contains(event.target as any as Node)) {
91 hide();
92 }
93 }
packages/react-devtools-shared/src/devtools/cache.js
+8 -8
@@ -46,10 +46,10 @@ if (typeof React.use === 'function') {
46 return React.use(Context);
47 };
48 } else if (
49 - typeof (React: any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ===
49 + typeof (React as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ===
50 'object'
51 ) {
52 - const ReactCurrentDispatcher = (React: any)
52 + const ReactCurrentDispatcher = (React as any)
53 .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;
54 readContext = function (Context: ReactContext<null>) {
55 const dispatcher = ReactCurrentDispatcher.current;
@@ -79,9 +79,9 @@ const resourceConfigs: Map<Resource<any, any, any>, Config> = new Map();
79 function getEntriesForResource(
80 resource: any,
81 ): Map<any, any> | WeakMap<any, any> {
82 - let entriesForResource: Map<any, any> | WeakMap<any, any> = ((entries.get(
82 + let entriesForResource: Map<any, any> | WeakMap<any, any> = entries.get(
83 resource,
84 - ): any): Map<any, any>);
84 + ) as any as Map<any, any>;
85 if (entriesForResource === undefined) {
86 const config = resourceConfigs.get(resource);
87 entriesForResource =
@@ -103,12 +103,12 @@ function accessResult<Input, Key, Value>(
103 const thenable = fetch(input);
104 thenable.then(
105 value => {
106 - const fulfilledThenable: FulfilledThenable<Value> = (thenable: any);
106 + const fulfilledThenable: FulfilledThenable<Value> = thenable as any;
107 fulfilledThenable.status = 'fulfilled';
108 fulfilledThenable.value = value;
109 },
110 error => {
111 - const rejectedThenable: RejectedThenable<Value> = (thenable: any);
111 + const rejectedThenable: RejectedThenable<Value> = thenable as any;
112 rejectedThenable.status = 'rejected';
113 rejectedThenable.reason = error;
114 },
@@ -171,9 +171,9 @@ export function createResource<Input, Key, Value>(
171 write(key: Key, value: Value): void {
172 const entriesForResource = getEntriesForResource(resource);
173
174 - const fulfilledThenable: FulfilledThenable<Value> = (Promise.resolve(
174 + const fulfilledThenable: FulfilledThenable<Value> = Promise.resolve(
175 value,
176 - ): any);
176 + ) as any;
177 fulfilledThenable.status = 'fulfilled';
178 fulfilledThenable.value = value;
179
packages/react-devtools-shared/src/devtools/store.js
+6 -6
@@ -1313,7 +1313,7 @@ export default class Store extends EventEmitter<{
1313 if (didMutate) {
1314 let weightAcrossRoots = 0;
1315 this._roots.forEach(rootID => {
1316 - const {weight} = ((this.getElementByID(rootID): any): Element);
1316 + const {weight} = this.getElementByID(rootID) as any as Element;
1317 weightAcrossRoots += weight;
1318 });
1319 this._weightAcrossRoots = weightAcrossRoots;
@@ -1426,7 +1426,7 @@ export default class Store extends EventEmitter<{
1426 switch (operation) {
1427 case TREE_OPERATION_ADD: {
1428 const id = operations[i + 1];
1429 - const type = ((operations[i + 2]: any): ElementType);
1429 + const type = operations[i + 2] as any as ElementType;
1430
1431 i += 3;
1432
@@ -1820,7 +1820,7 @@ export default class Store extends EventEmitter<{
1820 const parentID = operations[i + 2];
1821 const nameStringID = operations[i + 3];
1822 const isSuspended = operations[i + 4] === 1;
1823 - const numRects = ((operations[i + 5]: any): number);
1823 + const numRects = operations[i + 5] as any as number;
1824 let name = stringTable[nameStringID];
1825
1826 if (this._idToSuspense.has(id)) {
@@ -2030,8 +2030,8 @@ export default class Store extends EventEmitter<{
2030 break;
2031 }
2032 case SUSPENSE_TREE_OPERATION_RESIZE: {
2033 - const id = ((operations[i + 1]: any): number);
2034 - const numRects = ((operations[i + 2]: any): number);
2033 + const id = operations[i + 1] as any as number;
2034 + const numRects = operations[i + 2] as any as number;
2035 i += 3;
2036
2037 const suspense = this._idToSuspense.get(id);
@@ -2276,7 +2276,7 @@ export default class Store extends EventEmitter<{
2276 if (didCollapse) {
2277 let weightAcrossRoots = 0;
2278 this._roots.forEach(rootID => {
2279 - const {weight} = ((this.getElementByID(rootID): any): Element);
2279 + const {weight} = this.getElementByID(rootID) as any as Element;
2280 weightAcrossRoots += weight;
2281 });
2282 this._weightAcrossRoots = weightAcrossRoots;
packages/react-devtools-shared/src/devtools/utils.js
+1 -1
@@ -156,7 +156,7 @@ export function printStore(
156 }
157
158 store.roots.forEach(rootID => {
159 - const {weight} = ((store.getElementByID(rootID): any): Element);
159 + const {weight} = store.getElementByID(rootID) as any as Element;
160 const maybeWeightLabel = includeWeight ? ` (${weight})` : '';
161
162 // Store does not (yet) expose a way to get errors/warnings per root.
packages/react-devtools-shared/src/devtools/views/Components/Components.js
+1 -1
@@ -239,4 +239,4 @@ function setResizeCSSVariable(
239 }
240 }
241
242 -export default (portaledContent(Components): component());
242 +export default portaledContent(Components) as component();
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js
+1 -1
@@ -57,7 +57,7 @@ type Context = {
57 };
58
59 export const InspectedElementContext: ReactContext<Context> =
60 - createContext<Context>(((null: any): Context));
60 + createContext<Context>(null as any as Context);
61
62 export type Props = {
63 children: ReactNodeList,
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js
+1 -1
@@ -81,7 +81,7 @@ export default function InspectedElementContextTree({
81 {isEmpty && <div className={styles.Empty}>None</div>}
82 {/* $FlowFixMe[constant-condition] */}
83 {!isEmpty &&
84 - (entries: any).map(([name, value]) => (
84 + (entries as any).map(([name, value]) => (
85 <KeyValue
86 key={name}
87 alphaSort={true}
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementHooksTree.js
+3 -3
@@ -234,7 +234,7 @@ function HookView({
234
235 // Format data for display to mimic the props/state/context for now.
236 if (type === 'string') {
237 - displayValue = `"${((value: any): string)}"`;
237 + displayValue = `"${value as any as string}"`;
238 } else if (type === 'boolean') {
239 displayValue = value ? 'true' : 'false';
240 } else if (type === 'number') {
@@ -389,6 +389,6 @@ function HookView({
389 }
390 }
391
392 -export default (React.memo(InspectedElementHooksTree): component(
392 +export default React.memo(InspectedElementHooksTree) as component(
393 ...props: HookViewProps
394 -));
394 +);
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementStateTree.js
+1 -1
@@ -69,7 +69,7 @@ export default function InspectedElementStateTree({
69 {isEmpty && <div className={styles.Empty}>None</div>}
70 {/* $FlowFixMe[constant-condition] */}
71 {!isEmpty &&
72 - (entries: any).map(([name, value]) => (
72 + (entries as any).map(([name, value]) => (
73 <KeyValue
74 key={name}
75 alphaSort={true}
packages/react-devtools-shared/src/devtools/views/Components/NativeStyleEditor/context.js
+1 -1
@@ -26,7 +26,7 @@ import type {StyleAndLayout as StyleAndLayoutFrontend} from './types';
26 type Context = StyleAndLayoutFrontend | null;
27
28 const NativeStyleContext: ReactContext<Context> = createContext<Context>(
29 - ((null: any): Context),
29 + null as any as Context,
30 );
31 NativeStyleContext.displayName = 'NativeStyleContext';
32
packages/react-devtools-shared/src/devtools/views/Components/OwnersListContext.js
+4 -4
@@ -26,7 +26,7 @@ import type {Resource, Thenable} from '../../cache';
26 type Context = (id: number) => Array<SerializedElement> | null;
27
28 const OwnersListContext: ReactContext<Context> = createContext<Context>(
29 - ((null: any): Context),
29 + null as any as Context,
30 );
31 OwnersListContext.displayName = 'OwnersListContext';
32
@@ -52,7 +52,7 @@ const resource: Resource<
52 | ResolveFn
53 | ((
54 result: Promise<Array<SerializedElement>> | Array<SerializedElement>,
55 - ) => void) = ((null: any): ResolveFn);
55 + ) => void) = null as any as ResolveFn;
56 const promise = new Promise(resolve => {
57 resolveFn = resolve;
58 });
@@ -60,7 +60,7 @@ const resource: Resource<
60 // $FlowFixMe[incompatible-type] found when upgrading Flow
61 inProgressRequests.set(element, {promise, resolveFn});
62
63 - return (promise: $FlowFixMe);
63 + return promise as $FlowFixMe;
64 },
65 (element: Element) => element,
66 {useWeakMap: true},
@@ -88,7 +88,7 @@ function useChangeOwnerAction(): (nextOwnerID: number) => void {
88 result:
89 | Promise<Array<SerializedElement>>
90 | Array<SerializedElement>,
91 - ) => void) = ((null: any): ResolveFn);
91 + ) => void) = null as any as ResolveFn;
92 const promise = new Promise(resolve => {
93 resolveFn = resolve;
94 });
packages/react-devtools-shared/src/devtools/views/Components/Tree.js
+1 -1
@@ -215,7 +215,7 @@ export default function Tree(): React.Node {
215 }
216
217 const handleKeyDown = (event: KeyboardEvent) => {
218 - if ((event: any).target.tagName === 'INPUT' || event.defaultPrevented) {
218 + if ((event as any).target.tagName === 'INPUT' || event.defaultPrevented) {
219 return;
220 }
221
packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js
+28 -25
@@ -149,12 +149,12 @@ type Action =
149 export type DispatcherContext = (action: Action) => void;
150
151 const TreeStateContext: ReactContext<StateContext> =
152 - createContext<StateContext>(((null: any): StateContext));
152 + createContext<StateContext>(null as any as StateContext);
153 TreeStateContext.displayName = 'TreeStateContext';
154
155 // TODO: `dispatch` is an Action and should be named accordingly.
156 const TreeDispatcherContext: ReactContext<DispatcherContext> =
157 - createContext<DispatcherContext>(((null: any): DispatcherContext));
157 + createContext<DispatcherContext>(null as any as DispatcherContext);
158 TreeDispatcherContext.displayName = 'TreeDispatcherContext';
159
160 type State = {
@@ -237,7 +237,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
237 case 'SELECT_ELEMENT_AT_INDEX':
238 ownerSubtreeLeafElementID = null;
239
240 - inspectedElementIndex = (action: ACTION_SELECT_ELEMENT_AT_INDEX)
240 + inspectedElementIndex = (action as ACTION_SELECT_ELEMENT_AT_INDEX)
241 .payload;
242 break;
243 case 'SELECT_ELEMENT_BY_ID':
@@ -247,7 +247,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
247 // It might also cause problems if the specified element was inside of a (not yet expanded) subtree.
248 lookupIDForIndex = false;
249
250 - inspectedElementID = (action: ACTION_SELECT_ELEMENT_BY_ID).payload;
250 + inspectedElementID = (action as ACTION_SELECT_ELEMENT_BY_ID).payload;
251 inspectedElementIndex =
252 inspectedElementID === null
253 ? null
@@ -270,7 +270,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
270
271 if (inspectedElementIndex !== null) {
272 const selectedElement = store.getElementAtIndex(
273 - ((inspectedElementIndex: any): number),
273 + inspectedElementIndex as any as number,
274 );
275 if (selectedElement !== null && selectedElement.parentID !== 0) {
276 const parent = store.getElementByID(selectedElement.parentID);
@@ -319,7 +319,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
319 }
320
321 const selectedElement = store.getElementAtIndex(
322 - ((inspectedElementIndex: any): number),
322 + inspectedElementIndex as any as number,
323 );
324 if (selectedElement !== null && selectedElement.ownerID !== 0) {
325 const ownerIndex = store.getIndexOfElementID(
@@ -336,7 +336,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
336
337 if (inspectedElementIndex !== null) {
338 const selectedElement = store.getElementAtIndex(
339 - ((inspectedElementIndex: any): number),
339 + inspectedElementIndex as any as number,
340 );
341 if (selectedElement !== null && selectedElement.parentID !== 0) {
342 const parentIndex = store.getIndexOfElementID(
@@ -362,7 +362,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
362
363 if (inspectedElementIndex !== null) {
364 const selectedElement = store.getElementAtIndex(
365 - ((inspectedElementIndex: any): number),
365 + inspectedElementIndex as any as number,
366 );
367 if (selectedElement !== null && selectedElement.parentID !== 0) {
368 const parent = store.getElementByID(selectedElement.parentID);
@@ -470,7 +470,7 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
470 inspectedElementID = null;
471 } else {
472 inspectedElementID = store.getElementIDAtIndex(
473 - ((inspectedElementIndex: any): number),
473 + inspectedElementIndex as any as number,
474 );
475 }
476 }
@@ -520,15 +520,16 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
520 if (numPrevSearchResults > 0) {
521 didRequestSearch = true;
522 searchIndex =
523 - ((searchIndex: any): number) > 0
524 - ? ((searchIndex: any): number) - 1
523 + (searchIndex as any as number) > 0
524 + ? (searchIndex as any as number) - 1
525 : numPrevSearchResults - 1;
526 }
527 break;
528 case 'HANDLE_STORE_MUTATION':
529 if (searchText !== '') {
530 - const [addedElementIDs, removedElementIDs] =
531 - (action: ACTION_HANDLE_STORE_MUTATION).payload;
530 + const [addedElementIDs, removedElementIDs] = (
531 + action as ACTION_HANDLE_STORE_MUTATION
532 + ).payload;
533
534 removedElementIDs.forEach((parentID, id) => {
535 // Prune this item from the search results.
@@ -541,14 +542,16 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
542 // If the results are now empty, also deselect things.
543 if (searchResults.length === 0) {
544 searchIndex = null;
544 - } else if (((searchIndex: any): number) >= searchResults.length) {
545 + } else if (
546 + (searchIndex as any as number) >= searchResults.length
547 + ) {
548 searchIndex = searchResults.length - 1;
549 }
550 }
551 });
552
553 addedElementIDs.forEach(id => {
551 - const element = ((store.getElementByID(id): any): Element);
554 + const element = store.getElementByID(id) as any as Element;
555
556 // It's possible that multiple tree operations will fire before this action has run.
557 // So it's important to check for elements that may have been added and then removed.
@@ -559,16 +562,16 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
562 // Add this item to the search results if it matches.
563 const regExp = createRegExp(searchText);
564 if (displayName !== null && regExp.test(displayName)) {
562 - const newElementIndex = ((store.getIndexOfElementID(
565 + const newElementIndex = store.getIndexOfElementID(
566 id,
564 - ): any): number);
567 + ) as any as number;
568
569 let foundMatch = false;
570 for (let index = 0; index < searchResults.length; index++) {
571 const resultID = searchResults[index];
572 if (
573 newElementIndex <
571 - ((store.getIndexOfElementID(resultID): any): number)
574 + (store.getIndexOfElementID(resultID) as any as number)
575 ) {
576 foundMatch = true;
577 searchResults = searchResults
@@ -591,7 +594,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
594 case 'SET_SEARCH_TEXT':
595 searchIndex = null;
596 searchResults = [];
594 - searchText = (action: ACTION_SET_SEARCH_TEXT).payload;
597 + searchText = (action as ACTION_SET_SEARCH_TEXT).payload;
598
599 if (searchText !== '') {
600 const regExp = createRegExp(searchText);
@@ -611,7 +614,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
614 }
615 } else {
616 searchIndex = Math.min(
614 - ((prevSearchIndex: any): number),
617 + prevSearchIndex as any as number,
618 searchResults.length - 1,
619 );
620 }
@@ -638,9 +641,9 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
641 }
642 }
643 if (didRequestSearch && searchIndex !== null) {
641 - inspectedElementID = ((searchResults[searchIndex]: any): number);
644 + inspectedElementID = searchResults[searchIndex] as any as number;
645 inspectedElementIndex = store.getIndexOfElementID(
643 - ((inspectedElementID: any): number),
646 + inspectedElementID as any as number,
647 );
648 }
649
@@ -706,13 +709,13 @@ function reduceOwnersState(store: Store, state: State, action: Action): State {
709 break;
710 case 'SELECT_ELEMENT_AT_INDEX':
711 if (ownerFlatTree !== null) {
709 - inspectedElementIndex = (action: ACTION_SELECT_ELEMENT_AT_INDEX)
712 + inspectedElementIndex = (action as ACTION_SELECT_ELEMENT_AT_INDEX)
713 .payload;
714 }
715 break;
716 case 'SELECT_ELEMENT_BY_ID':
717 if (ownerFlatTree !== null) {
715 - const payload = (action: ACTION_SELECT_ELEMENT_BY_ID).payload;
718 + const payload = (action as ACTION_SELECT_ELEMENT_BY_ID).payload;
719 if (payload === null) {
720 inspectedElementIndex = null;
721 } else {
@@ -752,7 +755,7 @@ function reduceOwnersState(store: Store, state: State, action: Action): State {
755 // If the Store doesn't have any owners metadata, don't drill into an empty stack.
756 // This is a confusing user experience.
757 if (store.hasOwnerMetadata) {
755 - ownerID = (action: ACTION_SELECT_OWNER).payload;
758 + ownerID = (action as ACTION_SELECT_OWNER).payload;
759 ownerFlatTree = store.getOwnersListForElement(ownerID);
760
761 // Always force reset selection to be the top of the new owner tree.
packages/react-devtools-shared/src/devtools/views/Components/ViewElementSourceContext.js
+1 -1
@@ -22,7 +22,7 @@ export type Context = {
22 };
23
24 const ViewElementSourceContext: ReactContext<Context> = createContext<Context>(
25 - ((null: any): Context),
25 + null as any as Context,
26 );
27 ViewElementSourceContext.displayName = 'ViewElementSourceContext';
28
packages/react-devtools-shared/src/devtools/views/DevTools.js
+3 -3
@@ -117,19 +117,19 @@ export type Props = {
117 };
118
119 const componentsTab = {
120 - id: ('components': TabID),
120 + id: 'components' as TabID,
121 icon: 'components',
122 label: 'Components',
123 title: 'React Components',
124 };
125 const profilerTab = {
126 - id: ('profiler': TabID),
126 + id: 'profiler' as TabID,
127 icon: 'profiler',
128 label: 'Profiler',
129 title: 'React Profiler',
130 };
131 const suspenseTab = {
132 - id: ('suspense': TabID),
132 + id: 'suspense' as TabID,
133 icon: 'suspense',
134 label: 'Suspense',
135 title: 'React Suspense',
packages/react-devtools-shared/src/devtools/views/Editor/EditorPane.js
+1 -1
@@ -115,4 +115,4 @@ function EditorPane({selectedSource}: Props) {
115 </div>
116 );
117 }
118 -export default (portaledContent(EditorPane): component());
118 +export default portaledContent(EditorPane) as component();
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/cache.js
+6 -6
@@ -74,13 +74,13 @@ export function findGitHubIssue(errorMessage: string): GitHubIssue | null {
74 };
75 const wake = () => {
76 // This assumes they won't throw.
77 - callbacks.forEach(callback => callback((thenable: any).value));
77 + callbacks.forEach(callback => callback((thenable as any).value));
78 callbacks.clear();
79 rejectCallbacks.clear();
80 };
81 const wakeRejections = () => {
82 // This assumes they won't throw.
83 - rejectCallbacks.forEach(callback => callback((thenable: any).reason));
83 + rejectCallbacks.forEach(callback => callback((thenable as any).reason));
84 rejectCallbacks.clear();
85 callbacks.clear();
86 };
@@ -96,20 +96,20 @@ export function findGitHubIssue(errorMessage: string): GitHubIssue | null {
96
97 if (maybeItem) {
98 const fulfilledThenable: FulfilledThenable<GitHubIssue> =
99 - (thenable: any);
99 + thenable as any;
100 fulfilledThenable.status = 'fulfilled';
101 fulfilledThenable.value = maybeItem;
102 wake();
103 } else {
104 const notFoundThenable: RejectedThenable<GitHubIssue> =
105 - (thenable: any);
105 + thenable as any;
106 notFoundThenable.status = 'rejected';
107 notFoundThenable.reason = null;
108 wakeRejections();
109 }
110 })
111 .catch(error => {
112 - const rejectedThenable: RejectedThenable<GitHubIssue> = (thenable: any);
112 + const rejectedThenable: RejectedThenable<GitHubIssue> = thenable as any;
113 rejectedThenable.status = 'rejected';
114 rejectedThenable.reason = null;
115 wakeRejections();
@@ -119,7 +119,7 @@ export function findGitHubIssue(errorMessage: string): GitHubIssue | null {
119 setTimeout(() => {
120 didTimeout = true;
121
122 - const timedoutThenable: RejectedThenable<GitHubIssue> = (thenable: any);
122 + const timedoutThenable: RejectedThenable<GitHubIssue> = thenable as any;
123 timedoutThenable.status = 'rejected';
124 timedoutThenable.reason = null;
125 wakeRejections();
packages/react-devtools-shared/src/devtools/views/InspectedElement/InspectedElementPane.js
+1 -1
@@ -32,4 +32,4 @@ function InspectedElementPane() {
32 </SettingsModalContextController>
33 );
34 }
35 -export default (portaledContent(InspectedElementPane): component());
35 +export default portaledContent(InspectedElementPane) as component();
packages/react-devtools-shared/src/devtools/views/ModalDialog.js
+1 -1
@@ -57,7 +57,7 @@ type ModalDialogContextType = {
57 };
58
59 const ModalDialogContext: ReactContext<ModalDialogContextType> =
60 - createContext<ModalDialogContextType>(((null: any): ModalDialogContextType));
60 + createContext<ModalDialogContextType>(null as any as ModalDialogContextType);
61 ModalDialogContext.displayName = 'ModalDialogContext';
62
63 function dialogReducer(state: State, action: Action) {
packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraph.js
+4 -4
@@ -57,13 +57,13 @@ export default function CommitFlamegraphAutoSizer(_: {}): React.Node {
57 if (selectedCommitIndex !== null) {
58 commitTree = profilingCache.getCommitTree({
59 commitIndex: selectedCommitIndex,
60 - rootID: ((rootID: any): number),
60 + rootID: rootID as any as number,
61 });
62
63 chartData = profilingCache.getFlamegraphChartData({
64 commitIndex: selectedCommitIndex,
65 commitTree,
66 - rootID: ((rootID: any): number),
66 + rootID: rootID as any as number,
67 });
68 }
69
@@ -75,8 +75,8 @@ export default function CommitFlamegraphAutoSizer(_: {}): React.Node {
75 // Force Flow types to avoid checking for `null` here because there's no static proof that
76 // by the time this render prop function is called, the values of the `let` variables have not changed.
77 <CommitFlamegraph
78 - chartData={((chartData: any): ChartData)}
79 - commitTree={((commitTree: any): CommitTree)}
78 + chartData={chartData as any as ChartData}
79 + commitTree={commitTree as any as CommitTree}
80 height={height}
81 width={width}
82 />
packages/react-devtools-shared/src/devtools/views/Profiler/CommitFlamegraphListItem.js
+2 -2
@@ -132,6 +132,6 @@ function CommitFlamegraphListItem({data, index, style}: Props): React.Node {
132 );
133 }
134
135 -export default (memo(CommitFlamegraphListItem, areEqual): component(
135 +export default memo(CommitFlamegraphListItem, areEqual) as component(
136 ...props: Props
137 -));
137 +);
packages/react-devtools-shared/src/devtools/views/Profiler/CommitRanked.js
+4 -4
@@ -57,13 +57,13 @@ export default function CommitRankedAutoSizer(_: {}): React.Node {
57 if (selectedCommitIndex !== null) {
58 commitTree = profilingCache.getCommitTree({
59 commitIndex: selectedCommitIndex,
60 - rootID: ((rootID: any): number),
60 + rootID: rootID as any as number,
61 });
62
63 chartData = profilingCache.getRankedChartData({
64 commitIndex: selectedCommitIndex,
65 commitTree,
66 - rootID: ((rootID: any): number),
66 + rootID: rootID as any as number,
67 });
68 }
69
@@ -73,8 +73,8 @@ export default function CommitRankedAutoSizer(_: {}): React.Node {
73 <AutoSizer>
74 {({height, width}) => (
75 <CommitRanked
76 - chartData={((chartData: any): ChartData)}
77 - commitTree={((commitTree: any): CommitTree)}
76 + chartData={chartData as any as ChartData}
77 + commitTree={commitTree as any as CommitTree}
78 height={height}
79 width={width}
80 />
packages/react-devtools-shared/src/devtools/views/Profiler/CommitRankedListItem.js
+2 -2
@@ -79,6 +79,6 @@ function CommitRankedListItem({data, index, style}: Props) {
79 );
80 }
81
82 -export default (memo(CommitRankedListItem, areEqual): component(
82 +export default memo(CommitRankedListItem, areEqual) as component(
83 ...props: Props
84 -));
84 +);
packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js
+25 -25
@@ -63,9 +63,9 @@ export function getCommitTree({
63 rootToCommitTreeMap.set(rootID, []);
64 }
65
66 - const commitTrees = ((rootToCommitTreeMap.get(
66 + const commitTrees = rootToCommitTreeMap.get(
67 rootID,
68 - ): any): Array<CommitTree>);
68 + ) as any as Array<CommitTree>;
69 if (commitIndex < commitTrees.length) {
70 return commitTrees[commitIndex];
71 }
@@ -87,7 +87,7 @@ export function getCommitTree({
87 );
88 }
89
90 - let commitTree: CommitTree = ((null: any): CommitTree);
90 + let commitTree: CommitTree = null as any as CommitTree;
91 for (let index = commitTrees.length; index <= commitIndex; index++) {
92 // Commits are generated sequentially and cached.
93 // If this is the very first commit, start with the cached snapshot and apply the first mutation.
@@ -140,9 +140,9 @@ function recursivelyInitializeTree(
140 hocDisplayNames: node.hocDisplayNames,
141 key: node.key,
142 parentID,
143 - treeBaseDuration: ((dataForRoot.initialTreeBaseDurations.get(
143 + treeBaseDuration: dataForRoot.initialTreeBaseDurations.get(
144 id,
145 - ): any): number),
145 + ) as any as number,
146 type: node.type,
147 compiledWithForget: node.compiledWithForget,
148 });
@@ -175,7 +175,7 @@ function updateTree(
175 };
176
177 let i = 2;
178 - let id: number = ((null: any): number);
178 + let id: number = null as any as number;
179
180 // Reassemble the string table.
181 const stringTable: Array<null | string> = [
@@ -199,8 +199,8 @@ function updateTree(
199
200 switch (operation) {
201 case TREE_OPERATION_ADD: {
202 - id = ((operations[i + 1]: any): number);
203 - const type = ((operations[i + 2]: any): ElementType);
202 + id = operations[i + 1] as any as number;
203 + const type = operations[i + 2] as any as ElementType;
204
205 i += 3;
206
@@ -235,7 +235,7 @@ function updateTree(
235
236 nodes.set(id, node);
237 } else {
238 - const parentID = ((operations[i]: any): number);
238 + const parentID = operations[i] as any as number;
239 i++;
240
241 i++; // ownerID
@@ -283,11 +283,11 @@ function updateTree(
283 break;
284 }
285 case TREE_OPERATION_REMOVE: {
286 - const removeLength = ((operations[i + 1]: any): number);
286 + const removeLength = operations[i + 1] as any as number;
287 i += 2;
288
289 for (let removeIndex = 0; removeIndex < removeLength; removeIndex++) {
290 - id = ((operations[i]: any): number);
290 + id = operations[i] as any as number;
291 i++;
292
293 if (!nodes.has(id)) {
@@ -319,12 +319,12 @@ function updateTree(
319 break;
320 }
321 case TREE_OPERATION_REORDER_CHILDREN: {
322 - id = ((operations[i + 1]: any): number);
323 - const numChildren = ((operations[i + 2]: any): number);
324 - const children = ((operations.slice(
322 + id = operations[i + 1] as any as number;
323 + const numChildren = operations[i + 2] as any as number;
324 + const children = operations.slice(
325 i + 3,
326 i + 3 + numChildren,
327 - ): any): Array<number>);
327 + ) as any as Array<number>;
328
329 i = i + 3 + numChildren;
330
@@ -414,19 +414,19 @@ function updateTree(
414 }
415
416 case SUSPENSE_TREE_OPERATION_REMOVE: {
417 - const removeLength = ((operations[i + 1]: any): number);
417 + const removeLength = operations[i + 1] as any as number;
418 i += 2 + removeLength;
419
420 break;
421 }
422
423 case SUSPENSE_TREE_OPERATION_REORDER_CHILDREN: {
424 - const suspenseID = ((operations[i + 1]: any): number);
425 - const numChildren = ((operations[i + 2]: any): number);
426 - const children = ((operations.slice(
424 + const suspenseID = operations[i + 1] as any as number;
425 + const numChildren = operations[i + 2] as any as number;
426 + const children = operations.slice(
427 i + 3,
428 i + 3 + numChildren,
429 - ): any): Array<number>);
429 + ) as any as Array<number>;
430
431 i = i + 3 + numChildren;
432
@@ -442,18 +442,18 @@ function updateTree(
442 }
443
444 case SUSPENSE_TREE_OPERATION_RESIZE: {
445 - const suspenseID = ((operations[i + 1]: any): number);
446 - const numRects = ((operations[i + 2]: any): number);
445 + const suspenseID = operations[i + 1] as any as number;
446 + const numRects = operations[i + 2] as any as number;
447
448 // $FlowFixMe[constant-condition]
449 if (__DEBUG__) {
450 if (numRects === -1) {
451 debug('Suspense resize', `suspense ${suspenseID} rects null`);
452 } else {
453 - const rects = ((operations.slice(
453 + const rects = operations.slice(
454 i + 3,
455 i + 3 + numRects * 4,
456 - ): any): Array<number>);
456 + ) as any as Array<number>;
457 debug(
458 'Suspense resize',
459 `suspense ${suspenseID} rects [${rects.join(',')}]`,
@@ -468,7 +468,7 @@ function updateTree(
468
469 case SUSPENSE_TREE_OPERATION_SUSPENDERS: {
470 i++;
471 - const changeLength = ((operations[i++]: any): number);
471 + const changeLength = operations[i++] as any as number;
472
473 for (let changeIndex = 0; changeIndex < changeLength; changeIndex++) {
474 const suspenseNodeId = operations[i++];
packages/react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder.js
+1 -1
@@ -52,7 +52,7 @@ export function getChartData({
52
53 const chartDataKey = `${rootID}-${commitIndex}`;
54 if (cachedChartData.has(chartDataKey)) {
55 - return ((cachedChartData.get(chartDataKey): any): ChartData);
55 + return cachedChartData.get(chartDataKey) as any as ChartData;
56 }
57
58 const idToDepthMap: Map<number, number> = new Map();
packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js
+1 -1
@@ -57,7 +57,7 @@ export default function HoveredFiberInfo({fiberData}: Props): React.Node {
57 const commitIndex = commitIndices[i];
58 if (selectedCommitIndex === commitIndex) {
59 const {fiberActualDurations, fiberSelfDurations} =
60 - profilerStore.getCommitData(((rootID: any): number), commitIndex);
60 + profilerStore.getCommitData(rootID as any as number, commitIndex);
61 const actualDuration = fiberActualDurations.get(id) || 0;
62 const selfDuration = fiberSelfDurations.get(id) || 0;
63
packages/react-devtools-shared/src/devtools/views/Profiler/Profiler.js
+1 -1
@@ -243,4 +243,4 @@ const tabsWithTimeline = [
243 },
244 ];
245
246 -export default (portaledContent(Profiler): component());
246 +export default portaledContent(Profiler) as component();
packages/react-devtools-shared/src/devtools/views/Profiler/ProfilerContext.js
+3 -3
@@ -83,7 +83,7 @@ export type Context = {
83 };
84
85 const ProfilerContext: ReactContext<Context> = createContext<Context>(
86 - ((null: any): Context),
86 + null as any as Context,
87 );
88 ProfilerContext.displayName = 'ProfilerContext';
89
@@ -228,12 +228,12 @@ function ProfilerContextController({children}: Props): React.Node {
228 // Always check didRecordCommits before using commitData or filteredCommitIndices.
229 const commitData = useMemo(() => {
230 if (!didRecordCommits || rootID === null || profilingData === null) {
231 - return ([]: Array<CommitDataFrontend>);
231 + return [] as Array<CommitDataFrontend>;
232 }
233 const dataForRoot = profilingData.dataForRoots.get(rootID);
234 return dataForRoot
235 ? dataForRoot.commitData
236 - : ([]: Array<CommitDataFrontend>);
236 + : ([] as Array<CommitDataFrontend>);
237 }, [didRecordCommits, rootID, profilingData]);
238
239 // Commit filtering and navigation
packages/react-devtools-shared/src/devtools/views/Profiler/ProfilingImportExportButtons.js
+2 -2
@@ -86,7 +86,7 @@ export default function ProfilingImportExportButtons(): React.Node {
86 // TODO (profiling) Handle fileReader errors.
87 const fileReader = new FileReader();
88 fileReader.addEventListener('load', () => {
89 - const raw = ((fileReader.result: any): string);
89 + const raw = fileReader.result as any as string;
90 const json = JSON.parse(raw);
91
92 if (!isArray(json) && hasOwnProperty.call(json, 'version')) {
@@ -95,7 +95,7 @@ export default function ProfilingImportExportButtons(): React.Node {
95 setFile(null);
96
97 try {
98 - const profilingDataExport = ((json: any): ProfilingDataExport);
98 + const profilingDataExport = json as any as ProfilingDataExport;
99 profilerStore.profilingData =
100 prepareProfilingDataFrontendFromExport(profilingDataExport);
101 } catch (error) {
packages/react-devtools-shared/src/devtools/views/Profiler/RankedChartBuilder.js
+1 -1
@@ -48,7 +48,7 @@ export function getChartData({
48
49 const chartDataKey = `${rootID}-${commitIndex}`;
50 if (cachedChartData.has(chartDataKey)) {
51 - return ((cachedChartData.get(chartDataKey): any): ChartData);
51 + return cachedChartData.get(chartDataKey) as any as ChartData;
52 }
53
54 let maxSelfDuration = 0;
packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js
+2 -2
@@ -97,7 +97,7 @@ export default function SidebarSelectedFiberInfo(): React.Node {
97 const commitIndex = commitIndices[i];
98
99 const {duration, timestamp} = profilerStore.getCommitData(
100 - ((rootID: any): number),
100 + rootID as any as number,
101 commitIndex,
102 );
103
@@ -136,7 +136,7 @@ export default function SidebarSelectedFiberInfo(): React.Node {
136 compiledWithForget={node.compiledWithForget}
137 />
138 )}
139 - <WhatChanged fiberID={((selectedFiberID: any): number)} />
139 + <WhatChanged fiberID={selectedFiberID as any as number} />
140 {listItems.length > 0 && (
141 <div>
142 <label className={styles.Label}>Rendered at: </label>
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js
+5 -1
@@ -292,7 +292,11 @@ function List({
292 itemCount={filteredCommitIndices.length}
293 itemData={itemData}
294 itemSize={itemSize}
295 - ref={(listRef: any) /* Flow bug? */}
295 + ref={
296 + listRef as any
297 +
298 + /* Flow bug? */
299 + }
300 width={width}>
301 {SnapshotCommitListItem}
302 </FixedSizeList>
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitListItem.js
+2 -2
@@ -96,6 +96,6 @@ function SnapshotCommitListItem({data: itemData, index, style}: Props) {
96 );
97 }
98
99 -export default (memo(SnapshotCommitListItem, areEqual): component(
99 +export default memo(SnapshotCommitListItem, areEqual) as component(
100 ...props: Props
101 -));
101 +);
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js
+1 -1
@@ -32,7 +32,7 @@ export default function SnapshotSelector(_: Props): React.Node {
32 } = useContext(ProfilerContext);
33
34 const {profilerStore} = useContext(StoreContext);
35 - const {commitData} = profilerStore.getDataForRoot(((rootID: any): number));
35 + const {commitData} = profilerStore.getDataForRoot(rootID as any as number);
36
37 const totalDurations: Array<number> = [];
38 const commitTimes: Array<number> = [];
packages/react-devtools-shared/src/devtools/views/Profiler/WhatChanged.js
+1 -1
@@ -37,7 +37,7 @@ export default function WhatChanged({
37 }
38
39 const {changeDescriptions} = profilerStore.getCommitData(
40 - ((rootID: any): number),
40 + rootID as any as number,
41 selectedCommitIndex,
42 );
43
packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js
+1 -1
@@ -60,7 +60,7 @@ export function useCommitFilteringAndNavigation(
60 reduced.push(index);
61 }
62 return reduced;
63 - }, ([]: Array<number>));
63 + }, [] as Array<number>);
64 },
65 [commitData],
66 );
packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js
+7 -7
@@ -281,7 +281,7 @@ export default function ComponentsSettings({
281 if (index >= 0) {
282 if (componentFilter.type === ComponentFilterElementType) {
283 cloned[index] = {
284 - ...((cloned[index]: any): ElementTypeComponentFilter),
284 + ...(cloned[index] as any as ElementTypeComponentFilter),
285 isEnabled,
286 };
287 } else if (
@@ -289,17 +289,17 @@ export default function ComponentsSettings({
289 componentFilter.type === ComponentFilterLocation
290 ) {
291 cloned[index] = {
292 - ...((cloned[index]: any): RegExpComponentFilter),
292 + ...(cloned[index] as any as RegExpComponentFilter),
293 isEnabled,
294 };
295 } else if (componentFilter.type === ComponentFilterHOC) {
296 cloned[index] = {
297 - ...((cloned[index]: any): BooleanComponentFilter),
297 + ...(cloned[index] as any as BooleanComponentFilter),
298 isEnabled,
299 };
300 } else if (componentFilter.type === ComponentFilterEnvironmentName) {
301 cloned[index] = {
302 - ...((cloned[index]: any): EnvironmentNameComponentFilter),
302 + ...(cloned[index] as any as EnvironmentNameComponentFilter),
303 isEnabled,
304 };
305 }
@@ -404,10 +404,10 @@ export default function ComponentsSettings({
404 onChange={({currentTarget}) =>
405 changeFilterType(
406 componentFilter,
407 - ((parseInt(
407 + parseInt(
408 currentTarget.value,
409 10,
410 - ): any): ComponentFilterType),
410 + ) as any as ComponentFilterType,
411 )
412 }>
413 {/* TODO: currently disabled, need find a new way of doing this
@@ -445,7 +445,7 @@ export default function ComponentsSettings({
445 onChange={({currentTarget}) =>
446 updateFilterValueElementType(
447 componentFilter,
448 - ((parseInt(currentTarget.value, 10): any): ElementType),
448 + parseInt(currentTarget.value, 10) as any as ElementType,
449 )
450 }>
451 {isInternalFacebookBuild && (
packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js
+10 -10
@@ -56,7 +56,7 @@ type Context = {
56 };
57
58 const SettingsContext: ReactContext<Context> = createContext<Context>(
59 - ((null: any): Context),
59 + null as any as Context,
60 );
61 SettingsContext.displayName = 'SettingsContext';
62
@@ -116,24 +116,24 @@ function SettingsContextController({
116
117 const documentElements = useMemo<DocumentElements>(() => {
118 const array: Array<HTMLElement> = [
119 - ((document.documentElement: any): HTMLElement),
119 + document.documentElement as any as HTMLElement,
120 ];
121 if (componentsPortalContainer != null) {
122 array.push(
123 - ((componentsPortalContainer.ownerDocument
124 - .documentElement: any): HTMLElement),
123 + componentsPortalContainer.ownerDocument
124 + .documentElement as any as HTMLElement,
125 );
126 }
127 if (profilerPortalContainer != null) {
128 array.push(
129 - ((profilerPortalContainer.ownerDocument
130 - .documentElement: any): HTMLElement),
129 + profilerPortalContainer.ownerDocument
130 + .documentElement as any as HTMLElement,
131 );
132 }
133 if (suspensePortalContainer != null) {
134 array.push(
135 - ((suspensePortalContainer.ownerDocument
136 - .documentElement: any): HTMLElement),
135 + suspensePortalContainer.ownerDocument
136 + .documentElement as any as HTMLElement,
137 );
138 }
139 return array;
@@ -218,11 +218,11 @@ export function updateDisplayDensity(
218 ): void {
219 // Sizes and paddings/margins are all rem-based,
220 // so update the root font-size as well when the display preference changes.
221 - const computedStyle = getComputedStyle((document.body: any));
221 + const computedStyle = getComputedStyle(document.body as any);
222 const fontSize = computedStyle.getPropertyValue(
223 `--${displayDensity}-root-font-size`,
224 );
225 - const root = ((document.querySelector(':root'): any): HTMLElement);
225 + const root = document.querySelector(':root') as any as HTMLElement;
226 root.style.fontSize = fontSize;
227 }
228
packages/react-devtools-shared/src/devtools/views/Settings/SettingsModalContext.js
+1 -1
@@ -34,7 +34,7 @@ type Context = {
34 };
35
36 const SettingsModalContext: ReactContext<Context> = createContext<Context>(
37 - ((null: any): Context),
37 + null as any as Context,
38 );
39 SettingsModalContext.displayName = 'SettingsModalContext';
40
packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js
+1 -1
@@ -451,7 +451,7 @@ function SuspenseRectsTransition({id}: {id: Element['id']}): React$Node {
451 });
452 }
453
454 -const ViewBox = createContext<Rect>((null: any));
454 +const ViewBox = createContext<Rect>(null as any);
455
456 function SuspenseRectsContainer({
457 scaleRef,
packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTab.js
+1 -1
@@ -645,4 +645,4 @@ function setResizeCSSVariable(
645 }
646 }
647
648 -export default (portaledContent(SuspenseTab): component());
648 +export default portaledContent(SuspenseTab) as component();
packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTreeContext.js
+2 -2
@@ -97,11 +97,11 @@ export type SuspenseTreeAction =
97 export type SuspenseTreeDispatch = (action: SuspenseTreeAction) => void;
98
99 const SuspenseTreeStateContext: ReactContext<SuspenseTreeState> =
100 - createContext<SuspenseTreeState>(((null: any): SuspenseTreeState));
100 + createContext<SuspenseTreeState>(null as any as SuspenseTreeState);
101 SuspenseTreeStateContext.displayName = 'SuspenseTreeStateContext';
102
103 const SuspenseTreeDispatcherContext: ReactContext<SuspenseTreeDispatch> =
104 - createContext<SuspenseTreeDispatch>(((null: any): SuspenseTreeDispatch));
104 + createContext<SuspenseTreeDispatch>(null as any as SuspenseTreeDispatch);
105 SuspenseTreeDispatcherContext.displayName = 'SuspenseTreeDispatcherContext';
106
107 type Props = {
packages/react-devtools-shared/src/devtools/views/TabBar.js
+1 -1
@@ -41,7 +41,7 @@ export default function TabBar({
41 type,
42 }: Props): React.Node {
43 if (!tabs.some(tab => tab !== null && tab.id === currentTab)) {
44 - const firstTab = ((tabs.find(tab => tab !== null): any): TabInfo);
44 + const firstTab = tabs.find(tab => tab !== null) as any as TabInfo;
45 selectTab(firstTab.id);
46 }
47
packages/react-devtools-shared/src/devtools/views/context.js
+2 -2
@@ -15,11 +15,11 @@ import type {ViewAttributeSource} from 'react-devtools-shared/src/devtools/views
15 import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
16
17 export const BridgeContext: ReactContext<FrontendBridge> =
18 - createContext<FrontendBridge>(((null: any): FrontendBridge));
18 + createContext<FrontendBridge>(null as any as FrontendBridge);
19 BridgeContext.displayName = 'BridgeContext';
20
21 export const StoreContext: ReactContext<Store> = createContext<Store>(
22 - ((null: any): Store),
22 + null as any as Store,
23 );
24 StoreContext.displayName = 'StoreContext';
25
packages/react-devtools-shared/src/devtools/views/hooks.js
+2 -2
@@ -165,7 +165,7 @@ export function useLocalStorage<T>(
165 console.log(error);
166 }
167 if (typeof initialValue === 'function') {
168 - return ((initialValue: any): () => T)();
168 + return (initialValue as any as () => T)();
169 } else {
170 return initialValue;
171 }
@@ -188,7 +188,7 @@ export function useLocalStorage<T>(
188 (value: $FlowFixMe) => {
189 try {
190 const valueToStore =
191 - value instanceof Function ? (value: any)(storedValue) : value;
191 + value instanceof Function ? (value as any)(storedValue) : value;
192 localStorageSetItem(key, JSON.stringify(valueToStore));
193
194 // Notify listeners that this setting has changed.
packages/react-devtools-shared/src/devtools/views/utils.js
+1 -1
@@ -134,7 +134,7 @@ export function serializeDataForCopy(props: Object): string {
134
135 export function serializeHooksForCopy(hooks: HooksTree | null): string {
136 // $FlowFixMe[not-an-object] "HooksTree is not an object"
137 - const cloned = Object.assign(([]: Array<any>), hooks);
137 + const cloned = Object.assign([] as Array<any>, hooks);
138
139 const queue = [...cloned];
140
packages/react-devtools-shared/src/dynamicImportCache.js
+4 -4
@@ -93,7 +93,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module {
93 }
94
95 // This assumes they won't throw.
96 - rejectCallbacks.forEach(callback => callback((thenable: any).reason));
96 + rejectCallbacks.forEach(callback => callback((thenable as any).reason));
97 rejectCallbacks.clear();
98 callbacks.clear();
99 };
@@ -115,7 +115,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module {
115 return;
116 }
117
118 - const fulfilledThenable: FulfilledThenable<Module> = (thenable: any);
118 + const fulfilledThenable: FulfilledThenable<Module> = thenable as any;
119 fulfilledThenable.status = 'fulfilled';
120 fulfilledThenable.value = module;
121
@@ -135,7 +135,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module {
135
136 console.log(error);
137
138 - const rejectedThenable: RejectedThenable<Module> = (thenable: any);
138 + const rejectedThenable: RejectedThenable<Module> = thenable as any;
139 rejectedThenable.status = 'rejected';
140 rejectedThenable.reason = error;
141
@@ -156,7 +156,7 @@ export function loadModule(moduleLoaderFunction: ModuleLoaderFunction): Module {
156
157 didTimeout = true;
158
159 - const rejectedThenable: RejectedThenable<Module> = (thenable: any);
159 + const rejectedThenable: RejectedThenable<Module> = thenable as any;
160 rejectedThenable.status = 'rejected';
161 rejectedThenable.reason = null;
162
packages/react-devtools-shared/src/hook.js
+10 -14
@@ -493,7 +493,7 @@ export function installHook(
493 // The backend is what implements a message queue, so it's the only one that injects onErrorOrWarning.
494 if (onErrorOrWarning != null) {
495 onErrorOrWarning(
496 - ((method: any): 'error' | 'warn'),
496 + method as any as 'error' | 'warn',
497 args.slice(),
498 );
499 }
@@ -699,19 +699,15 @@ export function installHook(
699 });
700 }
701
702 - Object.defineProperty(
703 - target,
704 - '__REACT_DEVTOOLS_GLOBAL_HOOK__',
705 - ({
706 - // This property needs to be configurable for the test environment,
707 - // else we won't be able to delete and recreate it between tests.
708 - configurable: __DEV__,
709 - enumerable: false,
710 - get() {
711 - return hook;
712 - },
713 - }: Object),
714 - );
702 + Object.defineProperty(target, '__REACT_DEVTOOLS_GLOBAL_HOOK__', {
703 + // This property needs to be configurable for the test environment,
704 + // else we won't be able to delete and recreate it between tests.
705 + configurable: __DEV__,
706 + enumerable: false,
707 + get() {
708 + return hook;
709 + },
710 + } as Object);
711
712 return hook;
713 }
packages/react-devtools-shared/src/hookNamesCache.js
+6 -6
@@ -115,7 +115,7 @@ export function loadHookNames(
115 }
116
117 // This assumes they won't throw.
118 - callbacks.forEach(callback => callback((thenable: any).value));
118 + callbacks.forEach(callback => callback((thenable as any).value));
119 callbacks.clear();
120 rejectCallbacks.clear();
121 };
@@ -125,7 +125,7 @@ export function loadHookNames(
125 timeoutID = null;
126 }
127 // This assumes they won't throw.
128 - rejectCallbacks.forEach(callback => callback((thenable: any).reason));
128 + rejectCallbacks.forEach(callback => callback((thenable as any).reason));
129 rejectCallbacks.clear();
130 callbacks.clear();
131 };
@@ -159,7 +159,7 @@ export function loadHookNames(
159
160 if (hookNames) {
161 const fulfilledThenable: FulfilledThenable<HookNames> =
162 - (thenable: any);
162 + thenable as any;
163 fulfilledThenable.status = 'fulfilled';
164 fulfilledThenable.value = hookNames;
165 status = 'success';
@@ -168,7 +168,7 @@ export function loadHookNames(
168 wake();
169 } else {
170 const notFoundThenable: RejectedThenable<HookNames> =
171 - (thenable: any);
171 + thenable as any;
172 notFoundThenable.status = 'rejected';
173 notFoundThenable.reason = null;
174 status = 'error';
@@ -190,7 +190,7 @@ export function loadHookNames(
190 console.error(error);
191
192 const rejectedThenable: RejectedThenable<HookNames> =
193 - (thenable: any);
193 + thenable as any;
194 rejectedThenable.status = 'rejected';
195 rejectedThenable.reason = null;
196
@@ -211,7 +211,7 @@ export function loadHookNames(
211
212 didTimeout = true;
213
214 - const timedoutThenable: RejectedThenable<HookNames> = (thenable: any);
214 + const timedoutThenable: RejectedThenable<HookNames> = thenable as any;
215 timedoutThenable.status = 'rejected';
216 timedoutThenable.reason = null;
217
packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
+8 -8
@@ -39,9 +39,9 @@ export default function SourceMapConsumer(
39 sourceMapJSON: MixedSourceMap | IndexSourceMapSection,
40 ): SourceMapConsumerType {
41 if (sourceMapJSON.sections != null) {
42 - return IndexedSourceMapConsumer(((sourceMapJSON: any): IndexSourceMap));
42 + return IndexedSourceMapConsumer(sourceMapJSON as any as IndexSourceMap);
43 } else {
44 - return BasicSourceMapConsumer(((sourceMapJSON: any): BasicSourceMap));
44 + return BasicSourceMapConsumer(sourceMapJSON as any as BasicSourceMap);
45 }
46 }
47
@@ -124,15 +124,15 @@ function BasicSourceMapConsumer(sourceMapJSON: BasicSourceMap) {
124 return {
125 column,
126 line,
127 - sourceContent: ((sourceContent: any): string | null),
128 - sourceURL: ((sourceURL: any): string | null),
127 + sourceContent: sourceContent as any as string | null,
128 + sourceURL: sourceURL as any as string | null,
129 ignored,
130 };
131 }
132
133 - return (({
133 + return {
134 originalPositionFor,
135 - }: any): SourceMapConsumerType);
135 + } as any as SourceMapConsumerType;
136 }
137
138 type Section = {
@@ -231,7 +231,7 @@ function IndexedSourceMapConsumer(sourceMapJSON: IndexSourceMap) {
231 });
232 }
233
234 - return (({
234 + return {
235 originalPositionFor,
236 - }: any): SourceMapConsumerType);
236 + } as any as SourceMapConsumerType;
237 }
packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js
+8 -6
@@ -141,7 +141,7 @@ function extractAndLoadSourceMapJSON(
141 locationKeyToHookSourceAndMetadata.forEach(hookSourceAndMetadata => {
142 const sourceMapRegex = / ?sourceMappingURL=([^\s'"]+)/gm;
143 const runtimeSourceCode =
144 - ((hookSourceAndMetadata.runtimeSourceCode: any): string);
144 + hookSourceAndMetadata.runtimeSourceCode as any as string;
145
146 // TODO (named hooks) Search for our custom metadata first.
147 // If it's found, we should use it rather than source maps.
@@ -175,9 +175,11 @@ function extractAndLoadSourceMapJSON(
175 // Web apps like Code Sandbox embed multiple inline source maps.
176 // In this case, we need to loop through and find the right one.
177 // We may also need to trim any part of this string that isn't based64 encoded data.
178 - const trimmed = ((sourceMappingURL.match(
179 - /base64,([a-zA-Z0-9+\/=]+)/,
180 - ): any): Array<string>)[1];
178 + const trimmed = (
179 + sourceMappingURL.match(
180 + /base64,([a-zA-Z0-9+\/=]+)/,
181 + ) as any as Array<string>
182 + )[1];
183 const decoded = withSyncPerfMeasurements(
184 'decodeBase64String()',
185 () => decodeBase64String(trimmed),
@@ -431,7 +433,7 @@ function initializeHookSourceAndMetadata(
433 const locationKey = getHookSourceLocationKey(hookSource);
434 if (!locationKeyToHookSourceAndMetadata.has(locationKey)) {
435 // Can't be null because getHookSourceLocationKey() would have thrown
434 - const runtimeSourceURL = ((hookSource.fileName: any): string);
436 + const runtimeSourceURL = hookSource.fileName as any as string;
437
438 const hookSourceAndMetadata: HookSourceAndMetadata = {
439 hookSource,
@@ -477,7 +479,7 @@ function loadSourceFiles(
479 return withAsyncPerfMeasurements(
480 `fetchFileWithCaching("${url}")`,
481 () => {
480 - return ((fetchFileWithCaching: any): FetchFileWithCaching)(url);
482 + return (fetchFileWithCaching as any as FetchFileWithCaching)(url);
483 },
484 );
485 };
packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js
+4 -4
@@ -129,7 +129,7 @@ function findHookNames(
129
130 hooksList.map(hook => {
131 // We already guard against a null HookSource in parseHookNames()
132 - const hookSource = ((hook.hookSource: any): HookSource);
132 + const hookSource = hook.hookSource as any as HookSource;
133 const fileName = hookSource.fileName;
134 if (!fileName) {
135 return null; // Should not be reachable.
@@ -177,8 +177,8 @@ function findHookNames(
177 getHookName(
178 hook,
179 hookParsedMetadata.originalSourceAST,
180 - ((hookParsedMetadata.originalSourceCode: any): string),
181 - ((originalSourceLineNumber: any): number),
180 + hookParsedMetadata.originalSourceCode as any as string,
181 + originalSourceLineNumber as any as number,
182 originalSourceColumnNumber,
183 ),
184 );
@@ -255,7 +255,7 @@ function parseSourceAST(
255
256 const {metadataConsumer, sourceMapConsumer} = hookParsedMetadata;
257 const runtimeSourceCode =
258 - ((hookSourceAndMetadata.runtimeSourceCode: any): string);
258 + hookSourceAndMetadata.runtimeSourceCode as any as string;
259 let hasHookMap = false;
260 let originalSourceURL;
261 let originalSourceCode;
packages/react-devtools-shared/src/hydration.js
+9 -9
@@ -26,15 +26,15 @@ import type {
26 import noop from 'shared/noop';
27
28 export const meta = {
29 - inspectable: (Symbol('inspectable'): symbol),
30 - inspected: (Symbol('inspected'): symbol),
31 - name: (Symbol('name'): symbol),
32 - preview_long: (Symbol('preview_long'): symbol),
33 - preview_short: (Symbol('preview_short'): symbol),
34 - readonly: (Symbol('readonly'): symbol),
35 - size: (Symbol('size'): symbol),
36 - type: (Symbol('type'): symbol),
37 - unserializable: (Symbol('unserializable'): symbol),
29 + inspectable: Symbol('inspectable') as symbol,
30 + inspected: Symbol('inspected') as symbol,
31 + name: Symbol('name') as symbol,
32 + preview_long: Symbol('preview_long') as symbol,
33 + preview_short: Symbol('preview_short') as symbol,
34 + readonly: Symbol('readonly') as symbol,
35 + size: Symbol('size') as symbol,
36 + type: Symbol('type') as symbol,
37 + unserializable: Symbol('unserializable') as symbol,
38 };
39
40 export type Dehydrated = {
packages/react-devtools-shared/src/inspectedElementCache.js
+5 -5
@@ -101,13 +101,13 @@ export function inspectElement(
101
102 const wake = () => {
103 // This assumes they won't throw.
104 - callbacks.forEach(callback => callback((thenable: any).value));
104 + callbacks.forEach(callback => callback((thenable as any).value));
105 callbacks.clear();
106 rejectCallbacks.clear();
107 };
108 const wakeRejections = () => {
109 // This assumes they won't throw.
110 - rejectCallbacks.forEach(callback => callback((thenable: any).reason));
110 + rejectCallbacks.forEach(callback => callback((thenable as any).reason));
111 rejectCallbacks.clear();
112 callbacks.clear();
113 };
@@ -116,7 +116,7 @@ export function inspectElement(
116 const rendererID = store.getRendererIDForElement(element.id);
117 if (rendererID == null) {
118 const rejectedThenable: RejectedThenable<InspectedElementFrontend> =
119 - (thenable: any);
119 + thenable as any;
120 rejectedThenable.status = 'rejected';
121 rejectedThenable.reason = new Error(
122 `Could not inspect element with id "${element.id}". No renderer found.`,
@@ -133,7 +133,7 @@ export function inspectElement(
133 InspectedElementResponseType,
134 ]) => {
135 const fulfilledThenable: FulfilledThenable<InspectedElementFrontend> =
136 - (thenable: any);
136 + thenable as any;
137 fulfilledThenable.status = 'fulfilled';
138 fulfilledThenable.value = inspectedElement;
139 wake();
@@ -143,7 +143,7 @@ export function inspectElement(
143 console.error(error);
144
145 const rejectedThenable: RejectedThenable<InspectedElementFrontend> =
146 - (thenable: any);
146 + thenable as any;
147 rejectedThenable.status = 'rejected';
148 rejectedThenable.reason = error;
149
packages/react-devtools-shared/src/inspectedElementMutableSource.js
+3 -3
@@ -88,7 +88,7 @@ export function inspectElement(
88 let inspectedElement;
89 switch (type) {
90 case 'error': {
91 - const {message, stack, errorType} = ((data: any): InspectElementError);
91 + const {message, stack, errorType} = data as any as InspectElementError;
92
93 // create a different error class for each error type
94 // and keep useful information from backend.
@@ -124,7 +124,7 @@ export function inspectElement(
124 throw Error(`Element "${id}" not found`);
125
126 case 'full-data':
127 - const fullData = ((data: any): InspectElementFullData);
127 + const fullData = data as any as InspectElementFullData;
128
129 // New data has come in.
130 // We should replace the data in our local mutable copy.
@@ -137,7 +137,7 @@ export function inspectElement(
137 return [inspectedElement, type];
138
139 case 'hydrated-path':
140 - const hydratedPathData = ((data: any): InspectElementHydratedPath);
140 + const hydratedPathData = data as any as InspectElementHydratedPath;
141 const {value} = hydratedPathData;
142
143 // A path has been hydrated.
packages/react-devtools-shared/src/utils.js
+17 -17
@@ -138,7 +138,7 @@ export function getWrappedDisplayName(
138 wrapperName: string,
139 fallbackName?: string,
140 ): string {
141 - const displayName = (outerType: any)?.displayName;
141 + const displayName = (outerType as any)?.displayName;
142 return (
143 displayName || `${wrapperName}(${getDisplayName(innerType, fallbackName)})`
144 );
@@ -251,8 +251,8 @@ export function printOperationsArray(operations: Array<number>) {
251
252 switch (operation) {
253 case TREE_OPERATION_ADD: {
254 - const id = ((operations[i + 1]: any): number);
255 - const type = ((operations[i + 2]: any): ElementType);
254 + const id = operations[i + 1] as any as number;
255 + const type = operations[i + 2] as any as ElementType;
256
257 i += 3;
258
@@ -264,7 +264,7 @@ export function printOperationsArray(operations: Array<number>) {
264 i++; // supportsStrictMode
265 i++; // hasOwnerMetadata
266 } else {
267 - const parentID = ((operations[i]: any): number);
267 + const parentID = operations[i] as any as number;
268 i++;
269
270 i++; // ownerID
@@ -283,11 +283,11 @@ export function printOperationsArray(operations: Array<number>) {
283 break;
284 }
285 case TREE_OPERATION_REMOVE: {
286 - const removeLength = ((operations[i + 1]: any): number);
286 + const removeLength = operations[i + 1] as any as number;
287 i += 2;
288
289 for (let removeIndex = 0; removeIndex < removeLength; removeIndex++) {
290 - const id = ((operations[i]: any): number);
290 + const id = operations[i] as any as number;
291 i += 1;
292
293 logs.push(`Remove node ${id}`);
@@ -304,8 +304,8 @@ export function printOperationsArray(operations: Array<number>) {
304 break;
305 }
306 case TREE_OPERATION_REORDER_CHILDREN: {
307 - const id = ((operations[i + 1]: any): number);
308 - const numChildren = ((operations[i + 2]: any): number);
307 + const id = operations[i + 1] as any as number;
308 + const numChildren = operations[i + 2] as any as number;
309 i += 3;
310 const children = operations.slice(i, i + numChildren);
311 i += numChildren;
@@ -369,11 +369,11 @@ export function printOperationsArray(operations: Array<number>) {
369 break;
370 }
371 case SUSPENSE_TREE_OPERATION_REMOVE: {
372 - const removeLength = ((operations[i + 1]: any): number);
372 + const removeLength = operations[i + 1] as any as number;
373 i += 2;
374
375 for (let removeIndex = 0; removeIndex < removeLength; removeIndex++) {
376 - const id = ((operations[i]: any): number);
376 + const id = operations[i] as any as number;
377 i += 1;
378
379 logs.push(`Remove suspense node ${id}`);
@@ -382,8 +382,8 @@ export function printOperationsArray(operations: Array<number>) {
382 break;
383 }
384 case SUSPENSE_TREE_OPERATION_REORDER_CHILDREN: {
385 - const id = ((operations[i + 1]: any): number);
386 - const numChildren = ((operations[i + 2]: any): number);
385 + const id = operations[i + 1] as any as number;
386 + const numChildren = operations[i + 2] as any as number;
387 i += 3;
388 const children = operations.slice(i, i + numChildren);
389 i += numChildren;
@@ -394,8 +394,8 @@ export function printOperationsArray(operations: Array<number>) {
394 break;
395 }
396 case SUSPENSE_TREE_OPERATION_RESIZE: {
397 - const id = ((operations[i + 1]: any): number);
398 - const numRects = ((operations[i + 2]: any): number);
397 + const id = operations[i + 1] as any as number;
398 + const numRects = operations[i + 2] as any as number;
399 i += 3;
400
401 if (numRects === -1) {
@@ -422,7 +422,7 @@ export function printOperationsArray(operations: Array<number>) {
422 }
423 case SUSPENSE_TREE_OPERATION_SUSPENDERS: {
424 i++;
425 - const changeLength = ((operations[i++]: any): number);
425 + const changeLength = operations[i++] as any as number;
426
427 for (let changeIndex = 0; changeIndex < changeLength; changeIndex++) {
428 const id = operations[i++];
@@ -651,7 +651,7 @@ export function deletePathInObject(
651 const parent = getInObject(object, path.slice(0, length - 1));
652 if (parent) {
653 if (isArray(parent)) {
654 - parent.splice(((last: any): number), 1);
654 + parent.splice(last as any as number, 1);
655 } else {
656 delete parent[last];
657 }
@@ -672,7 +672,7 @@ export function renamePathInObject(
672 const lastNew = newPath[length - 1];
673 parent[lastNew] = parent[lastOld];
674 if (isArray(parent)) {
675 - parent.splice(((lastOld: any): number), 1);
675 + parent.splice(lastOld as any as number, 1);
676 } else {
677 delete parent[lastOld];
678 }
packages/react-devtools-shell/src/app/DeeplyNestedComponents/index.js
+1 -1
@@ -15,7 +15,7 @@ function wrapWithHoc(Component: () => any, index: number) {
15 return <Component />;
16 }
17
18 - const displayName = (Component: any).displayName || Component.name;
18 + const displayName = (Component as any).displayName || Component.name;
19
20 HOC.displayName = `withHoc${index}(${displayName})`;
21 return HOC;
packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js
+2 -2
@@ -122,8 +122,8 @@ function wrapWithHoc(
122 }
123 const HocWithHooks = wrapWithHoc(FunctionWithHooks);
124
125 -const Suspendender = React.lazy(() => {
126 - return new Promise<any>(resolve => {
125 +const Suspendender = React.lazy<() => React.Node>(() => {
126 + return new Promise<{default: () => React.Node, ...}>(resolve => {
127 setTimeout(() => {
128 resolve({
129 default: () => 'Finished!',
packages/react-devtools-shell/src/app/ToDoList/ListItem.js
+1 -1
@@ -46,4 +46,4 @@ function ListItem({item, removeItem, toggleItem}: Props) {
46 );
47 }
48
49 -export default (memo(ListItem): component(...props: Props));
49 +export default memo(ListItem) as component(...props: Props);
packages/react-devtools-shell/src/app/devtools.js
+5 -5
@@ -14,7 +14,7 @@ import {initDevTools} from 'react-devtools-shared/src/devtools';
14 // $FlowFixMe[cannot-resolve-name]
15 __webpack_public_path__ = '/dist/'; // eslint-disable-line no-undef
16
17 -const iframe = ((document.getElementById('target'): any): HTMLIFrameElement);
17 +const iframe = document.getElementById('target') as any as HTMLIFrameElement;
18
19 const {contentDocument, contentWindow} = iframe;
20
@@ -31,13 +31,13 @@ const DevTools = initializeFrontend(contentWindow);
31 // Otherwise the Store may miss important initial tree op codes.
32 activateBackend(contentWindow);
33
34 -const container = ((document.getElementById('devtools'): any): HTMLElement);
34 +const container = document.getElementById('devtools') as any as HTMLElement;
35
36 let isTestAppMounted = true;
37
38 -const mountButton = ((document.getElementById(
38 +const mountButton = document.getElementById(
39 'mountButton',
40 -): any): HTMLButtonElement);
40 +) as any as HTMLButtonElement;
41 mountButton.addEventListener('click', function () {
42 if (isTestAppMounted) {
43 if (typeof window.unmountTestApp === 'function') {
@@ -86,5 +86,5 @@ function inject(sourcePath: string, callback: () => void) {
86 script.onload = callback;
87 script.src = sourcePath;
88
89 - ((contentDocument.body: any): HTMLBodyElement).appendChild(script);
89 + (contentDocument.body as any as HTMLBodyElement).appendChild(script);
90 }
packages/react-devtools-shell/src/app/index.js
+1 -1
@@ -54,7 +54,7 @@ const unmountFunctions: Array<() => void | boolean> = [];
54 function createContainer() {
55 const container = document.createElement('div');
56
57 - ((document.body: any): HTMLBodyElement).appendChild(container);
57 + (document.body as any as HTMLBodyElement).appendChild(container);
58
59 return container;
60 }
packages/react-devtools-shell/src/e2e-apps/ListApp.js
+1 -1
@@ -19,7 +19,7 @@ function List() {
19 const inputRef = useRef(null);
20
21 const addItem = () => {
22 - const input = ((inputRef.current: any): HTMLInputElement);
22 + const input = inputRef.current as any as HTMLInputElement;
23 const text = input.value;
24 input.value = '';
25
packages/react-devtools-shell/src/e2e-regression/app-legacy.js
+1 -1
@@ -13,7 +13,7 @@ const version = process.env.E2E_APP_REACT_VERSION;
13 function mountApp(App: () => React$Node) {
14 const container = document.createElement('div');
15
16 - ((document.body: any): HTMLBodyElement).appendChild(container);
16 + (document.body as any as HTMLBodyElement).appendChild(container);
17
18 // $FlowFixMe[prop-missing]: These are removed in 19.
19 ReactDOM.render(<App />, container);
packages/react-devtools-shell/src/e2e-regression/app.js
+1 -1
@@ -9,7 +9,7 @@ import ListApp from '../e2e-apps/ListApp';
9 function mountApp(App: () => React$Node) {
10 const container = document.createElement('div');
11
12 - ((document.body: any): HTMLBodyElement).appendChild(container);
12 + (document.body as any as HTMLBodyElement).appendChild(container);
13
14 const root = ReactDOMClient.createRoot(container);
15 root.render(<App />);
packages/react-devtools-shell/src/e2e/app.js
+1 -1
@@ -7,7 +7,7 @@ import * as ReactDOMClient from 'react-dom/client';
7
8 const container = document.createElement('div');
9
10 -((document.body: any): HTMLBodyElement).appendChild(container);
10 +(document.body as any as HTMLBodyElement).appendChild(container);
11
12 // TODO We may want to parameterize this app
13 // so that it can load things other than just ToDoList.
packages/react-devtools-shell/src/perf-regression/app.js
+1 -1
@@ -9,7 +9,7 @@ import App from './apps/index';
9 function mountApp() {
10 const container = document.createElement('div');
11
12 - ((document.body: any): HTMLBodyElement).appendChild(container);
12 + (document.body as any as HTMLBodyElement).appendChild(container);
13
14 const root = createRoot(container);
15 root.render(
packages/react-devtools-timeline/src/EventTooltip.js
+2 -2
@@ -293,7 +293,7 @@ const TooltipSchedulingEvent = ({
293 case 'schedule-force-update':
294 lanes = schedulingEvent.lanes;
295 laneLabels = lanes.map(
296 - lane => ((data.laneToLabelMap.get(lane): any): string),
296 + lane => data.laneToLabelMap.get(lane) as any as string,
297 );
298 break;
299 }
@@ -441,7 +441,7 @@ const TooltipReactMeasure = ({
441 const [startTime, stopTime] = getBatchRange(batchUID, data);
442
443 const laneLabels = lanes.map(
444 - lane => ((data.laneToLabelMap.get(lane): any): string),
444 + lane => data.laneToLabelMap.get(lane) as any as string,
445 );
446
447 return (
packages/react-devtools-timeline/src/Timeline.js
+1 -1
@@ -57,7 +57,7 @@ export function Timeline(_: {}): React.Node {
57 const [key, setKey] = useState<string>(theme);
58 useLayoutEffect(() => {
59 const pollForTheme = () => {
60 - if (updateColorsToMatchTheme(((ref.current: any): HTMLDivElement))) {
60 + if (updateColorsToMatchTheme(ref.current as any as HTMLDivElement)) {
61 clearInterval(intervalID);
62 setKey(deferredTheme);
63 }
packages/react-devtools-timeline/src/TimelineContext.js
+1 -1
@@ -41,7 +41,7 @@ export type Context = {
41 };
42
43 const TimelineContext: ReactContext<Context> = createContext<Context>(
44 - ((null: any): Context),
44 + null as any as Context,
45 );
46 TimelineContext.displayName = 'TimelineContext';
47
packages/react-devtools-timeline/src/TimelineSearchContext.js
+1 -1
@@ -125,7 +125,7 @@ export type Context = {
125 };
126
127 const TimelineSearchContext: ReactContext<Context> = createContext<Context>(
128 - ((null: any): Context),
128 + null as any as Context,
129 );
130 TimelineSearchContext.displayName = 'TimelineSearchContext';
131
packages/react-devtools-timeline/src/content-views/ComponentMeasuresView.js
+2 -2
@@ -113,8 +113,8 @@ export class ComponentMeasuresView extends View {
113 return false; // Too small to render at this zoom level
114 }
115
116 - let textFillStyle = ((null: any): string);
117 - let typeLabel = ((null: any): string);
116 + let textFillStyle = null as any as string;
117 + let typeLabel = null as any as string;
118
119 const drawableRect = intersectionOfRects(componentMeasureRect, rect);
120 context.beginPath();
packages/react-devtools-timeline/src/content-views/SuspenseEventsView.js
+1 -1
@@ -122,7 +122,7 @@ export class SuspenseEventsView extends View {
122
123 baseY += depth * ROW_WITH_BORDER_HEIGHT;
124
125 - let fillStyle = ((null: any): string);
125 + let fillStyle = null as any as string;
126 if (warning !== null) {
127 fillStyle = showHoverHighlight
128 ? COLORS.WARNING_BACKGROUND_HOVER
packages/react-devtools-timeline/src/content-views/utils/text.js
+1 -1
@@ -24,7 +24,7 @@ export function getTextWidth(
24 cachedTextWidths.set(text, measuredWidth);
25 }
26
27 - return ((measuredWidth: any): number);
27 + return measuredWidth as any as number;
28 }
29
30 export function trimText(
packages/react-devtools-timeline/src/createDataResourceFromImportedFile.js
+2 -2
@@ -22,9 +22,9 @@ export default function createDataResourceFromImportedFile(
22 return createResource(
23 () => {
24 return new Promise<TimelineData | Error>((resolve, reject) => {
25 - const promise = ((importFile(
25 + const promise = importFile(
26 file,
27 - ): any): Promise<ImportWorkerOutputData>);
27 + ) as any as Promise<ImportWorkerOutputData>;
28 promise.then(data => {
29 switch (data.status) {
30 case 'SUCCESS':
packages/react-devtools-timeline/src/import-worker/preprocessData.js
+9 -7
@@ -171,9 +171,11 @@ function markWorkStarted(
171
172 // This array is pre-initialized before processing starts.
173 lanes.forEach(lane => {
174 - ((currentProfilerData.laneToReactMeasureMap.get(
175 - lane,
176 - ): any): ReactMeasure[]).push(measure);
174 + (
175 + currentProfilerData.laneToReactMeasureMap.get(
176 + lane,
177 + ) as any as Array<ReactMeasure>
178 + ).push(measure);
179 });
180 }
181
@@ -362,7 +364,7 @@ function processScreenshot(
364 };
365
366 // Delay processing until we've extracted snapshot dimensions.
365 - let resolveFn = ((null: any): Function);
367 + let resolveFn = null as any as Function;
368 state.asyncProcessingPromises.push(
369 new Promise(resolve => {
370 resolveFn = resolve;
@@ -551,7 +553,7 @@ function processTimelineEvent(
553 currentProfilerData.thrownErrors.push({
554 componentName,
555 message,
554 - phase: ((phase: any): Phase),
556 + phase: phase as any as Phase,
557 timestamp: startTime,
558 type: 'thrown-error',
559 });
@@ -586,7 +588,7 @@ function processTimelineEvent(
588 depth,
589 duration: null,
590 id,
589 - phase: ((phase: any): Phase),
591 + phase: phase as any as Phase,
592 promiseName: promiseName || null,
593 resolution: 'unresolved',
594 timestamp: startTime,
@@ -628,7 +630,7 @@ function processTimelineEvent(
630 } else if (name.startsWith('--render-start-')) {
631 if (state.nextRenderShouldGenerateNewBatchID) {
632 state.nextRenderShouldGenerateNewBatchID = false;
631 - state.batchUID = ((state.uidCounter++: any): BatchUID);
633 + state.batchUID = state.uidCounter++ as any as BatchUID;
634 }
635
636 // If this render is the result of a nested update, make a note of it.
packages/react-devtools-timeline/src/timelineCache.js
+6 -6
@@ -33,7 +33,7 @@ function readRecord<T>(record: Thenable<T>): T | Error {
33 return React.use(record);
34 } catch (x) {
35 if (record.status === 'rejected') {
36 - return (record.reason: any);
36 + return record.reason as any;
37 }
38 throw x;
39 }
@@ -41,7 +41,7 @@ function readRecord<T>(record: Thenable<T>): T | Error {
41 if (record.status === 'fulfilled') {
42 return record.value;
43 } else if (record.status === 'rejected') {
44 - return (record.reason: any);
44 + return record.reason as any;
45 } else {
46 throw record;
47 }
@@ -69,13 +69,13 @@ export function importFile(file: File): TimelineData | Error {
69
70 const wake = () => {
71 // This assumes they won't throw.
72 - callbacks.forEach(callback => callback((thenable: any).value));
72 + callbacks.forEach(callback => callback((thenable as any).value));
73 callbacks.clear();
74 rejectCallbacks.clear();
75 };
76 const wakeRejections = () => {
77 // This assumes they won't throw.
78 - rejectCallbacks.forEach(callback => callback((thenable: any).reason));
78 + rejectCallbacks.forEach(callback => callback((thenable as any).reason));
79 rejectCallbacks.clear();
80 callbacks.clear();
81 };
@@ -86,7 +86,7 @@ export function importFile(file: File): TimelineData | Error {
86 switch (data.status) {
87 case 'SUCCESS':
88 const fulfilledThenable: FulfilledThenable<TimelineData> =
89 - (thenable: any);
89 + thenable as any;
90 fulfilledThenable.status = 'fulfilled';
91 fulfilledThenable.value = data.processedData;
92 wake();
@@ -94,7 +94,7 @@ export function importFile(file: File): TimelineData | Error {
94 case 'INVALID_PROFILE_ERROR':
95 case 'UNEXPECTED_ERROR':
96 const rejectedThenable: RejectedThenable<TimelineData> =
97 - (thenable: any);
97 + thenable as any;
98 rejectedThenable.status = 'rejected';
99 rejectedThenable.reason = data.error;
100 wakeRejections();
packages/react-devtools-timeline/src/utils/getBatchRange.js
+1 -1
@@ -26,7 +26,7 @@ function unmemoizedGetBatchRange(
26 throw Error(`Could not find measures with batch UID "${batchUID}"`);
27 }
28
29 - const lastMeasure = ((measures[measures.length - 1]: any): ReactMeasure);
29 + const lastMeasure = measures[measures.length - 1] as any as ReactMeasure;
30 const stopTime = lastMeasure.timestamp + lastMeasure.duration;
31
32 if (stopTime < minStartTime) {
packages/react-devtools-timeline/src/view-base/VerticalScrollView.js
+2 -2
@@ -249,9 +249,9 @@ export class VerticalScrollView extends View {
249 if (
250 this._viewState.viewToMutableViewStateMap.has(this._mutableViewStateKey)
251 ) {
252 - this._scrollState = ((this._viewState.viewToMutableViewStateMap.get(
252 + this._scrollState = this._viewState.viewToMutableViewStateMap.get(
253 this._mutableViewStateKey,
254 - ): any): ScrollState);
254 + ) as any as ScrollState;
255 } else {
256 this._viewState.viewToMutableViewStateMap.set(
257 this._mutableViewStateKey,
packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js
+2 -2
@@ -107,9 +107,9 @@ export class ResizableView extends View {
107 if (
108 this._viewState.viewToMutableViewStateMap.has(this._mutableViewStateKey)
109 ) {
110 - this._layoutState = ((this._viewState.viewToMutableViewStateMap.get(
110 + this._layoutState = this._viewState.viewToMutableViewStateMap.get(
111 this._mutableViewStateKey,
112 - ): any): LayoutState);
112 + ) as any as LayoutState;
113
114 this._updateLayoutStateAndResizeBar(this._layoutState.barOffsetY);
115 } else {
packages/react-dom-bindings/src/client/DOMAccessibilityRoles.js
+2 -2
@@ -80,7 +80,7 @@ function getImplicitRole(element: Element): string | null {
80 }
81 break;
82 case 'INPUT': {
83 - const type = (element: any).type;
83 + const type = (element as any).type;
84 switch (type) {
85 case 'button':
86 case 'image':
@@ -111,7 +111,7 @@ function getImplicitRole(element: Element): string | null {
111 }
112
113 case 'SELECT':
114 - if (element.hasAttribute('multiple') || (element: any).size > 1) {
114 + if (element.hasAttribute('multiple') || (element as any).size > 1) {
115 return 'listbox';
116 }
117 return 'combobox';
packages/react-dom-bindings/src/client/DOMPropertyOperations.js
+10 -10
@@ -46,7 +46,7 @@ export function getValueForAttribute(
46 if (__DEV__) {
47 checkAttributeStringCoercion(expected, name);
48 }
49 - if (value === '' + (expected: any)) {
49 + if (value === '' + (expected as any)) {
50 return expected;
51 }
52 return value;
@@ -88,7 +88,7 @@ export function getValueForAttributeOnCustomComponent(
88 if (__DEV__) {
89 checkAttributeStringCoercion(expected, name);
90 }
91 - if (value === '' + (expected: any)) {
91 + if (value === '' + (expected as any)) {
92 return expected;
93 }
94 return value;
@@ -126,7 +126,7 @@ export function setValueForAttribute(
126 }
127 node.setAttribute(
128 name,
129 - enableTrustedTypesIntegration ? (value: any) : '' + (value: any),
129 + enableTrustedTypesIntegration ? (value as any) : '' + (value as any),
130 );
131 }
132 }
@@ -154,7 +154,7 @@ export function setValueForKnownAttribute(
154 }
155 node.setAttribute(
156 name,
157 - enableTrustedTypesIntegration ? (value: any) : '' + (value: any),
157 + enableTrustedTypesIntegration ? (value as any) : '' + (value as any),
158 );
159 }
160
@@ -183,7 +183,7 @@ export function setValueForNamespacedAttribute(
183 node.setAttributeNS(
184 namespace,
185 name,
186 - enableTrustedTypesIntegration ? (value: any) : '' + (value: any),
186 + enableTrustedTypesIntegration ? (value as any) : '' + (value as any),
187 );
188 }
189
@@ -206,22 +206,22 @@ export function setValueForPropertyOnCustomComponent(
206 if (typeof prevValue !== 'function' && prevValue !== null) {
207 // If we previously assigned a non-function type into this node, then
208 // remove it when switching to event listener mode.
209 - if (name in (node: any)) {
210 - (node: any)[name] = null;
209 + if (name in (node as any)) {
210 + (node as any)[name] = null;
211 } else if (node.hasAttribute(name)) {
212 node.removeAttribute(name);
213 }
214 }
215 // $FlowFixMe[incompatible-type] value can't be casted to EventListener.
216 - node.addEventListener(eventName, (value: EventListener), useCapture);
216 + node.addEventListener(eventName, value as EventListener, useCapture);
217 return;
218 }
219 }
220
221 trackHostMutation();
222
223 - if (name in (node: any)) {
224 - (node: any)[name] = value;
223 + if (name in (node as any)) {
224 + (node as any)[name] = value;
225 return;
226 }
227
packages/react-dom-bindings/src/client/ReactDOMComponent.js
+41 -38
@@ -250,7 +250,9 @@ function isExpectedViewTransitionName(htmlElement: HTMLElement): boolean {
250 return false;
251 }
252 const expectedVtName = htmlElement.getAttribute('vt-name');
253 - const actualVtName: string = (htmlElement.style: any)['view-transition-name'];
253 + const actualVtName: string = (htmlElement.style as any)[
254 + 'view-transition-name'
255 + ];
256 if (expectedVtName) {
257 return expectedVtName === actualVtName;
258 } else {
@@ -272,7 +274,7 @@ function warnForExtraAttributes(
274 // Skip empty style. It's fine.
275 return;
276 }
275 - const htmlElement = ((domElement: any): HTMLElement);
277 + const htmlElement = domElement as any as HTMLElement;
278 const style = htmlElement.style;
279 const isOnlyVTStyles =
280 (style.length === 1 && style[0] === 'view-transition-name') ||
@@ -326,7 +328,7 @@ function normalizeHTML(parent: Element, html: string) {
328 parent.namespaceURI === MATH_NAMESPACE ||
329 parent.namespaceURI === SVG_NAMESPACE
330 ? parent.ownerDocument.createElementNS(
329 - (parent.namespaceURI: any),
331 + parent.namespaceURI as any,
332 parent.tagName,
333 )
334 : parent.ownerDocument.createElement(parent.tagName);
@@ -347,7 +349,8 @@ function normalizeMarkupForTextOrAttribute(markup: mixed): string {
349 if (__DEV__) {
350 checkHtmlStringCoercion(markup);
351 }
350 - const markupString = typeof markup === 'string' ? markup : '' + (markup: any);
352 + const markupString =
353 + typeof markup === 'string' ? markup : '' + (markup as any);
354 return markupString
355 .replace(NORMALIZE_NEWLINES_REGEX, '\n')
356 .replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
@@ -464,7 +467,7 @@ function setProp(
467 if (__DEV__) {
468 try {
469 // This should always error.
467 - URL.revokeObjectURL(URL.createObjectURL((value: any)));
470 + URL.revokeObjectURL(URL.createObjectURL(value as any));
471 if (tag === 'source') {
472 console.error(
473 'Passing Blob, MediaSource or MediaStream to <source src> is not supported. ' +
@@ -525,9 +528,9 @@ function setProp(
528 if (__DEV__) {
529 checkAttributeStringCoercion(value, key);
530 }
528 - const sanitizedValue = (sanitizeURL(
529 - enableTrustedTypesIntegration ? value : '' + (value: any),
530 - ): any);
531 + const sanitizedValue = sanitizeURL(
532 + enableTrustedTypesIntegration ? value : '' + (value as any),
533 + ) as any;
534 domElement.setAttribute(key, sanitizedValue);
535 break;
536 }
@@ -596,9 +599,9 @@ function setProp(
599 if (__DEV__) {
600 checkAttributeStringCoercion(value, key);
601 }
599 - const sanitizedValue = (sanitizeURL(
600 - enableTrustedTypesIntegration ? value : '' + (value: any),
601 - ): any);
602 + const sanitizedValue = sanitizeURL(
603 + enableTrustedTypesIntegration ? value : '' + (value as any),
604 + ) as any;
605 domElement.setAttribute(key, sanitizedValue);
606 break;
607 }
@@ -608,7 +611,7 @@ function setProp(
611 if (__DEV__ && typeof value !== 'function') {
612 warnForInvalidEventListener(key, value);
613 }
611 - trapClickOnNonInteractiveElement(((domElement: any): HTMLElement));
614 + trapClickOnNonInteractiveElement(domElement as any as HTMLElement);
615 }
616 return;
617 }
@@ -658,12 +661,12 @@ function setProp(
661 // Note: `option.selected` is not updated if `select.multiple` is
662 // disabled with `removeAttribute`. We have special logic for handling this.
663 case 'multiple': {
661 - (domElement: any).multiple =
664 + (domElement as any).multiple =
665 value && typeof value !== 'function' && typeof value !== 'symbol';
666 break;
667 }
668 case 'muted': {
666 - (domElement: any).muted =
669 + (domElement as any).muted =
670 value && typeof value !== 'function' && typeof value !== 'symbol';
671 break;
672 }
@@ -699,9 +702,9 @@ function setProp(
702 if (__DEV__) {
703 checkAttributeStringCoercion(value, key);
704 }
702 - const sanitizedValue = (sanitizeURL(
703 - enableTrustedTypesIntegration ? value : '' + (value: any),
704 - ): any);
705 + const sanitizedValue = sanitizeURL(
706 + enableTrustedTypesIntegration ? value : '' + (value as any),
707 + ) as any;
708 domElement.setAttributeNS(xlinkNamespace, 'xlink:href', sanitizedValue);
709 break;
710 }
@@ -729,7 +732,7 @@ function setProp(
732 }
733 domElement.setAttribute(
734 key,
732 - enableTrustedTypesIntegration ? (value: any) : '' + (value: any),
735 + enableTrustedTypesIntegration ? (value as any) : '' + (value as any),
736 );
737 } else {
738 domElement.removeAttribute(key);
@@ -800,7 +803,7 @@ function setProp(
803 if (__DEV__) {
804 checkAttributeStringCoercion(value, key);
805 }
803 - domElement.setAttribute(key, (value: any));
806 + domElement.setAttribute(key, value as any);
807 } else {
808 domElement.removeAttribute(key);
809 }
@@ -816,12 +819,12 @@ function setProp(
819 typeof value !== 'function' &&
820 typeof value !== 'symbol' &&
821 !isNaN(value) &&
819 - (value: any) >= 1
822 + (value as any) >= 1
823 ) {
824 if (__DEV__) {
825 checkAttributeStringCoercion(value, key);
826 }
824 - domElement.setAttribute(key, (value: any));
827 + domElement.setAttribute(key, value as any);
828 } else {
829 domElement.removeAttribute(key);
830 }
@@ -839,7 +842,7 @@ function setProp(
842 if (__DEV__) {
843 checkAttributeStringCoercion(value, key);
844 }
842 - domElement.setAttribute(key, (value: any));
845 + domElement.setAttribute(key, value as any);
846 } else {
847 domElement.removeAttribute(key);
848 }
@@ -1055,7 +1058,7 @@ function setPropOnCustomElement(
1058 if (__DEV__ && typeof value !== 'function') {
1059 warnForInvalidEventListener(key, value);
1060 }
1058 - trapClickOnNonInteractiveElement(((domElement: any): HTMLElement));
1061 + trapClickOnNonInteractiveElement(domElement as any as HTMLElement);
1062 }
1063 return;
1064 }
@@ -1344,7 +1347,7 @@ export function setInitialProperties(
1347 switch (propKey) {
1348 case 'selected': {
1349 // TODO: Remove support for selected on option.
1347 - (domElement: any).selected =
1350 + (domElement as any).selected =
1351 propValue &&
1352 typeof propValue !== 'function' &&
1353 typeof propValue !== 'symbol';
@@ -1824,7 +1827,7 @@ export function updateProperties(
1827 switch (propKey) {
1828 case 'selected': {
1829 // TODO: Remove support for selected on option.
1827 - (domElement: any).selected = false;
1830 + (domElement as any).selected = false;
1831 break;
1832 }
1833 default: {
@@ -1847,7 +1850,7 @@ export function updateProperties(
1850 trackHostMutation();
1851 }
1852 // TODO: Remove support for selected on option.
1850 - (domElement: any).selected =
1853 + (domElement as any).selected =
1854 nextProp &&
1855 typeof nextProp !== 'function' &&
1856 typeof nextProp !== 'symbol';
@@ -2021,7 +2024,7 @@ function getStylesObjectFromElement(domElement: Element): {
2024 [styleName: string]: string,
2025 } {
2026 const serverValueInObjectForm: {[prop: string]: string} = {};
2024 - const htmlElement: HTMLElement = (domElement: any);
2027 + const htmlElement: HTMLElement = domElement as any;
2028 const style = htmlElement.style;
2029 for (let i = 0; i < style.length; i++) {
2030 const styleName: string = style[i];
@@ -2074,7 +2077,7 @@ function diffHydratedStyles(
2077 // Trailing semi-colon means this was regenerated.
2078 normalizedServerValue[normalizedServerValue.length - 1] === ';' &&
2079 // TODO: Should we just ignore any style if the style as been manipulated?
2077 - hasViewTransition((domElement: any))
2080 + hasViewTransition(domElement as any)
2081 ) {
2082 // If this had a view transition we might have applied a view transition
2083 // name/class and removed it. If that happens, the style attribute gets
@@ -2250,7 +2253,7 @@ function hydrateBooleanishAttribute(
2253 if (__DEV__) {
2254 checkAttributeStringCoercion(value, attributeName);
2255 }
2253 - if (serverValue === '' + (value: any)) {
2256 + if (serverValue === '' + (value as any)) {
2257 return;
2258 }
2259 }
@@ -2539,7 +2542,7 @@ function diffHydratedCustomComponent(
2542 continue;
2543 default: {
2544 // This is a DEV-only path
2542 - const hostContextDev: HostContextDev = (hostContext: any);
2545 + const hostContextDev: HostContextDev = hostContext as any;
2546 const hostContextProd = hostContextDev.context;
2547 if (
2548 hostContextProd === HostContextNamespaceNone &&
@@ -2662,26 +2665,26 @@ function diffHydratedGenericElement(
2665 continue;
2666 case 'multiple': {
2667 extraAttributes.delete(propKey);
2665 - const serverValue = (domElement: any).multiple;
2668 + const serverValue = (domElement as any).multiple;
2669 warnForPropDifference(propKey, serverValue, value, serverDifferences);
2670 continue;
2671 }
2672 case 'muted': {
2673 extraAttributes.delete(propKey);
2671 - const serverValue = (domElement: any).muted;
2674 + const serverValue = (domElement as any).muted;
2675 warnForPropDifference(propKey, serverValue, value, serverDifferences);
2676 continue;
2677 }
2678 case 'autoFocus': {
2679 extraAttributes.delete('autofocus');
2677 - const serverValue = (domElement: any).autofocus;
2680 + const serverValue = (domElement as any).autofocus;
2681 warnForPropDifference(propKey, serverValue, value, serverDifferences);
2682 continue;
2683 }
2684 case 'data':
2685 if (tag !== 'object') {
2686 extraAttributes.delete(propKey);
2684 - const serverValue = (domElement: any).getAttribute('data');
2687 + const serverValue = (domElement as any).getAttribute('data');
2688 warnForPropDifference(propKey, serverValue, value, serverDifferences);
2689 continue;
2690 }
@@ -2692,7 +2695,7 @@ function diffHydratedGenericElement(
2695 if (tag === 'img' || tag === 'video' || tag === 'audio') {
2696 try {
2697 // Test if this is a compatible object
2695 - URL.revokeObjectURL(URL.createObjectURL((value: any)));
2698 + URL.revokeObjectURL(URL.createObjectURL(value as any));
2699 hydrateSrcObjectAttribute(
2700 domElement,
2701 value,
@@ -2707,7 +2710,7 @@ function diffHydratedGenericElement(
2710 if (__DEV__) {
2711 try {
2712 // This should always error.
2710 - URL.revokeObjectURL(URL.createObjectURL((value: any)));
2713 + URL.revokeObjectURL(URL.createObjectURL(value as any));
2714 if (tag === 'source') {
2715 console.error(
2716 'Passing Blob, MediaSource or MediaStream to <source src> is not supported. ' +
@@ -3073,7 +3076,7 @@ function diffHydratedGenericElement(
3076 let isMismatchDueToBadCasing = false;
3077
3078 // This is a DEV-only path
3076 - const hostContextDev: HostContextDev = (hostContext: any);
3079 + const hostContextDev: HostContextDev = hostContext as any;
3080 const hostContextProd = hostContextDev.context;
3081
3082 if (
@@ -3264,7 +3267,7 @@ export function hydrateProperties(
3267
3268 if (props.onClick != null) {
3269 // TODO: This cast may not be sound for SVG, MathML or custom elements.
3267 - trapClickOnNonInteractiveElement(((domElement: any): HTMLElement));
3270 + trapClickOnNonInteractiveElement(domElement as any as HTMLElement);
3271 }
3272
3273 return true;
packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
+46 -46
@@ -72,22 +72,22 @@ export function detachDeletedInstance(node: Instance): void {
72 if (enableInternalInstanceMap) {
73 internalInstanceMap.delete(node);
74 internalPropsMap.delete(node);
75 - delete (node: any)[internalEventHandlersKey];
76 - delete (node: any)[internalEventHandlerListenersKey];
77 - delete (node: any)[internalEventHandlesSetKey];
78 - delete (node: any)[internalRootNodeResourcesKey];
75 + delete (node as any)[internalEventHandlersKey];
76 + delete (node as any)[internalEventHandlerListenersKey];
77 + delete (node as any)[internalEventHandlesSetKey];
78 + delete (node as any)[internalRootNodeResourcesKey];
79 if (__DEV__) {
80 - delete (node: any)[internalInstanceKey];
80 + delete (node as any)[internalInstanceKey];
81 }
82 return;
83 }
84 // TODO: This function is only called on host components. I don't think all of
85 // these fields are relevant.
86 - delete (node: any)[internalInstanceKey];
87 - delete (node: any)[internalPropsKey];
88 - delete (node: any)[internalEventHandlersKey];
89 - delete (node: any)[internalEventHandlerListenersKey];
90 - delete (node: any)[internalEventHandlesSetKey];
86 + delete (node as any)[internalInstanceKey];
87 + delete (node as any)[internalPropsKey];
88 + delete (node as any)[internalEventHandlersKey];
89 + delete (node as any)[internalEventHandlerListenersKey];
90 + delete (node as any)[internalEventHandlesSetKey];
91 }
92
93 export function precacheFiberNode(
@@ -102,11 +102,11 @@ export function precacheFiberNode(
102 if (enableInternalInstanceMap) {
103 internalInstanceMap.set(node, hostInst);
104 if (__DEV__) {
105 - (node: any)[internalInstanceKey] = hostInst;
105 + (node as any)[internalInstanceKey] = hostInst;
106 }
107 return;
108 }
109 - (node: any)[internalInstanceKey] = hostInst;
109 + (node as any)[internalInstanceKey] = hostInst;
110 }
111
112 export function markContainerAsRoot(hostRoot: Fiber, node: Container): void {
@@ -135,9 +135,9 @@ export function isContainerMarkedAsRoot(node: Container): boolean {
135 export function getClosestInstanceFromNode(targetNode: Node): null | Fiber {
136 let targetInst: void | Fiber;
137 if (enableInternalInstanceMap) {
138 - targetInst = internalInstanceMap.get(((targetNode: any): InstanceUnion));
138 + targetInst = internalInstanceMap.get(targetNode as any as InstanceUnion);
139 } else {
140 - targetInst = (targetNode: any)[internalInstanceKey];
140 + targetInst = (targetNode as any)[internalInstanceKey];
141 }
142 if (targetInst) {
143 // Don't return HostRoot, SuspenseComponent or ActivityComponent here.
@@ -157,12 +157,12 @@ export function getClosestInstanceFromNode(targetNode: Node): null | Fiber {
157 // If it's not a container, we check if it's an instance.
158 if (enableInternalInstanceMap) {
159 targetInst =
160 - (parentNode: any)[internalContainerInstanceKey] ||
161 - internalInstanceMap.get(((parentNode: any): InstanceUnion));
160 + (parentNode as any)[internalContainerInstanceKey] ||
161 + internalInstanceMap.get(parentNode as any as InstanceUnion);
162 } else {
163 targetInst =
164 - (parentNode: any)[internalContainerInstanceKey] ||
165 - (parentNode: any)[internalInstanceKey];
164 + (parentNode as any)[internalContainerInstanceKey] ||
165 + (parentNode as any)[internalInstanceKey];
166 }
167 if (targetInst) {
168 // Since this wasn't the direct target of the event, we might have
@@ -229,12 +229,12 @@ export function getInstanceFromNode(node: Node): Fiber | null {
229 let inst: void | null | Fiber;
230 if (enableInternalInstanceMap) {
231 inst =
232 - internalInstanceMap.get(((node: any): InstanceUnion)) ||
233 - (node: any)[internalContainerInstanceKey];
232 + internalInstanceMap.get(node as any as InstanceUnion) ||
233 + (node as any)[internalContainerInstanceKey];
234 } else {
235 inst =
236 - (node: any)[internalInstanceKey] ||
237 - (node: any)[internalContainerInstanceKey];
236 + (node as any)[internalInstanceKey] ||
237 + (node as any)[internalContainerInstanceKey];
238 }
239 if (inst) {
240 const tag = inst.tag;
@@ -288,7 +288,7 @@ export function getFiberCurrentPropsFromNode(
288 if (enableInternalInstanceMap) {
289 return internalPropsMap.get(node) || null;
290 }
291 - return (node: any)[internalPropsKey] || null;
291 + return (node as any)[internalPropsKey] || null;
292 }
293
294 export function updateFiberProps(node: Instance, props: Props): void {
@@ -296,15 +296,15 @@ export function updateFiberProps(node: Instance, props: Props): void {
296 internalPropsMap.set(node, props);
297 return;
298 }
299 - (node: any)[internalPropsKey] = props;
299 + (node as any)[internalPropsKey] = props;
300 }
301
302 export function getEventListenerSet(node: EventTarget): Set<string> {
303 - let elementListenerSet: Set<string> | void = (node: any)[
303 + let elementListenerSet: Set<string> | void = (node as any)[
304 internalEventHandlersKey
305 ];
306 if (elementListenerSet === undefined) {
307 - elementListenerSet = (node: any)[internalEventHandlersKey] = new Set();
307 + elementListenerSet = (node as any)[internalEventHandlersKey] = new Set();
308 }
309 return elementListenerSet;
310 }
@@ -314,9 +314,9 @@ export function getFiberFromScopeInstance(
314 ): null | Fiber {
315 if (enableScopeAPI) {
316 if (enableInternalInstanceMap) {
317 - return internalInstanceMap.get(((scope: any): InstanceUnion)) || null;
317 + return internalInstanceMap.get(scope as any as InstanceUnion) || null;
318 }
319 - return (scope: any)[internalInstanceKey] || null;
319 + return (scope as any)[internalInstanceKey] || null;
320 }
321 return null;
322 }
@@ -325,22 +325,22 @@ export function setEventHandlerListeners(
325 scope: EventTarget | ReactScopeInstance,
326 listeners: Set<ReactDOMEventHandleListener>,
327 ): void {
328 - (scope: any)[internalEventHandlerListenersKey] = listeners;
328 + (scope as any)[internalEventHandlerListenersKey] = listeners;
329 }
330
331 export function getEventHandlerListeners(
332 scope: EventTarget | ReactScopeInstance,
333 ): null | Set<ReactDOMEventHandleListener> {
334 - return (scope: any)[internalEventHandlerListenersKey] || null;
334 + return (scope as any)[internalEventHandlerListenersKey] || null;
335 }
336
337 export function addEventHandleToTarget(
338 target: EventTarget | ReactScopeInstance,
339 eventHandle: ReactDOMEventHandle,
340 ): void {
341 - let eventHandles = (target: any)[internalEventHandlesSetKey];
341 + let eventHandles = (target as any)[internalEventHandlesSetKey];
342 if (eventHandles === undefined) {
343 - eventHandles = (target: any)[internalEventHandlesSetKey] = new Set();
343 + eventHandles = (target as any)[internalEventHandlesSetKey] = new Set();
344 }
345 eventHandles.add(eventHandle);
346 }
@@ -349,7 +349,7 @@ export function doesTargetHaveEventHandle(
349 target: EventTarget | ReactScopeInstance,
350 eventHandle: ReactDOMEventHandle,
351 ): boolean {
352 - const eventHandles = (target: any)[internalEventHandlesSetKey];
352 + const eventHandles = (target as any)[internalEventHandlesSetKey];
353 if (eventHandles === undefined) {
354 return false;
355 }
@@ -357,9 +357,9 @@ export function doesTargetHaveEventHandle(
357 }
358
359 export function getResourcesFromRoot(root: HoistableRoot): RootResources {
360 - let resources = (root: any)[internalRootNodeResourcesKey];
360 + let resources = (root as any)[internalRootNodeResourcesKey];
361 if (!resources) {
362 - resources = (root: any)[internalRootNodeResourcesKey] = {
362 + resources = (root as any)[internalRootNodeResourcesKey] = {
363 hoistableStyles: new Map(),
364 hoistableScripts: new Map(),
365 };
@@ -368,45 +368,45 @@ export function getResourcesFromRoot(root: HoistableRoot): RootResources {
368 }
369
370 export function isMarkedHoistable(node: Node): boolean {
371 - return !!(node: any)[internalHoistableMarker];
371 + return !!(node as any)[internalHoistableMarker];
372 }
373
374 export function markNodeAsHoistable(node: Node) {
375 - (node: any)[internalHoistableMarker] = true;
375 + (node as any)[internalHoistableMarker] = true;
376 }
377
378 export function getScrollEndTimer(node: EventTarget): ?TimeoutID {
379 - return (node: any)[internalScrollTimer];
379 + return (node as any)[internalScrollTimer];
380 }
381
382 export function setScrollEndTimer(node: EventTarget, timer: TimeoutID): void {
383 - (node: any)[internalScrollTimer] = timer;
383 + (node as any)[internalScrollTimer] = timer;
384 }
385
386 export function clearScrollEndTimer(node: EventTarget): void {
387 - (node: any)[internalScrollTimer] = undefined;
387 + (node as any)[internalScrollTimer] = undefined;
388 }
389
390 export function markNodeAsPendingLoad(node: Node): void {
391 - (node: any)[internalLoadPendingKey] = true;
391 + (node as any)[internalLoadPendingKey] = true;
392 }
393
394 export function clearPendingLoadOnNode(node: Node): void {
395 - (node: any)[internalLoadPendingKey] = undefined;
395 + (node as any)[internalLoadPendingKey] = undefined;
396 }
397
398 export function isNodePendingLoad(node: Node): boolean {
399 - return (node: any)[internalLoadPendingKey] === true;
399 + return (node as any)[internalLoadPendingKey] === true;
400 }
401
402 export function isOwnedInstance(node: Node): boolean {
403 if (enableInternalInstanceMap) {
404 return !!(
405 - (node: any)[internalHoistableMarker] ||
406 - internalInstanceMap.has((node: any))
405 + (node as any)[internalHoistableMarker] ||
406 + internalInstanceMap.has(node as any)
407 );
408 }
409 return !!(
410 - (node: any)[internalHoistableMarker] || (node: any)[internalInstanceKey]
410 + (node as any)[internalHoistableMarker] || (node as any)[internalInstanceKey]
411 );
412 }
packages/react-dom-bindings/src/client/ReactDOMContainer.js
+1 -1
@@ -24,6 +24,6 @@ export function isValidContainer(node: any): boolean {
24 node.nodeType === DOCUMENT_FRAGMENT_NODE ||
25 (!disableCommentsAsDOMContainers &&
26 node.nodeType === COMMENT_NODE &&
27 - (node: any).nodeValue === ' react-mount-point-unstable '))
27 + (node as any).nodeValue === ' react-mount-point-unstable '))
28 );
29 }
packages/react-dom-bindings/src/client/ReactDOMEventHandle.js
+7 -7
@@ -35,11 +35,11 @@ type EventHandleOptions = {
35 };
36
37 function isValidEventTarget(target: EventTarget | ReactScopeInstance): boolean {
38 - return typeof (target: Object).addEventListener === 'function';
38 + return typeof (target as Object).addEventListener === 'function';
39 }
40
41 function isReactScope(target: EventTarget | ReactScopeInstance): boolean {
42 - return typeof (target: Object).getChildContextValues === 'function';
42 + return typeof (target as Object).getChildContextValues === 'function';
43 }
44
45 function createEventHandleListener(
@@ -59,12 +59,12 @@ function registerReactDOMEvent(
59 domEventName: DOMEventName,
60 isCapturePhaseListener: boolean,
61 ): void {
62 - if ((target: any).nodeType === ELEMENT_NODE) {
62 + if ((target as any).nodeType === ELEMENT_NODE) {
63 // Do nothing. We already attached all root listeners.
64 } else if (enableScopeAPI && isReactScope(target)) {
65 // Do nothing. We already attached all root listeners.
66 } else if (isValidEventTarget(target)) {
67 - const eventTarget = ((target: any): EventTarget);
67 + const eventTarget = target as any as EventTarget;
68 // These are valid event targets, but they are also
69 // non-managed React nodes.
70 listenToNativeEventForNonManagedEventTarget(
@@ -85,7 +85,7 @@ export function createEventHandle(
85 options?: EventHandleOptions,
86 ): ReactDOMEventHandle {
87 if (enableCreateEventHandleAPI) {
88 - const domEventName = ((type: any): DOMEventName);
88 + const domEventName = type as any as DOMEventName;
89
90 // We cannot support arbitrary native events with eager root listeners
91 // because the eager strategy relies on knowing the whole list ahead of time.
@@ -137,7 +137,7 @@ export function createEventHandle(
137 }
138 targetListeners.add(listener);
139 return () => {
140 - ((targetListeners: any): Set<ReactDOMEventHandleListener>).delete(
140 + (targetListeners as any as Set<ReactDOMEventHandleListener>).delete(
141 listener,
142 );
143 };
@@ -145,5 +145,5 @@ export function createEventHandle(
145
146 return eventHandle;
147 }
148 - return (null: any);
148 + return null as any;
149 }
packages/react-dom-bindings/src/client/ReactDOMInput.js
+11 -11
@@ -96,7 +96,7 @@ export function updateInput(
96 type: ?string,
97 name: ?string,
98 ) {
99 - const node: HTMLInputElement = (element: any);
99 + const node: HTMLInputElement = element as any;
100
101 // Temporarily disconnect the input from any radio buttons.
102 // Changing the type or name as the same time as changing the checked value
@@ -126,7 +126,7 @@ export function updateInput(
126 (value === 0 && node.value === '') ||
127 // We explicitly want to coerce to number here if possible.
128 // eslint-disable-next-line
129 - node.value != (value: any)
129 + node.value != (value as any)
130 ) {
131 node.value = toString(getToStringValue(value));
132 }
@@ -214,7 +214,7 @@ export function initInput(
214 name: ?string,
215 isHydrating: boolean,
216 ) {
217 - const node: HTMLInputElement = (element: any);
217 + const node: HTMLInputElement = element as any;
218
219 if (
220 type != null &&
@@ -235,7 +235,7 @@ export function initInput(
235 // default value provided by the browser. See: #12872
236 if (isButton && (value === undefined || value === null)) {
237 // We track the value just in case it changes type later on.
238 - track((element: any));
238 + track(element as any);
239 return;
240 }
241
@@ -342,7 +342,7 @@ export function initInput(
342 }
343 node.name = name;
344 }
345 - track((element: any));
345 + track(element as any);
346 }
347
348 export function hydrateInput(
@@ -352,7 +352,7 @@ export function hydrateInput(
352 checked: ?boolean,
353 defaultChecked: ?boolean,
354 ): void {
355 - const node: HTMLInputElement = (element: any);
355 + const node: HTMLInputElement = element as any;
356
357 const defaultValueStr =
358 defaultValue != null ? toString(getToStringValue(defaultValue)) : '';
@@ -370,7 +370,7 @@ export function hydrateInput(
370 // Detach .checked from .defaultChecked but leave user input alone
371 node.checked = node.checked;
372
373 - const changed = trackHydrated((node: any), initialValue, initialChecked);
373 + const changed = trackHydrated(node as any, initialValue, initialChecked);
374 if (changed) {
375 // If the current value is different, that suggests that the user
376 // changed it before hydration. Queue a replay of the change event.
@@ -382,7 +382,7 @@ export function hydrateInput(
382 }
383
384 export function restoreControlledInputState(element: Element, props: Object) {
385 - const rootNode: HTMLInputElement = (element: any);
385 + const rootNode: HTMLInputElement = element as any;
386 updateInput(
387 rootNode,
388 props.value,
@@ -398,7 +398,7 @@ export function restoreControlledInputState(element: Element, props: Object) {
398 let queryRoot: Element = rootNode;
399
400 while (queryRoot.parentNode) {
401 - queryRoot = ((queryRoot.parentNode: any): Element);
401 + queryRoot = queryRoot.parentNode as any as Element;
402 }
403
404 // If `rootNode.form` was non-null, then we could try `form.elements`,
@@ -418,7 +418,7 @@ export function restoreControlledInputState(element: Element, props: Object) {
418 );
419
420 for (let i = 0; i < group.length; i++) {
421 - const otherNode = ((group[i]: any): HTMLInputElement);
421 + const otherNode = group[i] as any as HTMLInputElement;
422 if (otherNode === rootNode || otherNode.form !== rootNode.form) {
423 continue;
424 }
@@ -453,7 +453,7 @@ export function restoreControlledInputState(element: Element, props: Object) {
453 // If any updateInput() call set .checked to true, an input in this group
454 // (often, `rootNode` itself) may have become unchecked
455 for (let i = 0; i < group.length; i++) {
456 - const otherNode = ((group[i]: any): HTMLInputElement);
456 + const otherNode = group[i] as any as HTMLInputElement;
457 if (otherNode.form !== rootNode.form) {
458 continue;
459 }
packages/react-dom-bindings/src/client/ReactDOMSelect.js
+6 -6
@@ -69,7 +69,7 @@ function updateOptions(
69 const options: HTMLOptionsCollection = node.options;
70
71 if (multiple) {
72 - const selectedValues = (propValue: Array<string>);
72 + const selectedValues = propValue as Array<string>;
73 const selectedValue: {[string]: boolean} = {};
74 for (let i = 0; i < selectedValues.length; i++) {
75 // Prefix to avoid chaos with special keys.
@@ -149,7 +149,7 @@ export function initSelect(
149 defaultValue: ?string,
150 multiple: ?boolean,
151 ) {
152 - const node: HTMLSelectElement = (element: any);
152 + const node: HTMLSelectElement = element as any;
153 node.multiple = !!multiple;
154 if (value != null) {
155 updateOptions(node, !!multiple, value, false);
@@ -164,7 +164,7 @@ export function hydrateSelect(
164 defaultValue: ?string,
165 multiple: ?boolean,
166 ): void {
167 - const node: HTMLSelectElement = (element: any);
167 + const node: HTMLSelectElement = element as any;
168 const options: HTMLOptionsCollection = node.options;
169
170 const propValue: any = value != null ? value : defaultValue;
@@ -172,7 +172,7 @@ export function hydrateSelect(
172 let changed = false;
173
174 if (multiple) {
175 - const selectedValues = (propValue: ?Array<string>);
175 + const selectedValues = propValue as ?Array<string>;
176 const selectedValue: {[string]: boolean} = {};
177 if (selectedValues != null) {
178 for (let i = 0; i < selectedValues.length; i++) {
@@ -218,7 +218,7 @@ export function updateSelect(
218 multiple: ?boolean,
219 wasMultiple: ?boolean,
220 ) {
221 - const node: HTMLSelectElement = (element: any);
221 + const node: HTMLSelectElement = element as any;
222
223 if (value != null) {
224 updateOptions(node, !!multiple, value, false);
@@ -234,7 +234,7 @@ export function updateSelect(
234 }
235
236 export function restoreControlledSelectState(element: Element, props: Object) {
237 - const node: HTMLSelectElement = (element: any);
237 + const node: HTMLSelectElement = element as any;
238 const value = props.value;
239
240 if (value != null) {
packages/react-dom-bindings/src/client/ReactDOMSrcObject.js
+1 -1
@@ -10,7 +10,7 @@
10 export function setSrcObject(domElement: Element, tag: string, value: any) {
11 // We optimistically create the URL regardless of object type. This lets us
12 // support cross-realms and any type that the browser supports like new types.
13 - const url = URL.createObjectURL((value: any));
13 + const url = URL.createObjectURL(value as any);
14 const loadEvent = tag === 'img' ? 'load' : 'loadstart';
15 const cleanUp = () => {
16 // Once the object has started loading, then it's already collected by the
packages/react-dom-bindings/src/client/ReactDOMTextarea.js
+6 -6
@@ -66,7 +66,7 @@ export function updateTextarea(
66 value: ?string,
67 defaultValue: ?string,
68 ) {
69 - const node: HTMLTextAreaElement = (element: any);
69 + const node: HTMLTextAreaElement = element as any;
70 if (value != null) {
71 // Cast `value` to a string to ensure the value is set correctly. While
72 // browsers typically do this as necessary, jsdom doesn't.
@@ -96,7 +96,7 @@ export function initTextarea(
96 defaultValue: ?string,
97 children: ?string,
98 ) {
99 - const node: HTMLTextAreaElement = (element: any);
99 + const node: HTMLTextAreaElement = element as any;
100
101 let initialValue = value;
102
@@ -128,7 +128,7 @@ export function initTextarea(
128 }
129
130 const stringValue = getToStringValue(initialValue);
131 - node.defaultValue = (stringValue: any); // This will be toString:ed.
131 + node.defaultValue = stringValue as any; // This will be toString:ed.
132
133 // This is in postMount because we need access to the DOM node, which is not
134 // available until after the component has mounted.
@@ -146,7 +146,7 @@ export function initTextarea(
146 }
147 }
148
149 - track((element: any));
149 + track(element as any);
150 }
151
152 export function hydrateTextarea(
@@ -154,7 +154,7 @@ export function hydrateTextarea(
154 value: ?string,
155 defaultValue: ?string,
156 ): void {
157 - const node: HTMLTextAreaElement = (element: any);
157 + const node: HTMLTextAreaElement = element as any;
158 let initialValue = value;
159 if (initialValue == null) {
160 if (defaultValue == null) {
@@ -166,7 +166,7 @@ export function hydrateTextarea(
166 // that any change event that fires will trigger onChange on the actual
167 // current value.
168 const stringValue = toString(getToStringValue(initialValue));
169 - const changed = trackHydrated((node: any), stringValue, false);
169 + const changed = trackHydrated(node as any, stringValue, false);
170 if (changed) {
171 // If the current value is different, that suggests that the user
172 // changed it before hydration. Queue a replay of the change event.
packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+198 -185
@@ -300,7 +300,7 @@ function getOwnerDocumentFromRootContainer(
300 rootContainerElement: Element | Document | DocumentFragment,
301 ): Document {
302 return rootContainerElement.nodeType === DOCUMENT_NODE
303 - ? (rootContainerElement: any)
303 + ? (rootContainerElement as any)
304 : rootContainerElement.ownerDocument;
305 }
306
@@ -314,7 +314,7 @@ export function getRootHostContext(
314 case DOCUMENT_NODE:
315 case DOCUMENT_FRAGMENT_NODE: {
316 type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment';
317 - const root = (rootContainerInstance: any).documentElement;
317 + const root = (rootContainerInstance as any).documentElement;
318 if (root) {
319 const namespaceURI = root.namespaceURI;
320 context = namespaceURI
@@ -398,7 +398,7 @@ export function getChildHostContext(
398 type: string,
399 ): HostContext {
400 if (__DEV__) {
401 - const parentHostContextDev = ((parentHostContext: any): HostContextDev);
401 + const parentHostContextDev = parentHostContext as any as HostContextDev;
402 const context = getChildHostContextProd(parentHostContextDev.context, type);
403 const ancestorInfo = updatedAncestorInfoDev(
404 parentHostContextDev.ancestorInfo,
@@ -406,7 +406,7 @@ export function getChildHostContext(
406 );
407 return {context, ancestorInfo};
408 }
409 - const parentNamespace = ((parentHostContext: any): HostContextProd);
409 + const parentNamespace = parentHostContext as any as HostContextProd;
410 return getChildHostContextProd(parentNamespace, type);
411 }
412
@@ -432,7 +432,7 @@ export function beforeActiveInstanceBlur(internalInstanceHandle: Object): void {
432 if (enableCreateEventHandleAPI) {
433 ReactBrowserEventEmitterSetEnabled(true);
434 dispatchBeforeDetachedBlur(
435 - (selectionInformation: any).focusedElem,
435 + (selectionInformation as any).focusedElem,
436 internalInstanceHandle,
437 );
438 ReactBrowserEventEmitterSetEnabled(false);
@@ -442,7 +442,7 @@ export function beforeActiveInstanceBlur(internalInstanceHandle: Object): void {
442 export function afterActiveInstanceBlur(): void {
443 if (enableCreateEventHandleAPI) {
444 ReactBrowserEventEmitterSetEnabled(true);
445 - dispatchAfterDetachedBlur((selectionInformation: any).focusedElem);
445 + dispatchAfterDetachedBlur((selectionInformation as any).focusedElem);
446 ReactBrowserEventEmitterSetEnabled(false);
447 }
448 }
@@ -534,11 +534,11 @@ export function createInstance(
534 let hostContextProd: HostContextProd;
535 if (__DEV__) {
536 // TODO: take namespace into account when validating.
537 - const hostContextDev: HostContextDev = (hostContext: any);
537 + const hostContextDev: HostContextDev = hostContext as any;
538 validateDOMNesting(type, hostContextDev.ancestorInfo);
539 hostContextProd = hostContextDev.context;
540 } else {
541 - hostContextProd = (hostContext: any);
541 + hostContextProd = hostContext as any;
542 }
543
544 const ownerDocument = getOwnerDocumentFromRootContainer(
@@ -586,7 +586,7 @@ export function createInstance(
586 }
587 div.innerHTML = '<script><' + '/script>';
588 // This is guaranteed to yield a script element.
589 - const firstChild = ((div.firstChild: any): HTMLScriptElement);
589 + const firstChild = div.firstChild as any as HTMLScriptElement;
590 domElement = div.removeChild(firstChild);
591 break;
592 }
@@ -754,7 +754,7 @@ export function createTextInstance(
754 internalInstanceHandle: Object,
755 ): TextInstance {
756 if (__DEV__) {
757 - const hostContextDev = ((hostContext: any): HostContextDev);
757 + const hostContextDev = hostContext as any as HostContextDev;
758 const ancestor = hostContextDev.ancestorInfo.current;
759 if (ancestor != null) {
760 validateTextNesting(
@@ -823,9 +823,9 @@ export const warnsIfNotActing = true;
823 // if a component just imports ReactDOM (e.g. for findDOMNode).
824 // Some environments might not have setTimeout or clearTimeout.
825 export const scheduleTimeout: any =
826 - typeof setTimeout === 'function' ? setTimeout : (undefined: any);
826 + typeof setTimeout === 'function' ? setTimeout : (undefined as any);
827 export const cancelTimeout: any =
828 - typeof clearTimeout === 'function' ? clearTimeout : (undefined: any);
828 + typeof clearTimeout === 'function' ? clearTimeout : (undefined as any);
829 export const noTimeout: -1 = -1;
830 const localPromise = typeof Promise === 'function' ? Promise : undefined;
831 const localRequestAnimationFrame =
@@ -899,11 +899,13 @@ export function commitMount(
899 case 'select':
900 case 'textarea':
901 if (newProps.autoFocus) {
902 - ((domElement: any):
903 - | HTMLButtonElement
904 - | HTMLInputElement
905 - | HTMLSelectElement
906 - | HTMLTextAreaElement).focus();
902 + (
903 + domElement as any as
904 + | HTMLButtonElement
905 + | HTMLInputElement
906 + | HTMLSelectElement
907 + | HTMLTextAreaElement
908 + ).focus();
909 }
910 return;
911 case 'img': {
@@ -917,7 +919,7 @@ export function commitMount(
919 // is already a noop regardless of which properties are assigned. We should revisit if browsers update
920 // this heuristic in the future.
921 if (newProps.src) {
920 - const src = (newProps: any).src;
922 + const src = (newProps as any).src;
923 if (enableSrcObject && typeof src === 'object') {
924 // For object src, we can't just set the src again to the same blob URL because it might have
925 // already revoked if it loaded before this. However, we can create a new blob URL and set that.
@@ -933,9 +935,11 @@ export function commitMount(
935 // path.
936 }
937 }
936 - ((domElement: any): HTMLImageElement).src = src;
938 + (domElement as any as HTMLImageElement).src = src;
939 } else if (newProps.srcSet) {
938 - ((domElement: any): HTMLImageElement).srcset = (newProps: any).srcSet;
940 + (domElement as any as HTMLImageElement).srcset = (
941 + newProps as any
942 + ).srcSet;
943 }
944 return;
945 }
@@ -1032,7 +1036,7 @@ export function appendChild(
1036
1037 function warnForReactChildrenConflict(container: Container): void {
1038 if (__DEV__) {
1035 - if ((container: any).__reactWarnedAboutChildrenConflict) {
1039 + if ((container as any).__reactWarnedAboutChildrenConflict) {
1040 return;
1041 }
1042 const props = getFiberCurrentPropsFromNode(container);
@@ -1043,7 +1047,7 @@ function warnForReactChildrenConflict(container: Container): void {
1047 typeof props.children === 'string' ||
1048 typeof props.children === 'number'
1049 ) {
1046 - (container: any).__reactWarnedAboutChildrenConflict = true;
1050 + (container as any).__reactWarnedAboutChildrenConflict = true;
1051 // Run the warning with the Fiber of the container for context of where the children are specified.
1052 // We could also maybe use the Portal. The current execution context is the child being added.
1053 runWithFiberInDEV(fiber, () => {
@@ -1054,7 +1058,7 @@ function warnForReactChildrenConflict(container: Container): void {
1058 );
1059 });
1060 } else if (props.dangerouslySetInnerHTML != null) {
1057 - (container: any).__reactWarnedAboutChildrenConflict = true;
1061 + (container as any).__reactWarnedAboutChildrenConflict = true;
1062 runWithFiberInDEV(fiber, () => {
1063 console.error(
1064 'Cannot use a ref on a React element as a container to `createRoot` or `createPortal` ' +
@@ -1077,12 +1081,12 @@ export function appendChildToContainer(
1081 }
1082 let parentNode: DocumentFragment | Element;
1083 if (container.nodeType === DOCUMENT_NODE) {
1080 - parentNode = (container: any).body;
1084 + parentNode = (container as any).body;
1085 } else if (
1086 !disableCommentsAsDOMContainers &&
1087 container.nodeType === COMMENT_NODE
1088 ) {
1085 - parentNode = (container.parentNode: any);
1089 + parentNode = container.parentNode as any;
1090 if (supportsMoveBefore && child.parentNode !== null) {
1091 // $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
1092 parentNode.moveBefore(child, container);
@@ -1091,9 +1095,9 @@ export function appendChildToContainer(
1095 }
1096 return;
1097 } else if (container.nodeName === 'HTML') {
1094 - parentNode = (container.ownerDocument.body: any);
1098 + parentNode = container.ownerDocument.body as any;
1099 } else {
1096 - parentNode = (container: any);
1100 + parentNode = container as any;
1101 }
1102 if (supportsMoveBefore && child.parentNode !== null) {
1103 // $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
@@ -1117,7 +1121,7 @@ export function appendChildToContainer(
1121 parentNode.onclick === null
1122 ) {
1123 // TODO: This cast may not be sound for SVG, MathML or custom elements.
1120 - trapClickOnNonInteractiveElement(((parentNode: any): HTMLElement));
1124 + trapClickOnNonInteractiveElement(parentNode as any as HTMLElement);
1125 }
1126 }
1127
@@ -1144,16 +1148,16 @@ export function insertInContainerBefore(
1148 }
1149 let parentNode: DocumentFragment | Element;
1150 if (container.nodeType === DOCUMENT_NODE) {
1147 - parentNode = (container: any).body;
1151 + parentNode = (container as any).body;
1152 } else if (
1153 !disableCommentsAsDOMContainers &&
1154 container.nodeType === COMMENT_NODE
1155 ) {
1152 - parentNode = (container.parentNode: any);
1156 + parentNode = container.parentNode as any;
1157 } else if (container.nodeName === 'HTML') {
1154 - parentNode = (container.ownerDocument.body: any);
1158 + parentNode = container.ownerDocument.body as any;
1159 } else {
1156 - parentNode = (container: any);
1160 + parentNode = container as any;
1161 }
1162 if (supportsMoveBefore && child.parentNode !== null) {
1163 // $FlowFixMe[prop-missing]: We've checked this with supportsMoveBefore.
@@ -1169,7 +1173,7 @@ export function isSingletonScope(type: string): boolean {
1173
1174 function createEvent(type: DOMEventName, bubbles: boolean): Event {
1175 const event = document.createEvent('Event');
1172 - event.initEvent(((type: any): string), bubbles, false);
1176 + event.initEvent(type as any as string, bubbles, false);
1177 return event;
1178 }
1179
@@ -1193,7 +1197,7 @@ function dispatchAfterDetachedBlur(target: HTMLElement): void {
1197 const event = createEvent('afterblur', false);
1198 // So we know what was detached, make the relatedTarget the
1199 // detached target on the "afterblur" event.
1196 - (event: any).relatedTarget = target;
1200 + (event as any).relatedTarget = target;
1201 // Dispatch the event on the document.
1202 document.dispatchEvent(event);
1203 }
@@ -1212,16 +1216,16 @@ export function removeChildFromContainer(
1216 ): void {
1217 let parentNode: DocumentFragment | Element;
1218 if (container.nodeType === DOCUMENT_NODE) {
1215 - parentNode = (container: any).body;
1219 + parentNode = (container as any).body;
1220 } else if (
1221 !disableCommentsAsDOMContainers &&
1222 container.nodeType === COMMENT_NODE
1223 ) {
1220 - parentNode = (container.parentNode: any);
1224 + parentNode = container.parentNode as any;
1225 } else if (container.nodeName === 'HTML') {
1222 - parentNode = (container.ownerDocument.body: any);
1226 + parentNode = container.ownerDocument.body as any;
1227 } else {
1224 - parentNode = (container: any);
1228 + parentNode = container as any;
1229 }
1230 parentNode.removeChild(child);
1231 }
@@ -1239,7 +1243,7 @@ function clearHydrationBoundary(
1243 const nextNode = node.nextSibling;
1244 parentInstance.removeChild(node);
1245 if (nextNode && nextNode.nodeType === COMMENT_NODE) {
1242 - const data = ((nextNode: any).data: string);
1246 + const data = (nextNode as any).data as string;
1247 if (data === SUSPENSE_END_DATA || data === ACTIVITY_END_DATA) {
1248 if (depth === 0) {
1249 parentInstance.removeChild(nextNode);
@@ -1261,18 +1265,18 @@ function clearHydrationBoundary(
1265 // If a preamble contribution marker is found within the bounds of this boundary,
1266 // then it contributed to the html tag and we need to reset it.
1267 const ownerDocument = parentInstance.ownerDocument;
1264 - const documentElement: Element = (ownerDocument.documentElement: any);
1268 + const documentElement: Element = ownerDocument.documentElement as any;
1269 releaseSingletonInstance(documentElement);
1270 } else if (data === PREAMBLE_CONTRIBUTION_HEAD) {
1271 const ownerDocument = parentInstance.ownerDocument;
1268 - const head: Element = (ownerDocument.head: any);
1272 + const head: Element = ownerDocument.head as any;
1273 releaseSingletonInstance(head);
1274 // We need to clear the head because this is the only singleton that can have children that
1275 // were part of this boundary but are not inside this boundary.
1276 clearHead(head);
1277 } else if (data === PREAMBLE_CONTRIBUTION_BODY) {
1278 const ownerDocument = parentInstance.ownerDocument;
1275 - const body: Element = (ownerDocument.body: any);
1279 + const body: Element = ownerDocument.body as any;
1280 releaseSingletonInstance(body);
1281 }
1282 }
@@ -1304,16 +1308,16 @@ function clearHydrationBoundaryFromContainer(
1308 ): void {
1309 let parentNode: DocumentFragment | Element;
1310 if (container.nodeType === DOCUMENT_NODE) {
1307 - parentNode = (container: any).body;
1311 + parentNode = (container as any).body;
1312 } else if (
1313 !disableCommentsAsDOMContainers &&
1314 container.nodeType === COMMENT_NODE
1315 ) {
1312 - parentNode = (container.parentNode: any);
1316 + parentNode = container.parentNode as any;
1317 } else if (container.nodeName === 'HTML') {
1314 - parentNode = (container.ownerDocument.body: any);
1318 + parentNode = container.ownerDocument.body as any;
1319 } else {
1316 - parentNode = (container: any);
1320 + parentNode = container as any;
1321 }
1322 clearHydrationBoundary(parentNode, hydrationInstance);
1323 // Retry if any event replaying was blocked on this.
@@ -1344,7 +1348,7 @@ function hideOrUnhideDehydratedBoundary(
1348 do {
1349 const nextNode = node.nextSibling;
1350 if (node.nodeType === ELEMENT_NODE) {
1347 - const instance = ((node: any): HTMLElement & {_stashedDisplay?: string});
1351 + const instance = node as any as HTMLElement & {_stashedDisplay?: string};
1352 if (isHidden) {
1353 instance._stashedDisplay = instance.style.display;
1354 instance.style.display = 'none';
@@ -1355,7 +1359,7 @@ function hideOrUnhideDehydratedBoundary(
1359 }
1360 }
1361 } else if (node.nodeType === TEXT_NODE) {
1358 - const textNode = ((node: any): Text & {_stashedText?: string});
1362 + const textNode = node as any as Text & {_stashedText?: string};
1363 if (isHidden) {
1364 textNode._stashedText = textNode.nodeValue;
1365 textNode.nodeValue = '';
@@ -1364,7 +1368,7 @@ function hideOrUnhideDehydratedBoundary(
1368 }
1369 }
1370 if (nextNode && nextNode.nodeType === COMMENT_NODE) {
1367 - const data = ((nextNode: any).data: string);
1371 + const data = (nextNode as any).data as string;
1372 if (data === SUSPENSE_END_DATA) {
1373 if (depth === 0) {
1374 return;
@@ -1395,7 +1399,7 @@ export function hideDehydratedBoundary(
1399 export function hideInstance(instance: Instance): void {
1400 // TODO: Does this work for all element types? What about MathML? Should we
1401 // pass host context to this method?
1398 - instance = ((instance: any): HTMLElement);
1402 + instance = instance as any as HTMLElement;
1403 const style = instance.style;
1404 // $FlowFixMe[method-unbinding]
1405 if (typeof style.setProperty === 'function') {
@@ -1416,7 +1420,7 @@ export function unhideDehydratedBoundary(
1420 }
1421
1422 export function unhideInstance(instance: Instance, props: Props): void {
1419 - instance = ((instance: any): HTMLElement);
1423 + instance = instance as any as HTMLElement;
1424 const styleProp = props[STYLE];
1425 const display =
1426 styleProp !== undefined &&
@@ -1447,7 +1451,7 @@ function warnForBlockInsideInline(instance: HTMLElement) {
1451 let node: Node = nextNode;
1452 if (
1453 node.nodeType === ELEMENT_NODE &&
1450 - getComputedStyle((node: any)).display === 'block'
1454 + getComputedStyle(node as any).display === 'block'
1455 ) {
1456 const fiber =
1457 getInstanceFromNode(node) || getInstanceFromNode(instance);
@@ -1465,7 +1469,7 @@ function warnForBlockInsideInline(instance: HTMLElement) {
1469 );
1470 },
1471 instance.tagName,
1468 - (node: any).tagName,
1472 + (node as any).tagName,
1473 );
1474 break;
1475 }
@@ -1507,7 +1511,7 @@ export function applyViewTransitionName(
1511 name: string,
1512 className: ?string,
1513 ): void {
1510 - instance = ((instance: any): HTMLElement);
1514 + instance = instance as any as HTMLElement;
1515 // If the name isn't valid CSS identifier, base64 encode the name instead.
1516 // This doesn't let you select it in custom CSS selectors but it does work in current
1517 // browsers.
@@ -1556,7 +1560,7 @@ export function restoreViewTransitionName(
1560 instance: Instance,
1561 props: Props,
1562 ): void {
1559 - instance = ((instance: any): HTMLElement);
1563 + instance = instance as any as HTMLElement;
1564 const style = instance.style;
1565 const styleProp = props[STYLE];
1566 const viewTransitionName =
@@ -1647,7 +1651,7 @@ export function cancelViewTransitionName(
1651 export function cancelRootViewTransitionName(rootContainer: Container): void {
1652 const documentElement: null | HTMLElement =
1653 rootContainer.nodeType === DOCUMENT_NODE
1650 - ? (rootContainer: any).documentElement
1654 + ? (rootContainer as any).documentElement
1655 : rootContainer.ownerDocument.documentElement;
1656
1657 if (
@@ -1701,13 +1705,13 @@ export function cancelRootViewTransitionName(rootContainer: Container): void {
1705 export function restoreRootViewTransitionName(rootContainer: Container): void {
1706 let containerInstance: Instance;
1707 if (rootContainer.nodeType === DOCUMENT_NODE) {
1704 - containerInstance = (rootContainer: any).body;
1708 + containerInstance = (rootContainer as any).body;
1709 } else if (rootContainer.nodeName === 'HTML') {
1706 - containerInstance = (rootContainer.ownerDocument.body: any);
1710 + containerInstance = rootContainer.ownerDocument.body as any;
1711 } else {
1712 // If the container is not the whole document, then we ideally should probably
1713 // clone the whole document outside of the React too.
1710 - containerInstance = (rootContainer: any);
1714 + containerInstance = rootContainer as any;
1715 }
1716 if (
1717 !disableCommentsAsDOMContainers &&
@@ -1816,7 +1820,7 @@ export function cloneRootViewTransitionContainer(
1820 // the clone so we first clear the name of the root container.
1821 const documentElement: null | HTMLElement =
1822 rootContainer.nodeType === DOCUMENT_NODE
1819 - ? (rootContainer: any).documentElement
1823 + ? (rootContainer as any).documentElement
1824 : rootContainer.ownerDocument.documentElement;
1825 if (
1826 documentElement !== null &&
@@ -1829,9 +1833,9 @@ export function cloneRootViewTransitionContainer(
1833
1834 let containerInstance: HTMLElement;
1835 if (rootContainer.nodeType === DOCUMENT_NODE) {
1832 - containerInstance = (rootContainer: any).body;
1836 + containerInstance = (rootContainer as any).body;
1837 } else if (rootContainer.nodeName === 'HTML') {
1834 - containerInstance = (rootContainer.ownerDocument.body: any);
1838 + containerInstance = rootContainer.ownerDocument.body as any;
1839 } else if (
1840 !disableCommentsAsDOMContainers &&
1841 rootContainer.nodeType === COMMENT_NODE
@@ -1842,7 +1846,7 @@ export function cloneRootViewTransitionContainer(
1846 } else {
1847 // If the container is not the whole document, then we ideally should probably
1848 // clone the whole document outside of the React too.
1845 - containerInstance = (rootContainer: any);
1849 + containerInstance = rootContainer as any;
1850 }
1851
1852 const containerParent = containerInstance.parentNode;
@@ -1945,13 +1949,13 @@ export function removeRootViewTransitionClone(
1949 ): void {
1950 let containerInstance: Instance;
1951 if (rootContainer.nodeType === DOCUMENT_NODE) {
1948 - containerInstance = (rootContainer: any).body;
1952 + containerInstance = (rootContainer as any).body;
1953 } else if (rootContainer.nodeName === 'HTML') {
1950 - containerInstance = (rootContainer.ownerDocument.body: any);
1954 + containerInstance = rootContainer.ownerDocument.body as any;
1955 } else {
1956 // If the container is not the whole document, then we ideally should probably
1957 // clone the whole document outside of the React too.
1954 - containerInstance = (rootContainer: any);
1958 + containerInstance = rootContainer as any;
1959 }
1960 const containerParent = containerInstance.parentNode;
1961 if (containerParent === null) {
@@ -2143,7 +2147,7 @@ function customizeViewTransitionError(
2147 /** @noinline */
2148 function forceLayout(ownerDocument: Document) {
2149 // This function exists to trick minifiers to not remove this unused member expression.
2146 - return (ownerDocument.documentElement: any).clientHeight;
2150 + return (ownerDocument.documentElement as any).clientHeight;
2151 }
2152
2153 function waitForImageToLoad(this: HTMLImageElement, resolve: () => void) {
@@ -2168,7 +2172,7 @@ export function startViewTransition(
2172 ): null | RunningViewTransition {
2173 const ownerDocument: Document =
2174 rootContainer.nodeType === DOCUMENT_NODE
2171 - ? (rootContainer: any)
2175 + ? (rootContainer as any)
2176 : rootContainer.ownerDocument;
2177 try {
2178 // $FlowFixMe[prop-missing]
@@ -2267,14 +2271,14 @@ export function startViewTransition(
2271 const viewTransitionAnimations: Array<Animation> = [];
2272
2273 const readyCallback = () => {
2270 - const documentElement: Element = (ownerDocument.documentElement: any);
2274 + const documentElement: Element = ownerDocument.documentElement as any;
2275 // Loop through all View Transition Animations.
2276 // $FlowFixMe[prop-missing]
2277 // $FlowFixMe[incompatible-type]
2278 const animations = documentElement.getAnimations({subtree: true});
2279 for (let i = 0; i < animations.length; i++) {
2280 const animation = animations[i];
2277 - const effect: KeyframeEffect = (animation.effect: any);
2281 + const effect: KeyframeEffect = animation.effect as any;
2282 // $FlowFixMe[prop-missing]
2283 const pseudoElement: ?string = effect.pseudoElement;
2284 if (
@@ -2499,10 +2503,9 @@ function animateGesture(
2503 if (keyframe.translate == null || keyframe.translate === '') {
2504 // TODO: If there's a CSS rule targeting translate on the pseudo element
2505 // already we need to merge it.
2502 - const elementTranslate: ?string = (getComputedStyle(
2503 - targetElement,
2504 - pseudoElement,
2505 - ): any).translate;
2506 + const elementTranslate: ?string = (
2507 + getComputedStyle(targetElement, pseudoElement) as any
2508 + ).translate;
2509 keyframe.translate = mergeTranslate(
2510 elementTranslate,
2511 '20000px 20000px',
@@ -2601,7 +2604,7 @@ export function startGestureTransition(
2604 ): null | RunningViewTransition {
2605 const ownerDocument: Document =
2606 rootContainer.nodeType === DOCUMENT_NODE
2604 - ? (rootContainer: any)
2607 + ? (rootContainer as any)
2608 : rootContainer.ownerDocument;
2609 try {
2610 // Force layout before we start the Transition. This works around a bug in Safari
@@ -2618,7 +2621,7 @@ export function startGestureTransition(
2621 const customTimelineCleanup: Array<() => void> = []; // Cleanup Animations started in a CustomTimeline
2622 const viewTransitionAnimations: Array<Animation> = [];
2623 const readyCallback = () => {
2621 - const documentElement: Element = (ownerDocument.documentElement: any);
2624 + const documentElement: Element = ownerDocument.documentElement as any;
2625 // Loop through all View Transition Animations.
2626 // $FlowFixMe[prop-missing]
2627 // $FlowFixMe[incompatible-type]
@@ -2630,7 +2633,7 @@ export function startGestureTransition(
2633 // Collect the longest duration of any view-transition animation including delay.
2634 let longestDuration = 0;
2635 for (let i = 0; i < animations.length; i++) {
2633 - const effect: KeyframeEffect = (animations[i].effect: any);
2636 + const effect: KeyframeEffect = animations[i].effect as any;
2637 // $FlowFixMe[prop-missing]
2638 const pseudoElement: ?string = effect.pseudoElement;
2639 if (pseudoElement == null) {
@@ -2665,7 +2668,7 @@ export function startGestureTransition(
2668 if (anim.playState !== 'running') {
2669 continue;
2670 }
2668 - const effect: KeyframeEffect = (anim.effect: any);
2671 + const effect: KeyframeEffect = anim.effect as any;
2672 // $FlowFixMe[prop-missing]
2673 const pseudoElement: ?string = effect.pseudoElement;
2674 if (
@@ -2882,7 +2885,7 @@ function ViewTransitionPseudoElement(
2885 name: string,
2886 ) {
2887 // TODO: Get the owner document from the root container.
2885 - this._scope = (document.documentElement: any);
2888 + this._scope = document.documentElement as any;
2889 this._selector = '::view-transition-' + pseudo + '(' + name + ')';
2890 }
2891 // $FlowFixMe[prop-missing]
@@ -2897,9 +2900,9 @@ ViewTransitionPseudoElement.prototype.animate = function (
2900 duration: options,
2901 }
2902 : Object.assign(
2900 - (// $FlowFixMe[prop-missing]
2903 + // $FlowFixMe[prop-missing]
2904 // $FlowFixMe[incompatible-type]
2902 - {}: KeyframeAnimationOptions),
2905 + {} as KeyframeAnimationOptions,
2906 options,
2907 );
2908 opts.pseudoElement = this._selector;
@@ -2924,7 +2927,7 @@ ViewTransitionPseudoElement.prototype.getAnimations = function (
2927 target?: Element,
2928 pseudoElement?: string,
2929 ...
2927 - } = (animations[i].effect: any);
2930 + } = animations[i].effect as any;
2931 // TODO: Handle multiple child instances.
2932 if (
2933 effect !== null &&
@@ -2950,10 +2953,10 @@ export function createViewTransitionInstance(
2953 ): ViewTransitionInstance {
2954 return {
2955 name: name,
2953 - group: new (ViewTransitionPseudoElement: any)('group', name),
2954 - imagePair: new (ViewTransitionPseudoElement: any)('image-pair', name),
2955 - old: new (ViewTransitionPseudoElement: any)('old', name),
2956 - new: new (ViewTransitionPseudoElement: any)('new', name),
2956 + group: new (ViewTransitionPseudoElement as any)('group', name),
2957 + imagePair: new (ViewTransitionPseudoElement as any)('image-pair', name),
2958 + old: new (ViewTransitionPseudoElement as any)('old', name),
2959 + new: new (ViewTransitionPseudoElement as any)('new', name),
2960 };
2961 }
2962
@@ -3361,7 +3364,7 @@ FragmentInstance.prototype.getRootNode = function (
3364 getInstanceFromHostFiber<Instance>(parentHostFiber);
3365 const rootNode =
3366 // $FlowFixMe[incompatible-type] Flow expects Node
3364 - (parentHostInstance.getRootNode(getRootNodeOptions): Document | ShadowRoot);
3367 + parentHostInstance.getRootNode(getRootNodeOptions) as Document | ShadowRoot;
3368 return rootNode;
3369 };
3370 // $FlowFixMe[prop-missing]
@@ -3396,7 +3399,7 @@ FragmentInstance.prototype.compareDocumentPosition = function (
3399 // our best guess is to use the parent of the child instance, rather than
3400 // the fiber tree host parent.
3401 const parentHostInstanceFromDOM = fiberIsPortaledIntoHost(this._fragmentFiber)
3399 - ? (firstNode.parentElement: ?Instance)
3402 + ? (firstNode.parentElement as ?Instance)
3403 : parentHostInstance;
3404
3405 if (parentHostInstanceFromDOM == null) {
@@ -3600,7 +3603,7 @@ function addFragmentHandleToInstance(
3603 export function createFragmentInstance(
3604 fragmentFiber: Fiber,
3605 ): FragmentInstanceType {
3603 - const fragmentInstance = new (FragmentInstance: any)(fragmentFiber);
3606 + const fragmentInstance = new (FragmentInstance as any)(fragmentFiber);
3607 if (enableFragmentRefsInstanceHandles) {
3608 traverseFragmentInstance(
3609 fragmentFiber,
@@ -3625,7 +3628,7 @@ export function commitNewChildToFragmentInstance(
3628 if (childInstance.nodeType === TEXT_NODE) {
3629 return;
3630 }
3628 - const instance: InstanceWithFragmentHandles = (childInstance: any);
3631 + const instance: InstanceWithFragmentHandles = childInstance as any;
3632 const eventListeners = fragmentInstance._eventListeners;
3633 if (eventListeners !== null) {
3634 for (let i = 0; i < eventListeners.length; i++) {
@@ -3650,7 +3653,7 @@ export function deleteChildFromFragmentInstance(
3653 if (childInstance.nodeType === TEXT_NODE) {
3654 return;
3655 }
3653 - const instance: InstanceWithFragmentHandles = (childInstance: any);
3656 + const instance: InstanceWithFragmentHandles = childInstance as any;
3657 const eventListeners = fragmentInstance._eventListeners;
3658 if (eventListeners !== null) {
3659 for (let i = 0; i < eventListeners.length; i++) {
@@ -3696,7 +3699,7 @@ function clearContainerSparingly(container: Node) {
3699 case 'HTML':
3700 case 'HEAD':
3701 case 'BODY': {
3699 - const element: Element = (node: any);
3702 + const element: Element = node as any;
3703 clearContainerSparingly(element);
3704 // If these singleton instances had previously been rendered with React they
3705 // may still hold on to references to the previous fiber tree. We detatch them
@@ -3723,7 +3726,9 @@ function clearContainerSparingly(container: Node) {
3726 }
3727 // Stylesheet tags are retained because they may likely come from 3rd party scripts and extensions
3728 case 'LINK': {
3726 - if (((node: any): HTMLLinkElement).rel.toLowerCase() === 'stylesheet') {
3729 + if (
3730 + (node as any as HTMLLinkElement).rel.toLowerCase() === 'stylesheet'
3731 + ) {
3732 continue;
3733 }
3734 }
@@ -3743,7 +3748,7 @@ function clearHead(head: Element): void {
3748 nodeName === 'SCRIPT' ||
3749 nodeName === 'STYLE' ||
3750 (nodeName === 'LINK' &&
3746 - ((node: any): HTMLLinkElement).rel.toLowerCase() === 'stylesheet')
3751 + (node as any as HTMLLinkElement).rel.toLowerCase() === 'stylesheet')
3752 ) {
3753 // retain these nodes
3754 } else {
@@ -3763,7 +3768,7 @@ export function bindInstance(
3768 props: Props,
3769 internalInstanceHandle: mixed,
3770 ) {
3766 - precacheFiberNode((internalInstanceHandle: any), instance);
3771 + precacheFiberNode(internalInstanceHandle as any, instance);
3772 updateFiberProps(instance, props);
3773 }
3774
@@ -3780,12 +3785,15 @@ export function canHydrateInstance(
3785 inRootOrSingleton: boolean,
3786 ): null | Instance {
3787 while (instance.nodeType === ELEMENT_NODE) {
3783 - const element: Element = (instance: any);
3784 - const anyProps = (props: any);
3788 + const element: Element = instance as any;
3789 + const anyProps = props as any;
3790 if (element.nodeName.toLowerCase() !== type.toLowerCase()) {
3791 if (!inRootOrSingleton) {
3792 // Usually we error for mismatched tags.
3788 - if (element.nodeName === 'INPUT' && (element: any).type === 'hidden') {
3793 + if (
3794 + element.nodeName === 'INPUT' &&
3795 + (element as any).type === 'hidden'
3796 + ) {
3797 // If we have extra hidden inputs, we don't mismatch. This allows us to embed
3798 // extra form data in the original form.
3799 } else {
@@ -3795,7 +3803,7 @@ export function canHydrateInstance(
3803 // In root or singleton parents we skip past mismatched instances.
3804 } else if (!inRootOrSingleton) {
3805 // Match
3798 - if (type === 'input' && (element: any).type === 'hidden') {
3806 + if (type === 'input' && (element as any).type === 'hidden') {
3807 if (__DEV__) {
3808 checkAttributeStringCoercion(anyProps.name, 'name');
3809 }
@@ -3931,7 +3939,7 @@ export function canHydrateTextInstance(
3939 if (
3940 instance.nodeType === ELEMENT_NODE &&
3941 instance.nodeName === 'INPUT' &&
3934 - (instance: any).type === 'hidden'
3942 + (instance as any).type === 'hidden'
3943 ) {
3944 // If we have extra hidden inputs, we don't mismatch. This allows us to
3945 // embed extra form data in the original form.
@@ -3945,7 +3953,7 @@ export function canHydrateTextInstance(
3953 instance = nextInstance;
3954 }
3955 // This has now been refined to a text node.
3948 - return ((instance: any): TextInstance);
3956 + return instance as any as TextInstance;
3957 }
3958
3959 function canHydrateHydrationBoundary(
@@ -3956,7 +3964,7 @@ function canHydrateHydrationBoundary(
3964 if (
3965 instance.nodeType === ELEMENT_NODE &&
3966 instance.nodeName === 'INPUT' &&
3959 - (instance: any).type === 'hidden'
3967 + (instance as any).type === 'hidden'
3968 ) {
3969 // If we have extra hidden inputs, we don't mismatch. This allows us to
3970 // embed extra form data in the original form.
@@ -3970,7 +3978,7 @@ function canHydrateHydrationBoundary(
3978 instance = nextInstance;
3979 }
3980 // This has now been refined to a hydration boundary node.
3973 - return (instance: any);
3981 + return instance as any;
3982 }
3983
3984 export function canHydrateActivityInstance(
@@ -3985,7 +3993,7 @@ export function canHydrateActivityInstance(
3993 hydratableInstance !== null &&
3994 hydratableInstance.data === ACTIVITY_START_DATA
3995 ) {
3988 - return (hydratableInstance: any);
3996 + return hydratableInstance as any;
3997 }
3998 return null;
3999 }
@@ -4002,7 +4010,7 @@ export function canHydrateSuspenseInstance(
4010 hydratableInstance !== null &&
4011 hydratableInstance.data !== ACTIVITY_START_DATA
4012 ) {
4005 - return (hydratableInstance: any);
4013 + return hydratableInstance as any;
4014 }
4015 return null;
4016 }
@@ -4033,7 +4041,8 @@ export function getSuspenseInstanceFallbackErrorDetails(
4041 componentStack?: string,
4042 } {
4043 const dataset =
4036 - instance.nextSibling && ((instance.nextSibling: any): HTMLElement).dataset;
4044 + instance.nextSibling &&
4045 + (instance.nextSibling as any as HTMLElement).dataset;
4046 let digest, message, stack, componentStack;
4047 if (dataset) {
4048 digest = dataset.dgst;
@@ -4105,12 +4114,12 @@ export function canHydrateFormStateMarker(
4114 }
4115 instance = nextInstance;
4116 }
4108 - const nodeData = (instance: any).data;
4117 + const nodeData = (instance as any).data;
4118 if (
4119 nodeData === FORM_STATE_IS_MATCHING ||
4120 nodeData === FORM_STATE_IS_NOT_MATCHING
4121 ) {
4113 - const markerInstance: FormStateMarkerInstance = (instance: any);
4122 + const markerInstance: FormStateMarkerInstance = instance as any;
4123 return markerInstance;
4124 }
4125 return null;
@@ -4124,13 +4133,13 @@ export function isFormStateMarkerMatching(
4133
4134 function getNextHydratable(node: ?Node) {
4135 // Skip non-hydratable nodes.
4127 - for (; node != null; node = ((node: any): Node).nextSibling) {
4136 + for (; node != null; node = (node as any as Node).nextSibling) {
4137 const nodeType = node.nodeType;
4138 if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) {
4139 break;
4140 }
4141 if (nodeType === COMMENT_NODE) {
4133 - const data = (node: any).data;
4142 + const data = (node as any).data;
4143 if (
4144 data === SUSPENSE_START_DATA ||
4145 data === SUSPENSE_FALLBACK_START_DATA ||
@@ -4147,7 +4156,7 @@ function getNextHydratable(node: ?Node) {
4156 }
4157 }
4158 }
4150 - return (node: any);
4159 + return node as any;
4160 }
4161
4162 export function getNextHydratableSibling(
@@ -4168,13 +4177,13 @@ export function getFirstHydratableChildWithinContainer(
4177 let parentElement: Element;
4178 switch (parentContainer.nodeType) {
4179 case DOCUMENT_NODE:
4171 - parentElement = (parentContainer: any).body;
4180 + parentElement = (parentContainer as any).body;
4181 break;
4182 default: {
4183 if (parentContainer.nodeName === 'HTML') {
4175 - parentElement = (parentContainer: any).ownerDocument.body;
4184 + parentElement = (parentContainer as any).ownerDocument.body;
4185 } else {
4177 - parentElement = (parentContainer: any);
4186 + parentElement = parentContainer as any;
4187 }
4188 }
4189 }
@@ -4235,7 +4244,7 @@ export function describeHydratableInstanceForDevWarnings(
4244 // Reverse engineer a set of props that can print for dev warnings
4245 return {
4246 type: instance.nodeName.toLowerCase(),
4238 - props: getPropsFromElement((instance: any)),
4247 + props: getPropsFromElement(instance as any),
4248 };
4249 } else if (instance.nodeType === COMMENT_NODE) {
4250 if (instance.data === ACTIVITY_START_DATA) {
@@ -4260,7 +4269,7 @@ export function validateHydratableInstance(
4269 ): boolean {
4270 if (__DEV__) {
4271 // TODO: take namespace into account when validating.
4263 - const hostContextDev: HostContextDev = (hostContext: any);
4272 + const hostContextDev: HostContextDev = hostContext as any;
4273 return validateDOMNesting(type, hostContextDev.ancestorInfo);
4274 }
4275 return true;
@@ -4296,7 +4305,7 @@ export function validateHydratableTextInstance(
4305 hostContext: HostContext,
4306 ): boolean {
4307 if (__DEV__) {
4299 - const hostContextDev = ((hostContext: any): HostContextDev);
4308 + const hostContextDev = hostContext as any as HostContextDev;
4309 const ancestor = hostContextDev.ancestorInfo.current;
4310 if (ancestor != null) {
4311 return validateTextNesting(
@@ -4359,10 +4368,10 @@ function getNextHydratableInstanceAfterHydrationBoundary(
4368 let depth = 0;
4369 while (node) {
4370 if (node.nodeType === COMMENT_NODE) {
4362 - const data = ((node: any).data: string);
4371 + const data = (node as any).data as string;
4372 if (data === SUSPENSE_END_DATA || data === ACTIVITY_END_DATA) {
4373 if (depth === 0) {
4365 - return getNextHydratableSibling((node: any));
4374 + return getNextHydratableSibling(node as any);
4375 } else {
4376 depth--;
4377 }
@@ -4407,7 +4416,7 @@ export function getParentHydrationBoundary(
4416 let depth = 0;
4417 while (node) {
4418 if (node.nodeType === COMMENT_NODE) {
4410 - const data = ((node: any).data: string);
4419 + const data = (node as any).data as string;
4420 if (
4421 data === SUSPENSE_START_DATA ||
4422 data === SUSPENSE_FALLBACK_START_DATA ||
@@ -4416,7 +4425,7 @@ export function getParentHydrationBoundary(
4425 data === ACTIVITY_START_DATA
4426 ) {
4427 if (depth === 0) {
4419 - return ((node: any): SuspenseInstance | ActivityInstance);
4428 + return node as any as SuspenseInstance | ActivityInstance;
4429 } else {
4430 depth--;
4431 }
@@ -4472,7 +4481,7 @@ export function findFiberRoot(node: Instance): null | FiberRoot {
4481 while (index < stack.length) {
4482 const current = stack[index++];
4483 if (isContainerMarkedAsRoot(current)) {
4475 - return ((getInstanceFromNodeDOMTree(current): any): FiberRoot);
4484 + return getInstanceFromNodeDOMTree(current) as any as FiberRoot;
4485 }
4486 stack.push(...current.children);
4487 }
@@ -4532,7 +4541,7 @@ export function setFocusIfFocusable(
4541 //
4542 // We could compare the node to document.activeElement after focus,
4543 // but this would not handle the case where application code managed focus to automatically blur.
4535 - const element = ((node: any): HTMLElement);
4544 + const element = node as any as HTMLElement;
4545
4546 // If this element is already the active element, it's focusable and already
4547 // focused. Calling .focus() on it would be a no-op (no focus event fires),
@@ -4602,7 +4611,7 @@ export function setupIntersectionObserver(
4611
4612 const observer = new IntersectionObserver(handleIntersection, options);
4613 targets.forEach(target => {
4605 - observer.observe((target: any));
4614 + observer.observe(target as any);
4615 });
4616
4617 return {
@@ -4612,11 +4621,11 @@ export function setupIntersectionObserver(
4621 rect: getBoundingRect(target),
4622 ratio: 0,
4623 });
4615 - observer.observe((target: any));
4624 + observer.observe(target as any);
4625 },
4626 unobserve: target => {
4627 rectRatioCache.delete(target);
4619 - observer.unobserve((target: any));
4628 + observer.unobserve(target as any);
4629 },
4630 };
4631 }
@@ -4645,7 +4654,7 @@ export function resolveSingletonInstance(
4654 validateDOMNestingDev: boolean,
4655 ): Instance {
4656 if (__DEV__) {
4648 - const hostContextDev = ((hostContext: any): HostContextDev);
4657 + const hostContextDev = hostContext as any as HostContextDev;
4658 if (validateDOMNestingDev) {
4659 validateDOMNesting(type, hostContextDev.ancestorInfo);
4660 }
@@ -4837,14 +4846,18 @@ export type HoistableRoot = Document | ShadowRoot;
4846 // getRootNode is missing from IE and old jsdom versions
4847 export function getHoistableRoot(container: Container): HoistableRoot {
4848 // $FlowFixMe[method-unbinding]
4840 - return typeof container.getRootNode === 'function'
4841 - ? /* $FlowFixMe[incompatible-type] Flow types this as returning a `Node`,
4842 - * but it's either a `Document` or `ShadowRoot`. */
4843 - (container.getRootNode(): Document | ShadowRoot)
4844 - : container.nodeType === DOCUMENT_NODE
4845 - ? // $FlowFixMe[incompatible-type] We've constrained this to be a Document which satisfies the return type
4846 - (container: Document)
4847 - : container.ownerDocument;
4849 + if (typeof container.getRootNode === 'function') {
4850 + const rootNode = container.getRootNode();
4851 + if (rootNode.nodeType === DOCUMENT_NODE) {
4852 + return rootNode as any as Document;
4853 + }
4854 + if (rootNode.nodeType === DOCUMENT_FRAGMENT_NODE) {
4855 + return rootNode as any as ShadowRoot;
4856 + }
4857 + }
4858 + return container.nodeType === DOCUMENT_NODE
4859 + ? (container as any as Document)
4860 + : container.ownerDocument;
4861 }
4862
4863 function getCurrentResourceRoot(): null | HoistableRoot {
@@ -4935,7 +4948,7 @@ function preconnectAs(
4948 const instance = ownerDocument.createElement('link');
4949 setInitialProperties(instance, 'link', preconnectProps);
4950 markNodeAsHoistable(instance);
4938 - (ownerDocument.head: any).appendChild(instance);
4951 + (ownerDocument.head as any).appendChild(instance);
4952 }
4953 }
4954 }
@@ -4992,7 +5005,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
5005 }
5006 if (!preloadPropsMap.has(key)) {
5007 const preloadProps = Object.assign(
4995 - ({
5008 + {
5009 rel: 'preload',
5010 // There is a bug in Safari where imageSrcSet is not respected on preload links
5011 // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image.
@@ -5001,7 +5014,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
5014 href:
5015 as === 'image' && options && options.imageSrcSet ? undefined : href,
5016 as,
5004 - }: PreloadProps),
5017 + } as PreloadProps,
5018 options,
5019 );
5020 preloadPropsMap.set(key, preloadProps);
@@ -5030,7 +5043,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
5043 };
5044 }
5045 markNodeAsHoistable(instance);
5033 - (ownerDocument.head: any).appendChild(instance);
5046 + (ownerDocument.head as any).appendChild(instance);
5047 }
5048 }
5049 }
@@ -5063,10 +5076,10 @@ function preloadModule(href: string, options?: ?PreloadModuleImplOptions) {
5076
5077 if (!preloadPropsMap.has(key)) {
5078 const props: PreloadModuleProps = Object.assign(
5066 - ({
5079 + {
5080 rel: 'modulepreload',
5081 href,
5069 - }: PreloadModuleProps),
5082 + } as PreloadModuleProps,
5083 options,
5084 );
5085 preloadPropsMap.set(key, props);
@@ -5087,7 +5100,7 @@ function preloadModule(href: string, options?: ?PreloadModuleImplOptions) {
5100 const instance = ownerDocument.createElement('link');
5101 setInitialProperties(instance, 'link', props);
5102 markNodeAsHoistable(instance);
5090 - (ownerDocument.head: any).appendChild(instance);
5103 + (ownerDocument.head as any).appendChild(instance);
5104 }
5105 }
5106 }
@@ -5129,11 +5142,11 @@ function preinitStyle(
5142 } else {
5143 // Construct a new instance and insert it
5144 const stylesheetProps = Object.assign(
5132 - ({
5145 + {
5146 rel: 'stylesheet',
5147 href,
5148 'data-precedence': precedence,
5136 - }: StylesheetProps),
5149 + } as StylesheetProps,
5150 options,
5151 );
5152 const preloadProps = preloadPropsMap.get(key);
@@ -5144,7 +5157,7 @@ function preinitStyle(
5157 markNodeAsHoistable(link);
5158 setInitialProperties(link, 'link', stylesheetProps);
5159
5147 - (link: any)._p = new Promise((resolve, reject) => {
5160 + (link as any)._p = new Promise((resolve, reject) => {
5161 link.onload = resolve;
5162 link.onerror = reject;
5163 });
@@ -5197,10 +5210,10 @@ function preinitScript(src: string, options?: ?PreinitScriptOptions) {
5210 if (!instance) {
5211 // Construct a new instance and insert it
5212 const scriptProps = Object.assign(
5200 - ({
5213 + {
5214 src,
5215 async: true,
5203 - }: ScriptProps),
5216 + } as ScriptProps,
5217 options,
5218 );
5219 // Adopt certain preload props
@@ -5211,7 +5224,7 @@ function preinitScript(src: string, options?: ?PreinitScriptOptions) {
5224 instance = ownerDocument.createElement('script');
5225 markNodeAsHoistable(instance);
5226 setInitialProperties(instance, 'link', scriptProps);
5214 - (ownerDocument.head: any).appendChild(instance);
5227 + (ownerDocument.head as any).appendChild(instance);
5228 }
5229
5230 // Construct a Resource and cache it
@@ -5253,11 +5266,11 @@ function preinitModuleScript(
5266 if (!instance) {
5267 // Construct a new instance and insert it
5268 const scriptProps = Object.assign(
5256 - ({
5269 + {
5270 src,
5271 async: true,
5272 type: 'module',
5260 - }: ScriptProps),
5273 + } as ScriptProps,
5274 options,
5275 );
5276 // Adopt certain preload props
@@ -5268,7 +5281,7 @@ function preinitModuleScript(
5281 instance = ownerDocument.createElement('script');
5282 markNodeAsHoistable(instance);
5283 setInitialProperties(instance, 'link', scriptProps);
5271 - (ownerDocument.head: any).appendChild(instance);
5284 + (ownerDocument.head as any).appendChild(instance);
5285 }
5286
5287 // Construct a Resource and cache it
@@ -5355,7 +5368,7 @@ export function getResource(
5368 if (!resource) {
5369 // We asserted this above but Flow can't figure out that the type satisfies
5370 const ownerDocument = getDocumentFromRoot(resourceRoot);
5358 - resource = ({
5371 + resource = {
5372 type: 'stylesheet',
5373 instance: null,
5374 count: 0,
@@ -5363,13 +5376,13 @@ export function getResource(
5376 loading: NotLoaded,
5377 preload: null,
5378 },
5366 - }: StylesheetResource);
5379 + } as StylesheetResource;
5380 styles.set(key, resource);
5381 const instance = ownerDocument.querySelector(
5382 getStylesheetSelectorFromKey(key),
5383 );
5384 if (instance) {
5372 - const loadingState: ?Promise<mixed> = (instance: any)._p;
5385 + const loadingState: ?Promise<mixed> = (instance as any)._p;
5386 if (loadingState) {
5387 // This instance is inserted as part of a boundary reveal and is not yet
5388 // loaded
@@ -5579,7 +5592,7 @@ function preloadStylesheet(
5592 );
5593 setInitialProperties(instance, 'link', preloadProps);
5594 markNodeAsHoistable(instance);
5582 - (ownerDocument.head: any).appendChild(instance);
5595 + (ownerDocument.head as any).appendChild(instance);
5596 }
5597 // $FlowFixMe[incompatible-type] -- if instance is an Element it will also be an HTMLLinkElement
5598 state.preload = instance;
@@ -5676,8 +5689,8 @@ export function acquireResource(
5689 const ownerDocument = getDocumentFromRoot(hoistableRoot);
5690 instance = ownerDocument.createElement('link');
5691 markNodeAsHoistable(instance);
5679 - const linkInstance: HTMLLinkElement = (instance: any);
5680 - (linkInstance: any)._p = new Promise((resolve, reject) => {
5692 + const linkInstance: HTMLLinkElement = instance as any;
5693 + (linkInstance as any)._p = new Promise((resolve, reject) => {
5694 linkInstance.onload = resolve;
5695 linkInstance.onerror = reject;
5696 });
@@ -5717,7 +5730,7 @@ export function acquireResource(
5730 instance = ownerDocument.createElement('script');
5731 markNodeAsHoistable(instance);
5732 setInitialProperties(instance, 'link', scriptProps);
5720 - (ownerDocument.head: any).appendChild(instance);
5733 + (ownerDocument.head as any).appendChild(instance);
5734 resource.instance = instance;
5735
5736 return instance;
@@ -5786,12 +5799,12 @@ function insertStylesheet(
5799 // We get the prior from the document so we know it is in the tree.
5800 // We also know that links can't be the topmost Node so the parentNode
5801 // must exist.
5789 - ((prior.parentNode: any): Node).insertBefore(instance, prior.nextSibling);
5802 + (prior.parentNode as any as Node).insertBefore(instance, prior.nextSibling);
5803 } else {
5804 const parent =
5805 root.nodeType === DOCUMENT_NODE
5793 - ? ((((root: any): Document).head: any): Element)
5794 - : ((root: any): ShadowRoot);
5806 + ? ((root as any as Document).head as any as Element)
5807 + : (root as any as ShadowRoot);
5808 parent.insertBefore(instance, parent.firstChild);
5809 }
5810 }
@@ -5842,7 +5855,7 @@ export function hydrateHoistable(
5855 instance.hasAttribute('itemprop')
5856 ) {
5857 instance = ownerDocument.createElement(type);
5845 - (ownerDocument.head: any).insertBefore(
5858 + (ownerDocument.head as any).insertBefore(
5859 instance,
5860 ownerDocument.querySelector('head > title'),
5861 );
@@ -5880,7 +5893,7 @@ export function hydrateHoistable(
5893 }
5894 instance = ownerDocument.createElement(type);
5895 setInitialProperties(instance, type, props);
5883 - (ownerDocument.head: any).appendChild(instance);
5896 + (ownerDocument.head as any).appendChild(instance);
5897 break;
5898 }
5899 case 'meta': {
@@ -5924,7 +5937,7 @@ export function hydrateHoistable(
5937 }
5938 instance = ownerDocument.createElement(type);
5939 setInitialProperties(instance, type, props);
5927 - (ownerDocument.head: any).appendChild(instance);
5940 + (ownerDocument.head as any).appendChild(instance);
5941 break;
5942 }
5943 default:
@@ -5967,7 +5980,7 @@ function getHydratableHoistableCache(
5980 }
5981
5982 // Mark this cache as seeded for this type
5970 - cache.set(type, (null: any));
5983 + cache.set(type, null as any);
5984
5985 const nodes = ownerDocument.getElementsByTagName(type);
5986 for (let i = 0; i < nodes.length; i++) {
@@ -5997,14 +6010,14 @@ export function mountHoistable(
6010 instance: Instance,
6011 ): void {
6012 const ownerDocument = getDocumentFromRoot(hoistableRoot);
6000 - (ownerDocument.head: any).insertBefore(
6013 + (ownerDocument.head as any).insertBefore(
6014 instance,
6015 type === 'title' ? ownerDocument.querySelector('head > title') : null,
6016 );
6017 }
6018
6019 export function unmountHoistable(instance: Instance): void {
6007 - (instance.parentNode: any).removeChild(instance);
6020 + (instance.parentNode as any).removeChild(instance);
6021 }
6022
6023 export function isHostHoistableType(
@@ -6015,13 +6028,13 @@ export function isHostHoistableType(
6028 let outsideHostContainerContext: boolean;
6029 let hostContextProd: HostContextProd;
6030 if (__DEV__) {
6018 - const hostContextDev: HostContextDev = (hostContext: any);
6031 + const hostContextDev: HostContextDev = hostContext as any;
6032 // We can only render resources when we are not within the host container context
6033 outsideHostContainerContext =
6034 !hostContextDev.ancestorInfo.containerTagInScope;
6035 hostContextProd = hostContextDev.context;
6036 } else {
6024 - hostContextProd = (hostContext: any);
6037 + hostContextProd = hostContext as any;
6038 }
6039
6040 // Global opt out of hoisting for anything in SVG Namespace or anything with an itemProp inside an itemScope
@@ -6235,7 +6248,7 @@ export function preloadInstance(
6248 // If we return true here, we'll still get a suspendInstance call in the
6249 // pre-commit phase to determine if we still need to decode the image or
6250 // if was dropped from cache. This just avoids rendering Suspense fallback.
6238 - return !!(instance: any).complete;
6251 + return !!(instance as any).complete;
6252 }
6253
6254 export function preloadResource(resource: Resource): boolean {
@@ -6309,9 +6322,9 @@ export function suspendInstance(
6322 // Estimate the byte size that we're about to download based on the width/height
6323 // specified in the props. This is best practice to know ahead of time but if it's
6324 // unspecified we'll fallback to a guess of 100x100 pixels.
6312 - if (!(instance: any).complete) {
6313 - state.imgBytes += estimateImageBytes((instance: any));
6314 - state.suspenseyImages.push((instance: any));
6325 + if (!(instance as any).complete) {
6326 + state.imgBytes += estimateImageBytes(instance as any);
6327 + state.suspenseyImages.push(instance as any);
6328 }
6329 const ping = onUnsuspendImg.bind(state);
6330 // $FlowFixMe[prop-missing]
@@ -6348,7 +6361,7 @@ export function suspendResource(
6361 // as part of the preamble and therefore synchronously loaded. It could have
6362 // errored however which we still do not yet have a means to detect. For now
6363 // we assume it is loaded.
6351 - const maybeLoadingState: ?Promise<mixed> = (instance: any)._p;
6364 + const maybeLoadingState: ?Promise<mixed> = (instance as any)._p;
6365 if (
6366 maybeLoadingState !== null &&
6367 typeof maybeLoadingState === 'object' &&
@@ -6377,10 +6390,10 @@ export function suspendResource(
6390 // Construct and insert a new instance
6391 instance = ownerDocument.createElement('link');
6392 markNodeAsHoistable(instance);
6380 - const linkInstance: HTMLLinkElement = (instance: any);
6393 + const linkInstance: HTMLLinkElement = instance as any;
6394 // This Promise is a loading state used by the Fizz runtime. We need this incase there is a race
6395 // between this resource being rendered on the client and being rendered with a late completed boundary.
6383 - (linkInstance: any)._p = new Promise((resolve, reject) => {
6396 + (linkInstance as any)._p = new Promise((resolve, reject) => {
6397 linkInstance.onload = resolve;
6398 linkInstance.onerror = reject;
6399 });
@@ -6564,7 +6577,7 @@ const LAST_PRECEDENCE = null;
6577 let precedencesByRoot: Map<
6578 HoistableRoot,
6579 Map<string | typeof LAST_PRECEDENCE, Instance>,
6567 -> = (null: any);
6580 +> = null as any;
6581
6582 function insertSuspendedStylesheets(
6583 state: SuspendedState,
@@ -6584,7 +6597,7 @@ function insertSuspendedStylesheets(
6597
6598 precedencesByRoot = new Map();
6599 resources.forEach(insertStylesheetIntoRoot, state);
6587 - precedencesByRoot = (null: any);
6600 + precedencesByRoot = null as any;
6601
6602 // We can remove our temporary count and if we're still at zero we can unsuspend.
6603 // If we are in the synchronous phase before deciding if the commit should suspend and this
@@ -6635,9 +6648,9 @@ function insertStylesheetIntoRoot(
6648 }
6649
6650 // We only call this after we have constructed an instance so we assume it here
6638 - const instance: HTMLLinkElement = (resource.instance: any);
6651 + const instance: HTMLLinkElement = resource.instance as any;
6652 // We will always have a precedence for stylesheet instances
6640 - const precedence: string = (instance.getAttribute('data-precedence'): any);
6653 + const precedence: string = instance.getAttribute('data-precedence') as any;
6654
6655 const prior = precedences.get(precedence) || last;
6656 if (prior === last) {
@@ -6651,12 +6664,12 @@ function insertStylesheetIntoRoot(
6664 instance.addEventListener('error', onComplete);
6665
6666 if (prior) {
6654 - (prior.parentNode: any).insertBefore(instance, prior.nextSibling);
6667 + (prior.parentNode as any).insertBefore(instance, prior.nextSibling);
6668 } else {
6669 const parent =
6670 root.nodeType === DOCUMENT_NODE
6658 - ? ((((root: any): Document).head: any): Element)
6659 - : ((root: any): ShadowRoot);
6671 + ? ((root as any as Document).head as any as Element)
6672 + : (root as any as ShadowRoot);
6673 parent.insertBefore(instance, parent.firstChild);
6674 }
6675 resource.state.loading |= Inserted;
@@ -6665,8 +6678,8 @@ function insertStylesheetIntoRoot(
6678 export const NotPendingTransition: TransitionStatus = NotPending;
6679 export const HostTransitionContext: ReactContext<TransitionStatus> = {
6680 $$typeof: REACT_CONTEXT_TYPE,
6668 - Provider: (null: any),
6669 - Consumer: (null: any),
6681 + Provider: null as any,
6682 + Consumer: null as any,
6683 _currentValue: NotPendingTransition,
6684 _currentValue2: NotPendingTransition,
6685 _threadCount: 0,
packages/react-dom-bindings/src/client/ToStringValue.js
+1 -1
@@ -24,7 +24,7 @@ export opaque type ToStringValue =
24 export function toString(value: ToStringValue): string {
25 // The coercion safety check is performed in getToStringValue().
26 // eslint-disable-next-line react-internal/safe-string-coercion
27 - return '' + (value: any);
27 + return '' + (value as any);
28 }
29
30 export function getToStringValue(value: mixed): ToStringValue {
packages/react-dom-bindings/src/client/inputValueTracking.js
+4 -5
@@ -125,7 +125,7 @@ export function track(node: ElementWithValueTracker) {
125 // This is read from the DOM so always safe to coerce. We really shouldn't
126 // be coercing to a string at all. It's just historical.
127 // eslint-disable-next-line react-internal/safe-string-coercion
128 - const initialValue = '' + (node[valueField]: any);
128 + const initialValue = '' + (node[valueField] as any);
129 node._valueTracker = trackValueOnNode(node, valueField, initialValue);
130 }
131
@@ -145,16 +145,15 @@ export function trackHydrated(
145 if (isCheckable(node)) {
146 valueField = 'checked';
147 // eslint-disable-next-line react-internal/safe-string-coercion
148 - expectedValue = '' + (initialChecked: any);
148 + expectedValue = '' + (initialChecked as any);
149 } else {
150 valueField = 'value';
151 expectedValue = initialValue;
152 }
153 const currentValue =
154 // eslint-disable-next-line react-internal/safe-string-coercion
155 - '' +
156 - (// $FlowFixMe[prop-missing]
157 - node[valueField]: any);
155 + '' + // $FlowFixMe[prop-missing]
156 + (node[valueField] as any);
157 node._valueTracker = trackValueOnNode(node, valueField, expectedValue);
158 return currentValue !== expectedValue;
159 }
packages/react-dom-bindings/src/client/validateDOMNesting.js
+1 -1
@@ -292,7 +292,7 @@ function updatedAncestorInfoDev(
292
293 return ancestorInfo;
294 } else {
295 - return (null: any);
295 + return null as any;
296 }
297 }
298
packages/react-dom-bindings/src/events/DOMEventProperties.js
+2 -2
@@ -129,8 +129,8 @@ function registerSimpleEvent(domEventName: DOMEventName, reactName: string) {
129
130 export function registerSimpleEvents() {
131 for (let i = 0; i < simpleEventPluginEvents.length; i++) {
132 - const eventName = ((simpleEventPluginEvents[i]: any): string);
133 - const domEventName = ((eventName.toLowerCase(): any): DOMEventName);
132 + const eventName = simpleEventPluginEvents[i] as any as string;
133 + const domEventName = eventName.toLowerCase() as any as DOMEventName;
134 const capitalizedEvent = eventName[0].toUpperCase() + eventName.slice(1);
135 registerSimpleEvent(domEventName, 'on' + capitalizedEvent);
136 }
packages/react-dom-bindings/src/events/DOMPluginEventSystem.js
+10 -10
@@ -430,8 +430,8 @@ export function listenToNativeEventForNonManagedEventTarget(
430 const listeningMarker = '_reactListening' + Math.random().toString(36).slice(2);
431
432 export function listenToAllSupportedEvents(rootContainerElement: EventTarget) {
433 - if (!(rootContainerElement: any)[listeningMarker]) {
434 - (rootContainerElement: any)[listeningMarker] = true;
433 + if (!(rootContainerElement as any)[listeningMarker]) {
434 + (rootContainerElement as any)[listeningMarker] = true;
435 allNativeEvents.forEach(domEventName => {
436 // We handle selectionchange separately because it
437 // doesn't bubble and needs to be on the document.
@@ -443,15 +443,15 @@ export function listenToAllSupportedEvents(rootContainerElement: EventTarget) {
443 }
444 });
445 const ownerDocument =
446 - (rootContainerElement: any).nodeType === DOCUMENT_NODE
446 + (rootContainerElement as any).nodeType === DOCUMENT_NODE
447 ? rootContainerElement
448 - : (rootContainerElement: any).ownerDocument;
448 + : (rootContainerElement as any).ownerDocument;
449 // $FlowFixMe[invalid-compare]
450 if (ownerDocument !== null) {
451 // The selectionchange event also needs deduplication
452 // but it is attached to the document.
453 - if (!(ownerDocument: any)[listeningMarker]) {
454 - (ownerDocument: any)[listeningMarker] = true;
453 + if (!(ownerDocument as any)[listeningMarker]) {
454 + (ownerDocument as any)[listeningMarker] = true;
455 listenToNativeEvent('selectionchange', false, ownerDocument);
456 }
457 }
@@ -491,7 +491,7 @@ function addTrappedEventListener(
491
492 targetContainer =
493 enableLegacyFBSupport && isDeferredListenerForLegacyFBSupport
494 - ? (targetContainer: any).ownerDocument
494 + ? (targetContainer as any).ownerDocument
495 : targetContainer;
496
497 let unsubscribeListener;
@@ -594,7 +594,7 @@ export function dispatchEventForPluginEventSystem(
594 (eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 &&
595 (eventSystemFlags & IS_NON_DELEGATED) === 0
596 ) {
597 - const targetContainerNode = ((targetContainer: any): Node);
597 + const targetContainerNode = targetContainer as any as Node;
598
599 // If we are using the legacy FB support flag, we
600 // defer the event to the null with a one
@@ -751,7 +751,7 @@ export function accumulateSinglePhaseListeners(
751 createDispatchListener(
752 instance,
753 entry.callback,
754 - (lastHostComponent: any),
754 + lastHostComponent as any,
755 ),
756 );
757 }
@@ -789,7 +789,7 @@ export function accumulateSinglePhaseListeners(
789 createDispatchListener(
790 instance,
791 entry.callback,
792 - (lastHostComponent: any),
792 + lastHostComponent as any,
793 ),
794 );
795 }
packages/react-dom-bindings/src/events/EventRegistry.js
+1 -1
@@ -33,7 +33,7 @@ export const registrationNameDependencies: {
33 */
34 export const possibleRegistrationNames: {
35 [lowerCasedName: string]: string,
36 -} = __DEV__ ? {} : (null: any);
36 +} = __DEV__ ? {} : (null as any);
37 // Trust the developer to only use possibleRegistrationNames in __DEV__
38
39 export function registerTwoPhaseEvent(
packages/react-dom-bindings/src/events/ReactDOMEventReplaying.js
+12 -12
@@ -168,13 +168,13 @@ export function clearIfContinuousEvent(
168 break;
169 case 'pointerover':
170 case 'pointerout': {
171 - const pointerId = ((nativeEvent: any): PointerEventType).pointerId;
171 + const pointerId = (nativeEvent as any as PointerEventType).pointerId;
172 queuedPointers.delete(pointerId);
173 break;
174 }
175 case 'gotpointercapture':
176 case 'lostpointercapture': {
177 - const pointerId = ((nativeEvent: any): PointerEventType).pointerId;
177 + const pointerId = (nativeEvent as any as PointerEventType).pointerId;
178 queuedPointerCaptures.delete(pointerId);
179 break;
180 }
@@ -237,7 +237,7 @@ export function queueIfContinuousEvent(
237 // Instead of mutating we could clone the event.
238 switch (domEventName) {
239 case 'focusin': {
240 - const focusEvent = ((nativeEvent: any): FocusEvent);
240 + const focusEvent = nativeEvent as any as FocusEvent;
241 queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(
242 queuedFocus,
243 blockedOn,
@@ -249,7 +249,7 @@ export function queueIfContinuousEvent(
249 return true;
250 }
251 case 'dragenter': {
252 - const dragEvent = ((nativeEvent: any): DragEvent);
252 + const dragEvent = nativeEvent as any as DragEvent;
253 queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(
254 queuedDrag,
255 blockedOn,
@@ -261,7 +261,7 @@ export function queueIfContinuousEvent(
261 return true;
262 }
263 case 'mouseover': {
264 - const mouseEvent = ((nativeEvent: any): MouseEvent);
264 + const mouseEvent = nativeEvent as any as MouseEvent;
265 queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(
266 queuedMouse,
267 blockedOn,
@@ -273,7 +273,7 @@ export function queueIfContinuousEvent(
273 return true;
274 }
275 case 'pointerover': {
276 - const pointerEvent = ((nativeEvent: any): PointerEventType);
276 + const pointerEvent = nativeEvent as any as PointerEventType;
277 const pointerId = pointerEvent.pointerId;
278 queuedPointers.set(
279 pointerId,
@@ -289,7 +289,7 @@ export function queueIfContinuousEvent(
289 return true;
290 }
291 case 'gotpointercapture': {
292 - const pointerEvent = ((nativeEvent: any): PointerEventType);
292 + const pointerEvent = nativeEvent as any as PointerEventType;
293 const pointerId = pointerEvent.pointerId;
294 queuedPointerCaptures.set(
295 pointerId,
@@ -396,7 +396,7 @@ function attemptReplayContinuousQueuedEvent(
396 const nativeEvent = queuedEvent.nativeEvent;
397 const nativeEventClone = new nativeEvent.constructor(
398 nativeEvent.type,
399 - (nativeEvent: any),
399 + nativeEvent as any,
400 );
401 setReplayingEvent(nativeEventClone);
402 nativeEvent.target.dispatchEvent(nativeEventClone);
@@ -429,7 +429,7 @@ function attemptReplayContinuousQueuedEventInMap(
429 function replayChangeEvent(target: EventTarget): void {
430 // Dispatch a fake "change" event for the input.
431 const element: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement =
432 - (target: any);
432 + target as any;
433 if (element.nodeName === 'INPUT') {
434 if (element.type === 'checkbox' || element.type === 'radio') {
435 // Checkboxes always fire a click event regardless of how the change was made.
@@ -610,7 +610,7 @@ export function retryIfBlockedOn(
610 // Check the document if there are any queued form actions.
611 // If there's no ownerDocument, then this is the document.
612 const root = unblocked.ownerDocument || unblocked;
613 - const formReplayingQueue: void | FormReplayingQueue = (root: any)
613 + const formReplayingQueue: void | FormReplayingQueue = (root as any)
614 .$$reactFormReplay;
615 if (formReplayingQueue != null) {
616 for (let i = 0; i < formReplayingQueue.length; i += 3) {
@@ -643,7 +643,7 @@ export function retryIfBlockedOn(
643 const submitterProps = getFiberCurrentPropsFromNode(submitter);
644 if (submitterProps) {
645 // The submitter is part of this instance.
646 - action = (submitterProps: any).formAction;
646 + action = (submitterProps as any).formAction;
647 } else {
648 const blockedOn = findInstanceBlockingTarget(target);
649 if (blockedOn !== null) {
@@ -654,7 +654,7 @@ export function retryIfBlockedOn(
654 // Except the form isn't. We don't dispatch actions in this scenario.
655 }
656 } else {
657 - action = (formProps: any).action;
657 + action = (formProps as any).action;
658 }
659 if (typeof action === 'function') {
660 formReplayingQueue[i + 1] = action;
packages/react-dom-bindings/src/events/forks/EventListener-www.js
+1 -1
@@ -66,4 +66,4 @@ export function removeEventListener(
66 }
67
68 // Flow magic to verify the exports of this file match the original version.
69 -((((null: any): EventListenerType): EventListenerShimType): EventListenerType);
69 +null as any as EventListenerType as EventListenerShimType as EventListenerType;
packages/react-dom-bindings/src/events/isEventSupported.js
+1 -1
@@ -33,7 +33,7 @@ function isEventSupported(eventNameSuffix: string): boolean {
33 if (!isSupported) {
34 const element = document.createElement('div');
35 element.setAttribute(eventName, 'return;');
36 - isSupported = typeof (element: any)[eventName] === 'function';
36 + isSupported = typeof (element as any)[eventName] === 'function';
37 }
38
39 return isSupported;
packages/react-dom-bindings/src/events/isTextInputElement.js
+1 -1
@@ -32,7 +32,7 @@ function isTextInputElement(elem: ?HTMLElement): boolean {
32 const nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
33
34 if (nodeName === 'input') {
35 - return !!supportedInputTypes[((elem: any): HTMLInputElement).type];
35 + return !!supportedInputTypes[(elem as any as HTMLInputElement).type];
36 }
37
38 if (nodeName === 'textarea') {
packages/react-dom-bindings/src/events/plugins/ChangeEventPlugin.js
+8 -8
@@ -54,7 +54,7 @@ function createAndAccumulateChangeEvent(
54 target: null | EventTarget,
55 ) {
56 // Flag this event loop as needing state restore.
57 - enqueueStateRestore(((target: any): Node));
57 + enqueueStateRestore(target as any as Node);
58 const listeners = accumulateTwoPhaseListeners(inst, 'onChange');
59 if (listeners.length > 0) {
60 const event: ReactSyntheticEvent = new SyntheticEvent(
@@ -80,7 +80,7 @@ function shouldUseChangeEvent(elem: Instance | TextInstance) {
80 const nodeName = elem.nodeName && elem.nodeName.toLowerCase();
81 return (
82 nodeName === 'select' ||
83 - (nodeName === 'input' && (elem: any).type === 'file')
83 + (nodeName === 'input' && (elem as any).type === 'file')
84 );
85 }
86
@@ -113,7 +113,7 @@ function runEventInBatch(dispatchQueue: DispatchQueue) {
113
114 function getInstIfValueChanged(targetInst: Object) {
115 const targetNode = getNodeFromInstance(targetInst);
116 - if (updateValueIfChanged(((targetNode: any): HTMLInputElement))) {
116 + if (updateValueIfChanged(targetNode as any as HTMLInputElement)) {
117 return targetInst;
118 }
119 }
@@ -150,7 +150,7 @@ function startWatchingForValueChange(
150 ) {
151 activeElement = target;
152 activeElementInst = targetInst;
153 - (activeElement: any).attachEvent('onpropertychange', handlePropertyChange);
153 + (activeElement as any).attachEvent('onpropertychange', handlePropertyChange);
154 }
155
156 /**
@@ -161,7 +161,7 @@ function stopWatchingForValueChange() {
161 if (!activeElement) {
162 return;
163 }
164 - (activeElement: any).detachEvent('onpropertychange', handlePropertyChange);
164 + (activeElement as any).detachEvent('onpropertychange', handlePropertyChange);
165 activeElement = null;
166 activeElementInst = null;
167 }
@@ -269,7 +269,7 @@ function handleControlledInputBlur(node: HTMLInputElement, props: any) {
269 const isControlled = props.value != null;
270 if (isControlled) {
271 // If controlled, assign the value attribute to the current value on blur
272 - setDefaultValue((node: any), 'number', (node: any).value);
272 + setDefaultValue(node as any, 'number', (node as any).value);
273 }
274 }
275 }
@@ -298,7 +298,7 @@ function extractEvents(
298 let getTargetInstFunc, handleEventFunc;
299 if (shouldUseChangeEvent(targetNode)) {
300 getTargetInstFunc = getTargetInstForChangeEvent;
301 - } else if (isTextInputElement(((targetNode: any): HTMLElement))) {
301 + } else if (isTextInputElement(targetNode as any as HTMLElement)) {
302 if (isInputEventSupported) {
303 getTargetInstFunc = getTargetInstForInputOrChangeEvent;
304 } else {
@@ -337,7 +337,7 @@ function extractEvents(
337 // between controlled and uncontrolled, so it doesn't matter and the previous
338 // code was also broken for changes.
339 const props = targetInst.memoizedProps;
340 - handleControlledInputBlur(((targetNode: any): HTMLInputElement), props);
340 + handleControlledInputBlur(targetNode as any as HTMLInputElement, props);
341 }
342 }
343
packages/react-dom-bindings/src/events/plugins/EnterLeaveEventPlugin.js
+6 -6
@@ -65,7 +65,7 @@ function extractEvents(
65 // then it's because we couldn't dispatch against this target previously
66 // so we have to do it now instead.
67 const related =
68 - (nativeEvent: any).relatedTarget || (nativeEvent: any).fromElement;
68 + (nativeEvent as any).relatedTarget || (nativeEvent as any).fromElement;
69 if (related) {
70 // If the related node is managed by React, we can assume that we have
71 // already dispatched the corresponding events during its mouseout.
@@ -85,12 +85,12 @@ function extractEvents(
85
86 let win;
87 // TODO: why is this nullable in the types but we read from it?
88 - if ((nativeEventTarget: any).window === nativeEventTarget) {
88 + if ((nativeEventTarget as any).window === nativeEventTarget) {
89 // `nativeEventTarget` is probably a window object.
90 win = nativeEventTarget;
91 } else {
92 // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
93 - const doc = (nativeEventTarget: any).ownerDocument;
93 + const doc = (nativeEventTarget as any).ownerDocument;
94 if (doc) {
95 win = doc.defaultView || doc.parentWindow;
96 } else {
@@ -101,9 +101,9 @@ function extractEvents(
101 let from;
102 let to;
103 if (isOutEvent) {
104 - const related = nativeEvent.relatedTarget || (nativeEvent: any).toElement;
104 + const related = nativeEvent.relatedTarget || (nativeEvent as any).toElement;
105 from = targetInst;
106 - to = related ? getClosestInstanceFromNode((related: any)) : null;
106 + to = related ? getClosestInstanceFromNode(related as any) : null;
107 if (to !== null) {
108 const nearestMounted = getNearestMountedFiber(to);
109 const tag = to.tag;
@@ -153,7 +153,7 @@ function extractEvents(
153
154 // We should only process this nativeEvent if we are processing
155 // the first ancestor. Next time, we will ignore the event.
156 - const nativeTargetInst = getClosestInstanceFromNode((nativeEventTarget: any));
156 + const nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget as any);
157 if (nativeTargetInst === targetInst) {
158 const enterEvent: KnownReactSyntheticEvent = new SyntheticEventCtor(
159 enterEventType,
packages/react-dom-bindings/src/events/plugins/FormActionEventPlugin.js
+11 -10
@@ -34,14 +34,14 @@ function coerceFormActionProp(
34 ) {
35 return null;
36 } else if (typeof actionProp === 'function') {
37 - return (actionProp: any);
37 + return actionProp as any;
38 } else {
39 if (__DEV__) {
40 checkAttributeStringCoercion(actionProp, 'action');
41 }
42 - return (sanitizeURL(
43 - enableTrustedTypesIntegration ? actionProp : '' + (actionProp: any),
44 - ): any);
42 + return sanitizeURL(
43 + enableTrustedTypesIntegration ? actionProp : '' + (actionProp as any),
44 + ) as any;
45 }
46 }
47
@@ -67,19 +67,20 @@ function extractEvents(
67 return;
68 }
69 const formInst = maybeTargetInst;
70 - const form: HTMLFormElement = (nativeEventTarget: any);
70 + const form: HTMLFormElement = nativeEventTarget as any;
71 let action = coerceFormActionProp(
72 - (getFiberCurrentPropsFromNode(form): any).action,
72 + (getFiberCurrentPropsFromNode(form) as any).action,
73 );
74 - let submitter: null | void | HTMLInputElement | HTMLButtonElement =
75 - (nativeEvent: any).submitter;
74 + let submitter: null | void | HTMLInputElement | HTMLButtonElement = (
75 + nativeEvent as any
76 + ).submitter;
77 let submitterAction;
78 if (submitter) {
79 const submitterProps = getFiberCurrentPropsFromNode(submitter);
80 submitterAction = submitterProps
80 - ? coerceFormActionProp((submitterProps: any).formAction)
81 + ? coerceFormActionProp((submitterProps as any).formAction)
82 : // The built-in Flow type is ?string, wider than the spec
82 - ((submitter.getAttribute('formAction'): any): string | null);
83 + (submitter.getAttribute('formAction') as any as string | null);
84 if (submitterAction !== null) {
85 // The submitter overrides the form action.
86 action = submitterAction;
packages/react-dom-bindings/src/events/plugins/SelectEventPlugin.js
+1 -1
@@ -162,7 +162,7 @@ function extractEvents(
162 // Track the input node that has focus.
163 case 'focusin':
164 if (
165 - isTextInputElement((targetNode: any)) ||
165 + isTextInputElement(targetNode as any) ||
166 targetNode.contentEditable === 'true'
167 ) {
168 activeElement = targetNode;
packages/react-dom-bindings/src/events/plugins/SimpleEventPlugin.js
+2 -2
@@ -76,7 +76,7 @@ function extractEvents(
76 // non-printable. One would expect Tab to be as well (but it isn't).
77 // TODO: Fixed in https://bugzilla.mozilla.org/show_bug.cgi?id=968056. Can
78 // probably remove.
79 - if (getEventCharCode(((nativeEvent: any): KeyboardEvent)) === 0) {
79 + if (getEventCharCode(nativeEvent as any as KeyboardEvent) === 0) {
80 return;
81 }
82 /* falls through */
@@ -184,7 +184,7 @@ function extractEvents(
184 const listeners = accumulateEventHandleNonManagedNodeListeners(
185 // TODO: this cast may not make sense for events like
186 // "focus" where React listens to e.g. "focusin".
187 - ((reactEventType: any): DOMEventName),
187 + reactEventType as any as DOMEventName,
188 targetContainer,
189 inCapturePhase,
190 );
packages/react-dom-bindings/src/server/ReactDOMFlightServerHostDispatcher.js
+2 -2
@@ -243,12 +243,12 @@ function trimOptions<
243 >(options: ?T): ?T {
244 if (options == null) return null;
245 let hasProperties = false;
246 - const trimmed: T = ({}: any);
246 + const trimmed: T = {} as any;
247 for (const key in options) {
248 // $FlowFixMe[invalid-computed-prop]
249 if (options[key] != null) {
250 hasProperties = true;
251 - (trimmed: any)[key] = options[key];
251 + (trimmed as any)[key] = options[key];
252 }
253 }
254 return hasProperties ? trimmed : null;
packages/react-dom-bindings/src/server/ReactDOMServerExternalRuntime.js
+4 -4
@@ -14,7 +14,7 @@ if (document.body != null) {
14 installFizzInstrObserver(document.body);
15 }
16 // $FlowFixMe[incompatible-type]
17 - handleExistingNodes((document.body: HTMLElement));
17 + handleExistingNodes(document.body as HTMLElement);
18 } else {
19 // Document must be loading -- body may not exist yet if the fizz external
20 // runtime is sent in <head> (e.g. as a preinit resource)
@@ -26,7 +26,7 @@ if (document.body != null) {
26 installFizzInstrObserver(document.body);
27 }
28 // $FlowFixMe[incompatible-type]
29 - handleExistingNodes((document.body: HTMLElement));
29 + handleExistingNodes(document.body as HTMLElement);
30
31 // We can call disconnect without takeRecord here,
32 // since we only expect a single document.body
@@ -70,11 +70,11 @@ function installFizzInstrObserver(target: Node) {
70
71 function handleNode(node_: Node) {
72 // $FlowFixMe[incompatible-type]
73 - if (node_.nodeType !== 1 || !(node_: HTMLElement).dataset) {
73 + if (node_.nodeType !== 1 || !(node_ as HTMLElement).dataset) {
74 return;
75 }
76 // $FlowFixMe[incompatible-type]
77 - const node = (node_: HTMLElement);
77 + const node = node_ as HTMLElement;
78 const dataset = node.dataset;
79 if (dataset['rxi'] != null) {
80 window['$RX'](
packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
+79 -81
@@ -547,12 +547,12 @@ export function createRenderState(
547 for (let i = 0; i < bootstrapScripts.length; i++) {
548 const scriptConfig = bootstrapScripts[i];
549 let src, crossOrigin, integrity;
550 - const props: PreloadAsProps = ({
550 + const props: PreloadAsProps = {
551 rel: 'preload',
552 as: 'script',
553 fetchPriority: 'low',
554 nonce,
555 - }: any);
555 + } as any;
556 if (typeof scriptConfig === 'string') {
557 props.href = src = scriptConfig;
558 } else {
@@ -605,11 +605,11 @@ export function createRenderState(
605 for (let i = 0; i < bootstrapModules.length; i++) {
606 const scriptConfig = bootstrapModules[i];
607 let src, crossOrigin, integrity;
608 - const props: PreloadModuleProps = ({
608 + const props: PreloadModuleProps = {
609 rel: 'modulepreload',
610 fetchPriority: 'low',
611 nonce: nonceScript,
612 - }: any);
612 + } as any;
613 if (typeof scriptConfig === 'string') {
614 props.href = src = scriptConfig;
615 } else {
@@ -1502,15 +1502,15 @@ function pushSrcObjectAttribute(
1502 const suspenseCache: WeakMap<Blob, Thenable<string>> = blobCache;
1503 let thenable = suspenseCache.get(blob);
1504 if (thenable === undefined) {
1505 - thenable = ((readAsDataURL(blob): any): Thenable<string>);
1505 + thenable = readAsDataURL(blob) as any as Thenable<string>;
1506 thenable.then(
1507 result => {
1508 - (thenable: any).status = 'fulfilled';
1509 - (thenable: any).value = result;
1508 + (thenable as any).status = 'fulfilled';
1509 + (thenable as any).value = result;
1510 },
1511 error => {
1512 - (thenable: any).status = 'rejected';
1513 - (thenable: any).reason = error;
1512 + (thenable as any).status = 'rejected';
1513 + (thenable as any).reason = error;
1514 },
1515 );
1516 suspenseCache.set(blob, thenable);
@@ -1756,7 +1756,7 @@ function pushAttribute(
1756 typeof value !== 'function' &&
1757 typeof value !== 'symbol' &&
1758 !isNaN(value) &&
1759 - (value: any) >= 1
1759 + (value as any) >= 1
1760 ) {
1761 target.push(
1762 attributeSeparator,
@@ -2105,11 +2105,11 @@ function flattenOptionChildren(children: mixed): string {
2105 let content = '';
2106 // Flatten children and warn if they aren't strings or numbers;
2107 // invalid types are ignored.
2108 - Children.forEach((children: any), function (child) {
2108 + Children.forEach(children as any, function (child) {
2109 if (child == null) {
2110 return;
2111 }
2112 - content += (child: any);
2112 + content += child as any;
2113 if (__DEV__) {
2114 if (
2115 !didWarnInvalidOptionChildren &&
@@ -2935,9 +2935,9 @@ function pushLink(
2935 if (!styleQueue) {
2936 styleQueue = {
2937 precedence: stringToChunk(escapeTextForBrowser(precedence)),
2938 - rules: ([]: Array<Chunk | PrecomputedChunk>),
2939 - hrefs: ([]: Array<Chunk | PrecomputedChunk>),
2940 - sheets: (new Map(): Map<string, StylesheetResource>),
2938 + rules: [] as Array<Chunk | PrecomputedChunk>,
2939 + hrefs: [] as Array<Chunk | PrecomputedChunk>,
2940 + sheets: new Map() as Map<string, StylesheetResource>,
2941 };
2942 renderState.styles.set(precedence, styleQueue);
2943 }
@@ -3143,9 +3143,9 @@ function pushStyle(
3143 // to create a StyleQueue.
3144 styleQueue = {
3145 precedence: stringToChunk(escapeTextForBrowser(precedence)),
3146 - rules: ([]: Array<Chunk | PrecomputedChunk>),
3147 - hrefs: ([]: Array<Chunk | PrecomputedChunk>),
3148 - sheets: (new Map(): Map<string, StylesheetResource>),
3146 + rules: [] as Array<Chunk | PrecomputedChunk>,
3147 + hrefs: [] as Array<Chunk | PrecomputedChunk>,
3148 + sheets: new Map() as Map<string, StylesheetResource>,
3149 };
3150 renderState.styles.set(precedence, styleQueue);
3151 }
@@ -3426,25 +3426,22 @@ function pushImg(
3426 headers.highImagePreloads += header;
3427 } else {
3428 resource = [];
3429 - pushLinkImpl(
3430 - resource,
3431 - ({
3432 - rel: 'preload',
3433 - as: 'image',
3434 - // There is a bug in Safari where imageSrcSet is not respected on preload links
3435 - // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image.
3436 - // This harms older browers that do not support imageSrcSet by making their preloads not work
3437 - // but this population is shrinking fast and is already small so we accept this tradeoff.
3438 - href: srcSet ? undefined : src,
3439 - imageSrcSet: srcSet,
3440 - imageSizes: sizes,
3441 - crossOrigin: crossOrigin,
3442 - integrity: props.integrity,
3443 - type: props.type,
3444 - fetchPriority: props.fetchPriority,
3445 - referrerPolicy: props.referrerPolicy,
3446 - }: PreloadProps),
3447 - );
3429 + pushLinkImpl(resource, {
3430 + rel: 'preload',
3431 + as: 'image',
3432 + // There is a bug in Safari where imageSrcSet is not respected on preload links
3433 + // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image.
3434 + // This harms older browers that do not support imageSrcSet by making their preloads not work
3435 + // but this population is shrinking fast and is already small so we accept this tradeoff.
3436 + href: srcSet ? undefined : src,
3437 + imageSrcSet: srcSet,
3438 + imageSizes: sizes,
3439 + crossOrigin: crossOrigin,
3440 + integrity: props.integrity,
3441 + type: props.type,
3442 + fetchPriority: props.fetchPriority,
3443 + referrerPolicy: props.referrerPolicy,
3444 + } as PreloadProps);
3445 if (
3446 props.fetchPriority === 'high' ||
3447 renderState.highImagePreloads.size < 10
@@ -5276,7 +5273,7 @@ function flushStyleTagsLateForBoundary(
5273 if (hrefs.length) {
5274 writeChunk(
5275 this,
5279 - ((currentlyFlushingRenderState: any): RenderState).startInlineStyle,
5276 + (currentlyFlushingRenderState as any as RenderState).startInlineStyle,
5277 );
5278 writeChunk(this, lateStyleTagResourceOpen1);
5279 writeChunk(this, styleQueue.precedence);
@@ -5396,7 +5393,7 @@ function flushStylesInPreamble(
5393 if (!hasStylesheets || hrefs.length) {
5394 writeChunk(
5395 this,
5399 - ((currentlyFlushingRenderState: any): RenderState).startInlineStyle,
5396 + (currentlyFlushingRenderState as any as RenderState).startInlineStyle,
5397 );
5398 writeChunk(this, styleTagResourceOpen1);
5399 writeChunk(this, styleQueue.precedence);
@@ -5764,7 +5761,7 @@ function writeStyleResourceDependencyHrefOnlyInJS(
5761 if (__DEV__) {
5762 checkAttributeStringCoercion(href, 'href');
5763 }
5767 - const coercedHref = '' + (href: any);
5764 + const coercedHref = '' + (href as any);
5765 writeChunk(
5766 destination,
5767 stringToChunk(escapeJSObjectForInstructionScripts(coercedHref)),
@@ -5778,7 +5775,7 @@ function writeStyleResourceDependencyInJS(
5775 props: Object,
5776 ) {
5777 // eslint-disable-next-line react-internal/safe-string-coercion
5781 - const coercedHref = sanitizeURL('' + (href: any));
5778 + const coercedHref = sanitizeURL('' + (href as any));
5779 writeChunk(
5780 destination,
5781 stringToChunk(escapeJSObjectForInstructionScripts(coercedHref)),
@@ -5787,7 +5784,7 @@ function writeStyleResourceDependencyInJS(
5784 if (__DEV__) {
5785 checkAttributeStringCoercion(precedence, 'precedence');
5786 }
5790 - const coercedPrecedence = '' + (precedence: any);
5787 + const coercedPrecedence = '' + (precedence as any);
5788 writeChunk(destination, arrayInterstitial);
5789 writeChunk(
5790 destination,
@@ -5852,7 +5849,7 @@ function writeStyleResourceAttributeInJS(
5849 if (__DEV__) {
5850 checkAttributeStringCoercion(value, attributeName);
5851 }
5855 - attributeValue = '' + (value: any);
5852 + attributeValue = '' + (value as any);
5853 break;
5854 }
5855 // Booleans
@@ -5870,7 +5867,7 @@ function writeStyleResourceAttributeInJS(
5867 if (__DEV__) {
5868 checkAttributeStringCoercion(value, attributeName);
5869 }
5873 - attributeValue = '' + (value: any);
5870 + attributeValue = '' + (value as any);
5871 break;
5872 }
5873 default: {
@@ -5889,7 +5886,7 @@ function writeStyleResourceAttributeInJS(
5886 if (__DEV__) {
5887 checkAttributeStringCoercion(value, attributeName);
5888 }
5892 - attributeValue = '' + (value: any);
5889 + attributeValue = '' + (value as any);
5890 }
5891 }
5892 writeChunk(destination, arrayInterstitial);
@@ -5958,7 +5955,7 @@ function writeStyleResourceDependencyHrefOnlyInAttr(
5955 if (__DEV__) {
5956 checkAttributeStringCoercion(href, 'href');
5957 }
5961 - const coercedHref = '' + (href: any);
5958 + const coercedHref = '' + (href as any);
5959 writeChunk(
5960 destination,
5961 stringToChunk(escapeTextForBrowser(JSON.stringify(coercedHref))),
@@ -5972,7 +5969,7 @@ function writeStyleResourceDependencyInAttr(
5969 props: Object,
5970 ) {
5971 // eslint-disable-next-line react-internal/safe-string-coercion
5975 - const coercedHref = sanitizeURL('' + (href: any));
5972 + const coercedHref = sanitizeURL('' + (href as any));
5973 writeChunk(
5974 destination,
5975 stringToChunk(escapeTextForBrowser(JSON.stringify(coercedHref))),
@@ -5981,7 +5978,7 @@ function writeStyleResourceDependencyInAttr(
5978 if (__DEV__) {
5979 checkAttributeStringCoercion(precedence, 'precedence');
5980 }
5984 - const coercedPrecedence = '' + (precedence: any);
5981 + const coercedPrecedence = '' + (precedence as any);
5982 writeChunk(destination, arrayInterstitial);
5983 writeChunk(
5984 destination,
@@ -6046,7 +6043,7 @@ function writeStyleResourceAttributeInAttr(
6043 if (__DEV__) {
6044 checkAttributeStringCoercion(value, attributeName);
6045 }
6049 - attributeValue = '' + (value: any);
6046 + attributeValue = '' + (value as any);
6047 break;
6048 }
6049
@@ -6066,7 +6063,7 @@ function writeStyleResourceAttributeInAttr(
6063 if (__DEV__) {
6064 checkAttributeStringCoercion(value, attributeName);
6065 }
6069 - attributeValue = '' + (value: any);
6066 + attributeValue = '' + (value as any);
6067 break;
6068 }
6069 default: {
@@ -6085,7 +6082,7 @@ function writeStyleResourceAttributeInAttr(
6082 if (__DEV__) {
6083 checkAttributeStringCoercion(value, attributeName);
6084 }
6088 - attributeValue = '' + (value: any);
6085 + attributeValue = '' + (value as any);
6086 }
6087 }
6088 writeChunk(destination, arrayInterstitial);
@@ -6244,7 +6241,7 @@ function prefetchDNS(href: string) {
6241 } else {
6242 // Encode as element
6243 const resource: Resource = [];
6247 - pushLinkImpl(resource, ({href, rel: 'dns-prefetch'}: PreconnectProps));
6244 + pushLinkImpl(resource, {href, rel: 'dns-prefetch'} as PreconnectProps);
6245 renderState.preconnects.add(resource);
6246 }
6247 }
@@ -6302,10 +6299,11 @@ function preconnect(href: string, crossOrigin: ?CrossOriginEnum) {
6299 headers.preconnects += header;
6300 } else {
6301 const resource: Resource = [];
6305 - pushLinkImpl(
6306 - resource,
6307 - ({rel: 'preconnect', href, crossOrigin}: PreconnectProps),
6308 - );
6302 + pushLinkImpl(resource, {
6303 + rel: 'preconnect',
6304 + href,
6305 + crossOrigin,
6306 + } as PreconnectProps);
6307 renderState.preconnects.add(resource);
6308 }
6309 }
@@ -6376,11 +6374,11 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
6374 // When we have imageSrcSet the browser probably cannot load the right version from headers
6375 // (this should be verified by testing). For now we assume these need to go in the head
6376 // as elements even if headers are available.
6379 - const resource = ([]: Resource);
6377 + const resource = [] as Resource;
6378 pushLinkImpl(
6379 resource,
6380 Object.assign(
6383 - ({
6381 + {
6382 rel: 'preload',
6383 // There is a bug in Safari where imageSrcSet is not respected on preload links
6384 // so we omit the href here if we have imageSrcSet b/c safari will load the wrong image.
@@ -6388,7 +6386,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
6386 // but this population is shrinking fast and is already small so we accept this tradeoff.
6387 href: imageSrcSet ? undefined : href,
6388 as,
6391 - }: PreloadAsProps),
6389 + } as PreloadAsProps,
6390 options,
6391 ),
6392 );
@@ -6409,10 +6407,10 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
6407 // we can return if we already have this resource
6408 return;
6409 }
6412 - const resource = ([]: Resource);
6410 + const resource = [] as Resource;
6411 pushLinkImpl(
6412 resource,
6415 - Object.assign(({rel: 'preload', href, as}: PreloadAsProps), options),
6413 + Object.assign({rel: 'preload', href, as} as PreloadAsProps, options),
6414 );
6415 resumableState.styleResources[key] =
6416 options &&
@@ -6430,12 +6428,12 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
6428 // we can return if we already have this resource
6429 return;
6430 }
6433 - const resource = ([]: Resource);
6431 + const resource = [] as Resource;
6432 renderState.preloads.scripts.set(key, resource);
6433 renderState.bulkPreloads.add(resource);
6434 pushLinkImpl(
6435 resource,
6438 - Object.assign(({rel: 'preload', href, as}: PreloadAsProps), options),
6436 + Object.assign({rel: 'preload', href, as} as PreloadAsProps, options),
6437 );
6438 resumableState.scriptResources[key] =
6439 options &&
@@ -6456,7 +6454,7 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
6454 return;
6455 }
6456 } else {
6459 - resources = ({}: ResumableState['unknownResources']['asType']);
6457 + resources = {} as ResumableState['unknownResources']['asType'];
6458 resumableState.unknownResources[as] = resources;
6459 }
6460 resources[key] = PRELOAD_NO_CREDS;
@@ -6489,13 +6487,13 @@ function preload(href: string, as: string, options?: ?PreloadImplOptions) {
6487 } else {
6488 // We either don't have headers or we are preloading something that does
6489 // not warrant elevated priority so we encode as an element.
6492 - const resource = ([]: Resource);
6490 + const resource = [] as Resource;
6491 const props = Object.assign(
6494 - ({
6492 + {
6493 rel: 'preload',
6494 href,
6495 as,
6498 - }: PreloadAsProps),
6496 + } as PreloadAsProps,
6497 options,
6498 );
6499 pushLinkImpl(resource, props);
@@ -6543,7 +6541,7 @@ function preloadModule(
6541 // we can return if we already have this resource
6542 return;
6543 }
6546 - resource = ([]: Resource);
6544 + resource = [] as Resource;
6545 resumableState.moduleScriptResources[key] =
6546 options &&
6547 (typeof options.crossOrigin === 'string' ||
@@ -6564,10 +6562,10 @@ function preloadModule(
6562 return;
6563 }
6564 } else {
6567 - resources = ({}: ResumableState['moduleUnknownResources']['asType']);
6565 + resources = {} as ResumableState['moduleUnknownResources']['asType'];
6566 resumableState.moduleUnknownResources[as] = resources;
6567 }
6570 - resource = ([]: Resource);
6568 + resource = [] as Resource;
6569 resources[key] = PRELOAD_NO_CREDS;
6570 }
6571 }
@@ -6575,10 +6573,10 @@ function preloadModule(
6573 pushLinkImpl(
6574 resource,
6575 Object.assign(
6578 - ({
6576 + {
6577 rel: 'modulepreload',
6578 href,
6581 - }: PreloadModuleProps),
6579 + } as PreloadModuleProps,
6580 options,
6581 ),
6582 );
@@ -6623,9 +6621,9 @@ function preinitStyle(
6621 if (!styleQueue) {
6622 styleQueue = {
6623 precedence: stringToChunk(escapeTextForBrowser(precedence)),
6626 - rules: ([]: Array<Chunk | PrecomputedChunk>),
6627 - hrefs: ([]: Array<Chunk | PrecomputedChunk>),
6628 - sheets: (new Map(): Map<string, StylesheetResource>),
6624 + rules: [] as Array<Chunk | PrecomputedChunk>,
6625 + hrefs: [] as Array<Chunk | PrecomputedChunk>,
6626 + sheets: new Map() as Map<string, StylesheetResource>,
6627 };
6628 renderState.styles.set(precedence, styleQueue);
6629 }
@@ -6633,11 +6631,11 @@ function preinitStyle(
6631 const resource = {
6632 state: PENDING,
6633 props: Object.assign(
6636 - ({
6634 + {
6635 rel: 'stylesheet',
6636 href,
6637 'data-precedence': precedence,
6640 - }: StylesheetProps),
6638 + } as StylesheetProps,
6639 options,
6640 ),
6641 };
@@ -6702,10 +6700,10 @@ function preinitScript(src: string, options?: ?PreinitScriptOptions): void {
6700 resumableState.scriptResources[key] = EXISTS;
6701
6702 const props: ScriptProps = Object.assign(
6705 - ({
6703 + {
6704 src,
6705 async: true,
6708 - }: ScriptProps),
6706 + } as ScriptProps,
6707 options,
6708 );
6709 if (resourceState) {
@@ -6764,11 +6762,11 @@ function preinitModuleScript(
6762 resumableState.moduleScriptResources[key] = EXISTS;
6763
6764 const props = Object.assign(
6767 - ({
6765 + {
6766 src,
6767 type: 'module',
6768 async: true,
6771 - }: ModuleScriptProps),
6769 + } as ModuleScriptProps,
6770 options,
6771 );
6772 if (resourceState) {
packages/react-dom-bindings/src/server/escapeTextForBrowser.js
+1 -1
@@ -114,7 +114,7 @@ function escapeTextForBrowser(text: string | number | boolean): string {
114 // this shortcircuit helps perf for types that we know will never have
115 // special characters, especially given that this function is used often
116 // for numeric dom ids.
117 - return '' + (text: any);
117 + return '' + (text as any);
118 }
119 return escapeHtml(text);
120 }
packages/react-dom-bindings/src/shared/ReactDOMFormActions.js
+1 -1
@@ -61,7 +61,7 @@ function resolveDispatcher() {
61 // Will result in a null access error if accessed outside render phase. We
62 // intentionally don't throw our own error because this is in a hot path.
63 // Also helps ensure this is inlined.
64 - return ((dispatcher: any): Dispatcher);
64 + return dispatcher as any as Dispatcher;
65 }
66
67 export function useFormStatus(): FormStatus {
packages/react-dom-bindings/src/shared/sanitizeURL.js
+1 -1
@@ -22,7 +22,7 @@ const isJavaScriptProtocol =
22 function sanitizeURL<T>(url: T): T | string {
23 // We should never have symbols here because they get filtered out elsewhere.
24 // eslint-disable-next-line react-internal/safe-string-coercion
25 - if (isJavaScriptProtocol.test('' + (url: any))) {
25 + if (isJavaScriptProtocol.test('' + (url as any))) {
26 // Return a different javascript: url that doesn't cause any side-effects and just
27 // throws if ever visited.
28 // eslint-disable-next-line no-script-url
packages/react-dom/src/ReactDOMFB.js
+1 -1
@@ -12,7 +12,7 @@ import {isEnabled} from 'react-dom-bindings/src/events/ReactDOMEventListener';
12 import Internals from './ReactDOMSharedInternalsFB';
13
14 // For classic WWW builds, include a few internals that are already in use.
15 -Object.assign((Internals: any), {
15 +Object.assign(Internals as any, {
16 ReactBrowserEventEmitter: {
17 isEnabled,
18 },
packages/react-dom/src/ReactDOMSharedInternals.js
+1 -1
@@ -14,7 +14,7 @@ import noop from 'shared/noop';
14
15 // This should line up with NoEventPriority from react-reconciler/src/ReactEventPriorities
16 // but we can't depend on the react-reconciler from this isomorphic code.
17 -export const NoEventPriority: EventPriority = (0: any);
17 +export const NoEventPriority: EventPriority = 0 as any;
18
19 type ReactDOMInternals = {
20 d /* ReactDOMCurrentDispatcher */: HostDispatcher,
packages/react-dom/src/ReactDOMSharedInternalsFB.js
+1 -1
@@ -36,7 +36,7 @@ const DefaultDispatcher: HostDispatcher = {
36 };
37
38 const Internals: ReactDOMInternals = {
39 - Events: (null: any),
39 + Events: null as any,
40 d /* ReactDOMCurrentDispatcher */: DefaultDispatcher,
41 p /* currentUpdatePriority */: NoEventPriority,
42 findDOMNode: null,
packages/react-dom/src/client/ReactDOMRoot.js
+3 -3
@@ -190,7 +190,7 @@ export function createRoot(
190 // $FlowFixMe[invalid-compare]
191 if (options !== null && options !== undefined) {
192 if (__DEV__) {
193 - if ((options: any).hydrate) {
193 + if ((options as any).hydrate) {
194 console.warn(
195 'hydrate through createRoot is deprecated. Use ReactDOMClient.hydrateRoot(container, <App />) instead.',
196 );
@@ -199,7 +199,7 @@ export function createRoot(
199 typeof options === 'object' &&
200 // $FlowFixMe[invalid-compare]
201 options !== null &&
202 - (options: any).$$typeof === REACT_ELEMENT_TYPE
202 + (options as any).$$typeof === REACT_ELEMENT_TYPE
203 ) {
204 console.error(
205 'You passed a JSX element to createRoot. You probably meant to ' +
@@ -253,7 +253,7 @@ export function createRoot(
253
254 const rootContainerElement: Document | Element | DocumentFragment =
255 !disableCommentsAsDOMContainers && container.nodeType === COMMENT_NODE
256 - ? (container.parentNode: any)
256 + ? (container.parentNode as any)
257 : container;
258 listenToAllSupportedEvents(rootContainerElement);
259
packages/react-dom/src/client/ReactDOMRootFB.js
+6 -6
@@ -135,11 +135,11 @@ export function createRoot(
135 return createRootImpl(
136 container,
137 assign(
138 - ({
138 + {
139 onUncaughtError: wwwOnUncaughtError,
140 onCaughtError: wwwOnCaughtError,
141 onDefaultTransitionIndicator: noopOnDefaultTransitionIndicator,
142 - }: any),
142 + } as any,
143 options,
144 ),
145 );
@@ -154,11 +154,11 @@ export function hydrateRoot(
154 container,
155 initialChildren,
156 assign(
157 - ({
157 + {
158 onUncaughtError: wwwOnUncaughtError,
159 onCaughtError: wwwOnCaughtError,
160 onDefaultTransitionIndicator: noopOnDefaultTransitionIndicator,
161 - }: any),
161 + } as any,
162 options,
163 ),
164 );
@@ -376,8 +376,8 @@ export function findDOMNode(
376 if (componentOrElement == null) {
377 return null;
378 }
379 - if ((componentOrElement: any).nodeType === ELEMENT_NODE) {
380 - return (componentOrElement: any);
379 + if ((componentOrElement as any).nodeType === ELEMENT_NODE) {
380 + return componentOrElement as any;
381 }
382 if (__DEV__) {
383 return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');
packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
+8 -8
@@ -85,7 +85,7 @@ function renderToReadableStream(
85 });
86
87 function onShellReady() {
88 - const stream: ReactDOMServerReadableStream = (new ReadableStream(
88 + const stream: ReactDOMServerReadableStream = new ReadableStream(
89 {
90 type: 'bytes',
91 pull: (controller): ?Promise<void> => {
@@ -99,7 +99,7 @@ function renderToReadableStream(
99 // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
100 // $FlowFixMe[incompatible-type]
101 {highWaterMark: 0},
102 - ): any);
102 + ) as any;
103 // TODO: Move to sub-classing ReadableStream.
104 stream.allReady = allReady;
105 resolve(stream);
@@ -150,10 +150,10 @@ function renderToReadableStream(
150 if (options && options.signal) {
151 const signal = options.signal;
152 if (signal.aborted) {
153 - abort(request, (signal: any).reason);
153 + abort(request, (signal as any).reason);
154 } else {
155 const listener = () => {
156 - abort(request, (signal: any).reason);
156 + abort(request, (signal as any).reason);
157 signal.removeEventListener('abort', listener);
158 };
159 signal.addEventListener('abort', listener);
@@ -177,7 +177,7 @@ function resume(
177 });
178
179 function onShellReady() {
180 - const stream: ReactDOMServerReadableStream = (new ReadableStream(
180 + const stream: ReactDOMServerReadableStream = new ReadableStream(
181 {
182 type: 'bytes',
183 pull: (controller): ?Promise<void> => {
@@ -191,7 +191,7 @@ function resume(
191 // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
192 // $FlowFixMe[incompatible-type]
193 {highWaterMark: 0},
194 - ): any);
194 + ) as any;
195 // TODO: Move to sub-classing ReadableStream.
196 stream.allReady = allReady;
197 resolve(stream);
@@ -219,10 +219,10 @@ function resume(
219 if (options && options.signal) {
220 const signal = options.signal;
221 if (signal.aborted) {
222 - abort(request, (signal: any).reason);
222 + abort(request, (signal as any).reason);
223 } else {
224 const listener = () => {
225 - abort(request, (signal: any).reason);
225 + abort(request, (signal as any).reason);
226 signal.removeEventListener('abort', listener);
227 };
228 signal.addEventListener('abort', listener);
packages/react-dom/src/server/ReactDOMFizzServerBun.js
+4 -4
@@ -74,7 +74,7 @@ function renderToReadableStream(
74 });
75
76 function onShellReady() {
77 - const stream: ReactDOMServerReadableStream = (new ReadableStream(
77 + const stream: ReactDOMServerReadableStream = new ReadableStream(
78 {
79 type: 'direct',
80 pull: (controller): ?Promise<void> => {
@@ -89,7 +89,7 @@ function renderToReadableStream(
89 // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
90 // $FlowFixMe[incompatible-type]
91 {highWaterMark: 2048},
92 - ): any);
92 + ) as any;
93 // TODO: Move to sub-classing ReadableStream.
94 stream.allReady = allReady;
95 resolve(stream);
@@ -140,10 +140,10 @@ function renderToReadableStream(
140 if (options && options.signal) {
141 const signal = options.signal;
142 if (signal.aborted) {
143 - abort(request, (signal: any).reason);
143 + abort(request, (signal as any).reason);
144 } else {
145 const listener = () => {
146 - abort(request, (signal: any).reason);
146 + abort(request, (signal as any).reason);
147 signal.removeEventListener('abort', listener);
148 };
149 signal.addEventListener('abort', listener);
packages/react-dom/src/server/ReactDOMFizzServerEdge.js
+8 -8
@@ -85,7 +85,7 @@ function renderToReadableStream(
85 });
86
87 function onShellReady() {
88 - const stream: ReactDOMServerReadableStream = (new ReadableStream(
88 + const stream: ReactDOMServerReadableStream = new ReadableStream(
89 {
90 type: 'bytes',
91 pull: (controller): ?Promise<void> => {
@@ -99,7 +99,7 @@ function renderToReadableStream(
99 // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
100 // $FlowFixMe[incompatible-type]
101 {highWaterMark: 0},
102 - ): any);
102 + ) as any;
103 // TODO: Move to sub-classing ReadableStream.
104 stream.allReady = allReady;
105 resolve(stream);
@@ -150,10 +150,10 @@ function renderToReadableStream(
150 if (options && options.signal) {
151 const signal = options.signal;
152 if (signal.aborted) {
153 - abort(request, (signal: any).reason);
153 + abort(request, (signal as any).reason);
154 } else {
155 const listener = () => {
156 - abort(request, (signal: any).reason);
156 + abort(request, (signal as any).reason);
157 signal.removeEventListener('abort', listener);
158 };
159 signal.addEventListener('abort', listener);
@@ -177,7 +177,7 @@ function resume(
177 });
178
179 function onShellReady() {
180 - const stream: ReactDOMServerReadableStream = (new ReadableStream(
180 + const stream: ReactDOMServerReadableStream = new ReadableStream(
181 {
182 type: 'bytes',
183 pull: (controller): ?Promise<void> => {
@@ -191,7 +191,7 @@ function resume(
191 // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
192 // $FlowFixMe[incompatible-type]
193 {highWaterMark: 0},
194 - ): any);
194 + ) as any;
195 // TODO: Move to sub-classing ReadableStream.
196 stream.allReady = allReady;
197 resolve(stream);
@@ -219,10 +219,10 @@ function resume(
219 if (options && options.signal) {
220 const signal = options.signal;
221 if (signal.aborted) {
222 - abort(request, (signal: any).reason);
222 + abort(request, (signal as any).reason);
223 } else {
224 const listener = () => {
225 - abort(request, (signal: any).reason);
225 + abort(request, (signal as any).reason);
226 signal.removeEventListener('abort', listener);
227 };
228 signal.addEventListener('abort', listener);
packages/react-dom/src/server/ReactDOMFizzServerNode.js
+10 -10
@@ -170,7 +170,7 @@ function createFakeWritableFromReadableStreamController(
170 ): Writable {
171 // The current host config expects a Writable so we create
172 // a fake writable for now to push into the Readable.
173 - return ({
173 + return {
174 write(chunk: string | Uint8Array) {
175 if (typeof chunk === 'string') {
176 chunk = textEncoder.encode(chunk);
@@ -191,7 +191,7 @@ function createFakeWritableFromReadableStreamController(
191 controller.close();
192 }
193 },
194 - }: any);
194 + } as any;
195 }
196
197 // TODO: Move to sub-classing ReadableStream.
@@ -218,7 +218,7 @@ function renderToReadableStream(
218
219 function onShellReady() {
220 let writable: Writable;
221 - const stream: ReactDOMServerReadableStream = (new ReadableStream(
221 + const stream: ReactDOMServerReadableStream = new ReadableStream(
222 {
223 type: 'bytes',
224 start: (controller): ?Promise<void> => {
@@ -236,7 +236,7 @@ function renderToReadableStream(
236 // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
237 // $FlowFixMe[incompatible-type]
238 {highWaterMark: 0},
239 - ): any);
239 + ) as any;
240 // TODO: Move to sub-classing ReadableStream.
241 stream.allReady = allReady;
242 resolve(stream);
@@ -287,10 +287,10 @@ function renderToReadableStream(
287 if (options && options.signal) {
288 const signal = options.signal;
289 if (signal.aborted) {
290 - abort(request, (signal: any).reason);
290 + abort(request, (signal as any).reason);
291 } else {
292 const listener = () => {
293 - abort(request, (signal: any).reason);
293 + abort(request, (signal as any).reason);
294 signal.removeEventListener('abort', listener);
295 };
296 signal.addEventListener('abort', listener);
@@ -377,7 +377,7 @@ function resume(
377
378 function onShellReady() {
379 let writable: Writable;
380 - const stream: ReactDOMServerReadableStream = (new ReadableStream(
380 + const stream: ReactDOMServerReadableStream = new ReadableStream(
381 {
382 type: 'bytes',
383 start: (controller): ?Promise<void> => {
@@ -395,7 +395,7 @@ function resume(
395 // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
396 // $FlowFixMe[incompatible-type]
397 {highWaterMark: 0},
398 - ): any);
398 + ) as any;
399 // TODO: Move to sub-classing ReadableStream.
400 stream.allReady = allReady;
401 resolve(stream);
@@ -423,10 +423,10 @@ function resume(
423 if (options && options.signal) {
424 const signal = options.signal;
425 if (signal.aborted) {
426 - abort(request, (signal: any).reason);
426 + abort(request, (signal as any).reason);
427 } else {
428 const listener = () => {
429 - abort(request, (signal: any).reason);
429 + abort(request, (signal as any).reason);
430 signal.removeEventListener('abort', listener);
431 };
432 signal.addEventListener('abort', listener);
packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js
+4 -4
@@ -132,10 +132,10 @@ function prerender(
132 if (options && options.signal) {
133 const signal = options.signal;
134 if (signal.aborted) {
135 - abort(request, (signal: any).reason);
135 + abort(request, (signal as any).reason);
136 } else {
137 const listener = () => {
138 - abort(request, (signal: any).reason);
138 + abort(request, (signal as any).reason);
139 signal.removeEventListener('abort', listener);
140 };
141 signal.addEventListener('abort', listener);
@@ -197,10 +197,10 @@ function resumeAndPrerender(
197 if (options && options.signal) {
198 const signal = options.signal;
199 if (signal.aborted) {
200 - abort(request, (signal: any).reason);
200 + abort(request, (signal as any).reason);
201 } else {
202 const listener = () => {
203 - abort(request, (signal: any).reason);
203 + abort(request, (signal as any).reason);
204 signal.removeEventListener('abort', listener);
205 };
206 signal.addEventListener('abort', listener);
packages/react-dom/src/server/ReactDOMFizzStaticEdge.js
+4 -4
@@ -131,10 +131,10 @@ function prerender(
131 if (options && options.signal) {
132 const signal = options.signal;
133 if (signal.aborted) {
134 - abort(request, (signal: any).reason);
134 + abort(request, (signal as any).reason);
135 } else {
136 const listener = () => {
137 - abort(request, (signal: any).reason);
137 + abort(request, (signal as any).reason);
138 signal.removeEventListener('abort', listener);
139 };
140 signal.addEventListener('abort', listener);
@@ -195,10 +195,10 @@ function resumeAndPrerender(
195 if (options && options.signal) {
196 const signal = options.signal;
197 if (signal.aborted) {
198 - abort(request, (signal: any).reason);
198 + abort(request, (signal as any).reason);
199 } else {
200 const listener = () => {
201 - abort(request, (signal: any).reason);
201 + abort(request, (signal as any).reason);
202 signal.removeEventListener('abort', listener);
203 };
204 signal.addEventListener('abort', listener);
packages/react-dom/src/server/ReactDOMFizzStaticNode.js
+12 -12
@@ -73,7 +73,7 @@ function createFakeWritableFromReadableStreamController(
73 ): Writable {
74 // The current host config expects a Writable so we create
75 // a fake writable for now to push into the Readable.
76 - return ({
76 + return {
77 write(chunk: string | Uint8Array) {
78 if (typeof chunk === 'string') {
79 chunk = textEncoder.encode(chunk);
@@ -94,13 +94,13 @@ function createFakeWritableFromReadableStreamController(
94 controller.close();
95 }
96 },
97 - }: any);
97 + } as any;
98 }
99
100 function createFakeWritableFromReadable(readable: any): Writable {
101 // The current host config expects a Writable so we create
102 // a fake writable for now to push into the Readable.
103 - return ({
103 + return {
104 write(chunk) {
105 return readable.push(chunk);
106 },
@@ -110,7 +110,7 @@ function createFakeWritableFromReadable(readable: any): Writable {
110 destroy(error) {
111 readable.destroy(error);
112 },
113 - }: any);
113 + } as any;
114 }
115
116 function prerenderToNodeStream(
@@ -163,10 +163,10 @@ function prerenderToNodeStream(
163 if (options && options.signal) {
164 const signal = options.signal;
165 if (signal.aborted) {
166 - abort(request, (signal: any).reason);
166 + abort(request, (signal as any).reason);
167 } else {
168 const listener = () => {
169 - abort(request, (signal: any).reason);
169 + abort(request, (signal as any).reason);
170 signal.removeEventListener('abort', listener);
171 };
172 signal.addEventListener('abort', listener);
@@ -253,10 +253,10 @@ function prerender(
253 if (options && options.signal) {
254 const signal = options.signal;
255 if (signal.aborted) {
256 - abort(request, (signal: any).reason);
256 + abort(request, (signal as any).reason);
257 } else {
258 const listener = () => {
259 - abort(request, (signal: any).reason);
259 + abort(request, (signal as any).reason);
260 signal.removeEventListener('abort', listener);
261 };
262 signal.addEventListener('abort', listener);
@@ -307,10 +307,10 @@ function resumeAndPrerenderToNodeStream(
307 if (options && options.signal) {
308 const signal = options.signal;
309 if (signal.aborted) {
310 - abort(request, (signal: any).reason);
310 + abort(request, (signal as any).reason);
311 } else {
312 const listener = () => {
313 - abort(request, (signal: any).reason);
313 + abort(request, (signal as any).reason);
314 signal.removeEventListener('abort', listener);
315 };
316 signal.addEventListener('abort', listener);
@@ -373,10 +373,10 @@ function resumeAndPrerender(
373 if (options && options.signal) {
374 const signal = options.signal;
375 if (signal.aborted) {
376 - abort(request, (signal: any).reason);
376 + abort(request, (signal as any).reason);
377 } else {
378 const listener = () => {
379 - abort(request, (signal: any).reason);
379 + abort(request, (signal as any).reason);
380 signal.removeEventListener('abort', listener);
381 };
382 signal.addEventListener('abort', listener);
packages/react-dom/src/test-utils/FizzTestUtils.js
+2 -2
@@ -40,7 +40,7 @@ async function insertNodesAndExecuteScripts(
40 lastChild = node;
41
42 if (node.nodeType === 1) {
43 - const element: Element = (node: any);
43 + const element: Element = node as any;
44 if (
45 // $FlowFixMe[prop-missing]
46 element.dataset != null &&
@@ -53,7 +53,7 @@ async function insertNodesAndExecuteScripts(
53 // When we have renderIntoContainer and renderDocument this will be
54 // more enforceable. At the moment you can misconfigure your stream and end up
55 // with instructions that are deep in the document
56 - (ownerDocument.body: any).appendChild(element);
56 + (ownerDocument.body as any).appendChild(element);
57 } else {
58 target.appendChild(element);
59
packages/react-flight-server-fb/src/ReactFlightFBReferences.js
+2 -2
@@ -67,7 +67,7 @@ function bind(this: ServerReference<any>): any {
67 const $$id = {value: this.$$id};
68 const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
69 return Object.defineProperties(
70 - (newFn: any),
70 + newFn as any,
71 (__DEV__
72 ? {
73 $$typeof,
@@ -107,7 +107,7 @@ export function registerServerReference<T: Function>(
107 };
108 const $$bound = {value: null, configurable: true};
109 return Object.defineProperties(
110 - (reference: any),
110 + reference as any,
111 (__DEV__
112 ? {
113 $$typeof,
packages/react-flight-server-fb/src/ReactServerStreamConfigFB.js
+16 -15
@@ -63,7 +63,7 @@ function writeStringChunk(destination: Destination, stringChunk: string) {
63 if (writtenBytes > 0) {
64 writeToDestination(
65 destination,
66 - ((currentView: any): Uint8Array).subarray(0, writtenBytes),
66 + (currentView as any as Uint8Array).subarray(0, writtenBytes),
67 );
68 currentView = new Uint8Array(VIEW_SIZE);
69 writtenBytes = 0;
@@ -73,9 +73,9 @@ function writeStringChunk(destination: Destination, stringChunk: string) {
73 return;
74 }
75
76 - let target: Uint8Array = (currentView: any);
76 + let target: Uint8Array = currentView as any;
77 if (writtenBytes > 0) {
78 - target = ((currentView: any): Uint8Array).subarray(writtenBytes);
78 + target = (currentView as any as Uint8Array).subarray(writtenBytes);
79 }
80 const {read, written} = textEncoder.encodeInto(stringChunk, target);
81 writtenBytes += written;
@@ -83,17 +83,17 @@ function writeStringChunk(destination: Destination, stringChunk: string) {
83 if (read < stringChunk.length) {
84 writeToDestination(
85 destination,
86 - (currentView: any).subarray(0, writtenBytes),
86 + (currentView as any).subarray(0, writtenBytes),
87 );
88 currentView = new Uint8Array(VIEW_SIZE);
89 writtenBytes = textEncoder.encodeInto(
90 stringChunk.slice(read),
91 - (currentView: any),
91 + currentView as any,
92 ).written;
93 }
94
95 if (writtenBytes === VIEW_SIZE) {
96 - writeToDestination(destination, (currentView: any));
96 + writeToDestination(destination, currentView as any);
97 currentView = new Uint8Array(VIEW_SIZE);
98 writtenBytes = 0;
99 }
@@ -110,7 +110,7 @@ function writeViewChunk(
110 if (writtenBytes > 0) {
111 writeToDestination(
112 destination,
113 - ((currentView: any): Uint8Array).subarray(0, writtenBytes),
113 + (currentView as any as Uint8Array).subarray(0, writtenBytes),
114 );
115 currentView = new Uint8Array(VIEW_SIZE);
116 writtenBytes = 0;
@@ -120,27 +120,28 @@ function writeViewChunk(
120 }
121
122 let bytesToWrite = chunk;
123 - const allowableBytes = ((currentView: any): Uint8Array).length - writtenBytes;
123 + const allowableBytes =
124 + (currentView as any as Uint8Array).length - writtenBytes;
125 if (allowableBytes < bytesToWrite.byteLength) {
126 if (allowableBytes === 0) {
126 - writeToDestination(destination, (currentView: any));
127 + writeToDestination(destination, currentView as any);
128 } else {
128 - ((currentView: any): Uint8Array).set(
129 + (currentView as any as Uint8Array).set(
130 bytesToWrite.subarray(0, allowableBytes),
131 writtenBytes,
132 );
133 writtenBytes += allowableBytes;
133 - writeToDestination(destination, (currentView: any));
134 + writeToDestination(destination, currentView as any);
135 bytesToWrite = bytesToWrite.subarray(allowableBytes);
136 }
137 currentView = new Uint8Array(VIEW_SIZE);
138 writtenBytes = 0;
139 }
139 - ((currentView: any): Uint8Array).set(bytesToWrite, writtenBytes);
140 + (currentView as any as Uint8Array).set(bytesToWrite, writtenBytes);
141 writtenBytes += bytesToWrite.byteLength;
142
143 if (writtenBytes === VIEW_SIZE) {
143 - writeToDestination(destination, (currentView: any));
144 + writeToDestination(destination, currentView as any);
145 currentView = new Uint8Array(VIEW_SIZE);
146 writtenBytes = 0;
147 }
@@ -153,7 +154,7 @@ export function writeChunk(
154 if (typeof chunk === 'string') {
155 writeStringChunk(destination, chunk);
156 } else {
156 - writeViewChunk(destination, ((chunk: any): PrecomputedChunk | BinaryChunk));
157 + writeViewChunk(destination, chunk as any as PrecomputedChunk | BinaryChunk);
158 }
159 }
160
@@ -186,7 +187,7 @@ export function close(destination: Destination) {
187 destination.end();
188 }
189
189 -export const textEncoder: TextEncoderType = (new TextEncoder(): any);
190 +export const textEncoder: TextEncoderType = new TextEncoder() as any;
191
192 export function stringToChunk(content: string): Chunk {
193 return content;
packages/react-flight-server-fb/src/client/ReactFlightClientConfigBundlerFB.js
+8 -8
@@ -64,11 +64,11 @@ export function resolveServerReference<T>(
64 config: ServerManifest,
65 id: ServerReferenceId,
66 ): ClientReference<T> {
67 - return ({
67 + return {
68 $$typeof: Symbol.for('react.client.reference'),
69 $$id: id,
70 $$hblp: null,
71 - }: any);
71 + } as any;
72 }
73
74 const asyncModuleCache: Map<string, Thenable<any>> = new Map();
@@ -97,12 +97,12 @@ export function preloadModule<T>(
97 const modulePromise: Thenable<T> = jsr.load();
98 modulePromise.then(
99 value => {
100 - const fulfilledThenable: FulfilledThenable<mixed> = (modulePromise: any);
100 + const fulfilledThenable: FulfilledThenable<mixed> = modulePromise as any;
101 fulfilledThenable.status = 'fulfilled';
102 fulfilledThenable.value = value;
103 },
104 reason => {
105 - const rejectedThenable: RejectedThenable<mixed> = (modulePromise: any);
105 + const rejectedThenable: RejectedThenable<mixed> = modulePromise as any;
106 rejectedThenable.status = 'rejected';
107 rejectedThenable.reason = reason;
108 },
@@ -151,7 +151,7 @@ export function requireModule<T>(metadata: ClientReference<T>): T {
151 // We cache ReactIOInfo across requests so that inner refreshes can dedupe with outer.
152 const moduleIOInfoCache: Map<string, ReactIOInfo> = __DEV__
153 ? new Map()
154 - : (null: any);
154 + : (null as any);
155
156 export function getModuleDebugInfo<T>(
157 metadata: ClientReference<T>,
@@ -182,7 +182,7 @@ export function getModuleDebugInfo<T>(
182 start = resourceEntry.startTime;
183 end = start + resourceEntry.duration;
184 // $FlowFixMe[prop-missing]
185 - byteSize = (resourceEntry.transferSize: any) || 0;
185 + byteSize = (resourceEntry.transferSize as any) || 0;
186 }
187 }
188 }
@@ -218,13 +218,13 @@ export function getModuleDebugInfo<T>(
218 href +
219 ':1:1';
220 }
221 - ioInfo = ({
221 + ioInfo = {
222 name: 'script',
223 start: start,
224 end: end,
225 value: value,
226 debugStack: fakeStack,
227 - }: ReactIOInfo);
227 + } as ReactIOInfo;
228 if (byteSize > 0) {
229 // $FlowFixMe[cannot-write]
230 ioInfo.byteSize = byteSize;
packages/react-flight-server-fb/src/client/ReactFlightDOMClientBrowser.js
+5 -5
@@ -173,7 +173,7 @@ function startReadingFromStream(
173 if (done) {
174 return onDone();
175 }
176 - const buffer: Uint8Array = (value: any);
176 + const buffer: Uint8Array = value as any;
177 processBinaryChunk(response, streamState, buffer);
178 return reader.read().then(progress).catch(error);
179 }
@@ -240,11 +240,11 @@ function createFromFetch<T>(
240 options.debugChannel.readable,
241 handleDone,
242 );
243 - startReadingFromStream(response, (r.body: any), handleDone, r);
243 + startReadingFromStream(response, r.body as any, handleDone, r);
244 } else {
245 startReadingFromStream(
246 response,
247 - (r.body: any),
247 + r.body as any,
248 close.bind(null, response),
249 r,
250 );
@@ -276,10 +276,10 @@ function encodeReply(
276 if (options && options.signal) {
277 const signal = options.signal;
278 if (signal.aborted) {
279 - abort((signal: any).reason);
279 + abort((signal as any).reason);
280 } else {
281 const listener = () => {
282 - abort((signal: any).reason);
282 + abort((signal as any).reason);
283 signal.removeEventListener('abort', listener);
284 };
285 signal.addEventListener('abort', listener);
packages/react-flight-server-fb/src/server/ReactFlightDOMServerNode.js
+9 -9
@@ -114,7 +114,7 @@ function startReadingFromDebugChannelReadable(
114 }
115 stringBuffer += chunk;
116 } else {
117 - const buffer: Uint8Array = (chunk: any);
117 + const buffer: Uint8Array = chunk as any;
118 stringBuffer += readPartialStringChunk(stringDecoder, buffer);
119 lastWasPartial = true;
120 }
@@ -141,7 +141,7 @@ function startReadingFromDebugChannelReadable(
141 // $FlowFixMe[method-unbinding]
142 typeof stream.binaryType === 'string'
143 ) {
144 - const ws: WebSocket = (stream: any);
144 + const ws: WebSocket = stream as any;
145 ws.binaryType = 'arraybuffer';
146 ws.addEventListener('message', event => {
147 // $FlowFixMe[incompatible-type]
@@ -153,7 +153,7 @@ function startReadingFromDebugChannelReadable(
153 });
154 ws.addEventListener('close', onClose);
155 } else {
156 - const readable: Readable = (stream: any);
156 + const readable: Readable = stream as any;
157 readable.on('data', onData);
158 readable.on('error', onError);
159 readable.on('end', onClose);
@@ -186,16 +186,16 @@ function renderToPipeableStream(
186 // $FlowFixMe[method-unbinding]
187 (typeof debugChannel.read === 'function' ||
188 typeof debugChannel.readyState === 'number')
189 - ? (debugChannel: any)
189 + ? (debugChannel as any)
190 : undefined;
191 const debugChannelWritable: void | Writable =
192 __DEV__ && debugChannel !== undefined
193 ? // $FlowFixMe[method-unbinding]
194 typeof debugChannel.write === 'function'
195 - ? (debugChannel: any)
195 + ? (debugChannel as any)
196 : // $FlowFixMe[method-unbinding]
197 typeof debugChannel.send === 'function'
198 - ? createFakeWritableFromWebSocket((debugChannel: any))
198 + ? createFakeWritableFromWebSocket(debugChannel as any)
199 : undefined
200 : undefined;
201 const request = createRequest(
@@ -250,9 +250,9 @@ function renderToPipeableStream(
250 }
251
252 function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
253 - return ({
253 + return {
254 write(chunk: string | Uint8Array) {
255 - webSocket.send((chunk: any));
255 + webSocket.send(chunk as any);
256 return true;
257 },
258 end() {
@@ -268,7 +268,7 @@ function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
268 webSocket.close(1011);
269 }
270 },
271 - }: any);
271 + } as any;
272 }
273
274 function decodeReplyFromBusboy<T>(
packages/react-markup/src/ReactMarkupClient.js
+2 -2
@@ -89,10 +89,10 @@ export function experimental_renderToHTML(
89 if (options && options.signal) {
90 const signal = options.signal;
91 if (signal.aborted) {
92 - abortFizz(fizzRequest, (signal: any).reason);
92 + abortFizz(fizzRequest, (signal as any).reason);
93 } else {
94 const listener = () => {
95 - abortFizz(fizzRequest, (signal: any).reason);
95 + abortFizz(fizzRequest, (signal as any).reason);
96 signal.removeEventListener('abort', listener);
97 };
98 signal.addEventListener('abort', listener);
packages/react-markup/src/ReactMarkupServer.js
+4 -4
@@ -219,12 +219,12 @@ export function experimental_renderToHTML(
219 if (options && options.signal) {
220 const signal = options.signal;
221 if (signal.aborted) {
222 - abortFlight(flightRequest, (signal: any).reason);
223 - abortFizz(fizzRequest, (signal: any).reason);
222 + abortFlight(flightRequest, (signal as any).reason);
223 + abortFizz(fizzRequest, (signal as any).reason);
224 } else {
225 const listener = () => {
226 - abortFlight(flightRequest, (signal: any).reason);
227 - abortFizz(fizzRequest, (signal: any).reason);
226 + abortFlight(flightRequest, (signal as any).reason);
227 + abortFizz(fizzRequest, (signal as any).reason);
228 signal.removeEventListener('abort', listener);
229 };
230 signal.addEventListener('abort', listener);
packages/react-native-renderer/fabric.js
+1 -1
@@ -10,6 +10,6 @@
10 import type {ReactFabricType} from './src/ReactNativeTypes';
11 import * as ReactFabric from './src/ReactFabric';
12 // Assert that the exports line up with the type we're going to expose.
13 -(ReactFabric: ReactFabricType);
13 +ReactFabric as ReactFabricType;
14
15 export * from './src/ReactFabric';
packages/react-native-renderer/src/ReactFabricComponentTree.js
+1 -1
@@ -20,7 +20,7 @@ import {getPublicInstance} from './ReactFiberConfigFabric';
20 // This is ok in DOM because they types are interchangeable, but in React Native
21 // they aren't.
22 function getInstanceFromNode(node: Instance | TextInstance): Fiber | null {
23 - const instance: Instance = (node: $FlowFixMe); // In React Native, node is never a text instance
23 + const instance: Instance = node as $FlowFixMe; // In React Native, node is never a text instance
24
25 if (
26 instance.canonical != null &&
packages/react-native-renderer/src/ReactFabricEventEmitter.js
+5 -5
@@ -51,9 +51,9 @@ function extractPluginEvents(
51 nativeEventTarget: null | EventTarget,
52 ): Array<ReactSyntheticEvent> | ReactSyntheticEvent | null {
53 let events: Array<ReactSyntheticEvent> | ReactSyntheticEvent | null = null;
54 - const legacyPlugins = ((plugins: any): Array<
54 + const legacyPlugins = plugins as any as Array<
55 LegacyPluginModule<AnyNativeEvent>,
56 - >);
56 + >;
57 for (let i = 0; i < legacyPlugins.length; i++) {
58 // Not every plugin in the ordering may be loaded at runtime.
59 const possiblePlugin = legacyPlugins[i];
@@ -94,9 +94,9 @@ export function dispatchEvent(
94 ) {
95 const nativeEvent: AnyNativeEvent =
96 nativeEventParam != null && typeof nativeEventParam === 'object'
97 - ? (nativeEventParam: any)
97 + ? (nativeEventParam as any)
98 : {};
99 - const targetFiber = (target: null | Fiber);
99 + const targetFiber = target as null | Fiber;
100
101 let eventTarget = null;
102 if (targetFiber != null) {
@@ -104,7 +104,7 @@ export function dispatchEvent(
104 // Guard against Fiber being unmounted
105 if (stateNode != null) {
106 // $FlowExpectedError[incompatible-type] public instances in Fabric do not implement `EventTarget` yet.
107 - eventTarget = (getPublicInstance(stateNode): EventTarget);
107 + eventTarget = getPublicInstance(stateNode) as EventTarget;
108 }
109 }
110
packages/react-native-renderer/src/ReactFiberConfigFabric.js
+11 -11
@@ -810,7 +810,7 @@ FragmentInstance.prototype.getRootNode = function (
810 }
811 const parentHostInstance = getPublicInstanceFromHostFiber(parentHostFiber);
812 // $FlowFixMe[incompatible-use] Fabric PublicInstance is opaque
813 - const rootNode = (parentHostInstance.getRootNode(getRootNodeOptions): Node);
813 + const rootNode = parentHostInstance.getRootNode(getRootNodeOptions) as Node;
814 return rootNode;
815 };
816
@@ -840,9 +840,9 @@ function addFragmentHandleToFiber(
840 fragmentInstance: FragmentInstanceType,
841 ): boolean {
842 if (enableFragmentRefsInstanceHandles) {
843 - const instance = ((getPublicInstanceFromHostFiber(
843 + const instance = getPublicInstanceFromHostFiber(
844 child,
845 - ): any): PublicInstanceWithFragmentHandles);
845 + ) as any as PublicInstanceWithFragmentHandles;
846 if (instance != null) {
847 addFragmentHandleToInstance(instance, fragmentInstance);
848 }
@@ -865,7 +865,7 @@ function addFragmentHandleToInstance(
865 export function createFragmentInstance(
866 fragmentFiber: Fiber,
867 ): FragmentInstanceType {
868 - const fragmentInstance = new (FragmentInstance: any)(fragmentFiber);
868 + const fragmentInstance = new (FragmentInstance as any)(fragmentFiber);
869 if (enableFragmentRefsInstanceHandles) {
870 traverseFragmentInstance(
871 fragmentFiber,
@@ -891,7 +891,7 @@ export function commitNewChildToFragmentInstance(
891 if (enableFragmentRefsTextNodes && childInstance.canonical == null) {
892 return;
893 }
894 - const instance: Instance = (childInstance: any);
894 + const instance: Instance = childInstance as any;
895 const publicInstance = getPublicInstance(instance);
896 if (fragmentInstance._observers !== null) {
897 if (publicInstance == null) {
@@ -905,7 +905,7 @@ export function commitNewChildToFragmentInstance(
905 }
906 if (enableFragmentRefsInstanceHandles) {
907 addFragmentHandleToInstance(
908 - ((publicInstance: any): PublicInstanceWithFragmentHandles),
908 + publicInstance as any as PublicInstanceWithFragmentHandles,
909 fragmentInstance,
910 );
911 }
@@ -919,10 +919,10 @@ export function deleteChildFromFragmentInstance(
919 if (enableFragmentRefsTextNodes && childInstance.canonical == null) {
920 return;
921 }
922 - const instance: Instance = (childInstance: any);
923 - const publicInstance = ((getPublicInstance(
922 + const instance: Instance = childInstance as any;
923 + const publicInstance = getPublicInstance(
924 instance,
925 - ): any): PublicInstanceWithFragmentHandles);
925 + ) as any as PublicInstanceWithFragmentHandles;
926 if (enableFragmentRefsInstanceHandles) {
927 if (publicInstance.reactFragments != null) {
928 publicInstance.reactFragments.delete(fragmentInstance);
@@ -933,8 +933,8 @@ export function deleteChildFromFragmentInstance(
933 export const NotPendingTransition: TransitionStatus = null;
934 export const HostTransitionContext: ReactContext<TransitionStatus> = {
935 $$typeof: REACT_CONTEXT_TYPE,
936 - Provider: (null: any),
937 - Consumer: (null: any),
936 + Provider: null as any,
937 + Consumer: null as any,
938 _currentValue: NotPendingTransition,
939 _currentValue2: NotPendingTransition,
940 _threadCount: 0,
packages/react-native-renderer/src/ReactFiberConfigFabricWithViewTransition.js
+2 -2
@@ -204,8 +204,8 @@ export function createViewTransitionInstance(
204 fabricCreateViewTransitionInstance(name, tag);
205 return {
206 name,
207 - old: new (ViewTransitionPseudoElement: any)('old', name),
208 - new: new (ViewTransitionPseudoElement: any)('new', name),
207 + old: new (ViewTransitionPseudoElement as any)('old', name),
208 + new: new (ViewTransitionPseudoElement as any)('new', name),
209 };
210 }
211
packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js
+1 -1
@@ -167,7 +167,7 @@ function accumulateDirectDispatches(events: ?(Array<Object> | Object)) {
167 type PropagationPhases = 'bubbled' | 'captured';
168
169 const ReactNativeBridgeEventPlugin: LegacyPluginModule<AnyNativeEvent> = {
170 - eventTypes: ({}: EventTypes),
170 + eventTypes: {} as EventTypes,
171
172 extractEvents: function (
173 topLevelType: TopLevelType,
packages/react-native-renderer/src/ReactNativeFiberInspector.js
+1 -1
@@ -123,7 +123,7 @@ if (__DEV__) {
123 hierarchy.unshift(instance);
124 const owner = instance._debugOwner;
125 if (owner != null && typeof owner.tag === 'number') {
126 - traverseOwnerTreeUp(hierarchy, (owner: any));
126 + traverseOwnerTreeUp(hierarchy, owner as any);
127 } else {
128 // TODO: Traverse Server Components owners.
129 }
packages/react-native-renderer/src/legacy-events/EventPluginRegistry.js
+1 -1
@@ -199,7 +199,7 @@ export const registrationNameDependencies: {
199 */
200 export const possibleRegistrationNames: {
201 [lowerCasedName: string]: string,
202 -} = __DEV__ ? {} : (null: any);
202 +} = __DEV__ ? {} : (null as any);
203 // Trust the developer to only use possibleRegistrationNames in __DEV__
204
205 /**
packages/react-native-renderer/src/legacy-events/ResponderTouchHistoryStore.js
+1 -1
@@ -56,7 +56,7 @@ function timestampForTouch(touch: Touch): number {
56 // The legacy internal implementation provides "timeStamp", which has been
57 // renamed to "timestamp". Let both work for now while we iron it out
58 // TODO (evv): rename timeStamp to timestamp in internal code
59 - return (touch: any).timeStamp || touch.timestamp;
59 + return (touch as any).timeStamp || touch.timestamp;
60 }
61
62 /**
packages/react-noop-renderer/src/ReactNoopFlightServer.js
+2 -2
@@ -97,10 +97,10 @@ function render(model: ReactClientValue, options?: Options): Destination {
97 const signal = options ? options.signal : undefined;
98 if (signal) {
99 if (signal.aborted) {
100 - ReactNoopFlightServer.abort(request, (signal: any).reason);
100 + ReactNoopFlightServer.abort(request, (signal as any).reason);
101 } else {
102 const listener = () => {
103 - ReactNoopFlightServer.abort(request, (signal: any).reason);
103 + ReactNoopFlightServer.abort(request, (signal as any).reason);
104 signal.removeEventListener('abort', listener);
105 };
106 signal.addEventListener('abort', listener);
packages/react-noop-renderer/src/ReactNoopServer.js
+1 -1
@@ -69,7 +69,7 @@ function write(destination: Destination, buffer: Uint8Array): void {
69 return;
70 }
71 // We assume one chunk is one instance.
72 - const instance = JSON.parse(Buffer.from((buffer: any)).toString('utf8'));
72 + const instance = JSON.parse(Buffer.from(buffer as any).toString('utf8'));
73 if (stack.length === 0) {
74 destination.root = instance;
75 } else {
packages/react-noop-renderer/src/createReactNoop.js
+14 -14
@@ -127,7 +127,7 @@ function createReactNoop(
127 prevParent !==
128 // $FlowFixMe[prop-missing]
129 // $FlowFixMe[incompatible-type]
130 - (parentInstance: Instance).id
130 + (parentInstance as Instance).id
131 ) {
132 throw new Error('Reparenting is not allowed');
133 }
@@ -135,7 +135,7 @@ function createReactNoop(
135 child.parent =
136 // $FlowFixMe[prop-missing]
137 // $FlowFixMe[incompatible-type]
138 - (parentInstance: Instance).id;
138 + (parentInstance as Instance).id;
139 const index = parentInstance.children.indexOf(child);
140 if (index !== -1) {
141 parentInstance.children.splice(index, 1);
@@ -161,7 +161,7 @@ function createReactNoop(
161 parentInstance: Instance,
162 child: Instance | TextInstance,
163 ): void {
164 - if (typeof (parentInstance: any).rootID === 'string') {
164 + if (typeof (parentInstance as any).rootID === 'string') {
165 // Some calls to this aren't typesafe.
166 // This helps surface mistakes in tests.
167 throw new Error('appendChild() first argument is not an instance.');
@@ -205,7 +205,7 @@ function createReactNoop(
205 child: Instance | TextInstance,
206 beforeChild: Instance | TextInstance,
207 ) {
208 - if (typeof (parentInstance: any).rootID === 'string') {
208 + if (typeof (parentInstance as any).rootID === 'string') {
209 // Some calls to this aren't typesafe.
210 // This helps surface mistakes in tests.
211 throw new Error('insertBefore() first argument is not an instance.');
@@ -246,7 +246,7 @@ function createReactNoop(
246 parentInstance: Instance,
247 child: Instance | TextInstance,
248 ): void {
249 - if (typeof (parentInstance: any).rootID === 'string') {
249 + if (typeof (parentInstance as any).rootID === 'string') {
250 // Some calls to this aren't typesafe.
251 // This helps surface mistakes in tests.
252 throw new Error('removeChild() first argument is not an instance.');
@@ -274,7 +274,7 @@ function createReactNoop(
274 : // $FlowFixMe[incompatible-type] We're not typing immutable instances.
275 (children ?? []),
276 text: shouldSetTextContent(type, newProps)
277 - ? computeText((newProps.children: any) + '', instance.context)
277 + ? computeText((newProps.children as any) + '', instance.context)
278 : null,
279 prop: newProps.prop,
280 hidden: !!newProps.hidden,
@@ -411,7 +411,7 @@ function createReactNoop(
411 },
412
413 getPublicInstance(instance: Instance): PublicInstance {
414 - return (instance: any);
414 + return instance as any;
415 },
416
417 HostTransitionContext: null,
@@ -440,7 +440,7 @@ function createReactNoop(
440 parent: -1,
441 text: shouldSetTextContent(type, props)
442 ? // eslint-disable-next-line react-internal/safe-string-coercion
443 - computeText((props.children: any) + '', hostContext)
443 + computeText((props.children as any) + '', hostContext)
444 : null,
445 prop: props.prop,
446 hidden: !!props.hidden,
@@ -696,7 +696,7 @@ function createReactNoop(
696 return null;
697 },
698
699 - NotPendingTransition: (null: TransitionStatus),
699 + NotPendingTransition: null as TransitionStatus,
700
701 resetFormInstance(form: Instance) {},
702
@@ -755,7 +755,7 @@ function createReactNoop(
755 checkPropStringCoercion(newProps.children, 'children');
756 }
757 instance.text = computeText(
758 - (newProps.children: any) + '',
758 + (newProps.children as any) + '',
759 instance.context,
760 );
761 }
@@ -1071,9 +1071,9 @@ function createReactNoop(
1071 }
1072 if (isArray(child.children)) {
1073 // This is an instance.
1074 - const instance: Instance = (child: any);
1074 + const instance: Instance = child as any;
1075 const children = childToJSX(instance.children, instance.text);
1076 - const props = ({prop: instance.prop}: any);
1076 + const props = {prop: instance.prop} as any;
1077 if (instance.hidden) {
1078 props.hidden = true;
1079 }
@@ -1087,7 +1087,7 @@ function createReactNoop(
1087 return createJSXElementForTestComparison(instance.type, props);
1088 }
1089 // This is a text instance
1090 - const textInstance: TextInstance = (child: any);
1090 + const textInstance: TextInstance = child as any;
1091 if (textInstance.hidden) {
1092 return '';
1093 }
@@ -1450,7 +1450,7 @@ function createReactNoop(
1450 return null;
1451 }
1452 // Unsound duck typing.
1453 - const component = (componentOrElement: any);
1453 + const component = componentOrElement as any;
1454 if (typeof component.id === 'number') {
1455 return component;
1456 }
packages/react-reconciler/src/ReactChildFiber.js
+27 -27
@@ -145,9 +145,9 @@ if (__DEV__) {
145 * object keys are not valid. This allows us to keep track of children between
146 * updates.
147 */
148 - ownerHasKeyUseWarning = ({}: {[string]: boolean});
149 - ownerHasFunctionTypeWarning = ({}: {[string]: boolean});
150 - ownerHasSymbolTypeWarning = ({}: {[string]: boolean});
148 + ownerHasKeyUseWarning = {} as {[string]: boolean};
149 + ownerHasFunctionTypeWarning = {} as {[string]: boolean};
150 + ownerHasSymbolTypeWarning = {} as {[string]: boolean};
151
152 warnForMissingKey = (
153 returnFiber: Fiber,
@@ -188,7 +188,7 @@ if (__DEV__) {
188
189 let currentComponentErrorInfo = '';
190 if (parentOwner && typeof parentOwner.tag === 'number') {
191 - const name = getComponentNameFromFiber((parentOwner: any));
191 + const name = getComponentNameFromFiber(parentOwner as any);
192 if (name) {
193 currentComponentErrorInfo =
194 '\n\nCheck the render method of `' + name + '`.';
@@ -207,7 +207,7 @@ if (__DEV__) {
207 if (childOwner != null && parentOwner !== childOwner) {
208 let ownerName = null;
209 if (typeof childOwner.tag === 'number') {
210 - ownerName = getComponentNameFromFiber((childOwner: any));
210 + ownerName = getComponentNameFromFiber(childOwner as any);
211 } else if (typeof childOwner.name === 'string') {
212 ownerName = childOwner.name;
213 }
@@ -765,7 +765,7 @@ function createChildReconciler(
765 }
766 case REACT_LAZY_TYPE: {
767 const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
768 - const resolvedChild = resolveLazy((newChild: any));
768 + const resolvedChild = resolveLazy(newChild as any);
769 const created = createChild(returnFiber, resolvedChild, lanes);
770 currentDebugInfo = prevDebugInfo;
771 return created;
@@ -801,7 +801,7 @@ function createChildReconciler(
801 //
802 // Unwrap the inner value and recursively call this function again.
803 if (typeof newChild.then === 'function') {
804 - const thenable: Thenable<any> = (newChild: any);
804 + const thenable: Thenable<any> = newChild as any;
805 const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
806 const created = createChild(
807 returnFiber,
@@ -814,7 +814,7 @@ function createChildReconciler(
814
815 // $FlowFixMe[invalid-compare]
816 if (newChild.$$typeof === REACT_CONTEXT_TYPE) {
817 - const context: ReactContext<mixed> = (newChild: any);
817 + const context: ReactContext<mixed> = newChild as any;
818 return createChild(
819 returnFiber,
820 readContextDuringReconciliation(returnFiber, context, lanes),
@@ -904,7 +904,7 @@ function createChildReconciler(
904 }
905 case REACT_LAZY_TYPE: {
906 const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
907 - const resolvedChild = resolveLazy((newChild: any));
907 + const resolvedChild = resolveLazy(newChild as any);
908 const updated = updateSlot(
909 returnFiber,
910 oldFiber,
@@ -942,8 +942,8 @@ function createChildReconciler(
942 //
943 // Unwrap the inner value and recursively call this function again.
944 if (typeof newChild.then === 'function') {
945 - const thenable: Thenable<any> = (newChild: any);
946 - const prevDebugInfo = pushDebugInfo((thenable: any)._debugInfo);
945 + const thenable: Thenable<any> = newChild as any;
946 + const prevDebugInfo = pushDebugInfo((thenable as any)._debugInfo);
947 const updated = updateSlot(
948 returnFiber,
949 oldFiber,
@@ -956,7 +956,7 @@ function createChildReconciler(
956
957 // $FlowFixMe[invalid-compare]
958 if (newChild.$$typeof === REACT_CONTEXT_TYPE) {
959 - const context: ReactContext<mixed> = (newChild: any);
959 + const context: ReactContext<mixed> = newChild as any;
960 return updateSlot(
961 returnFiber,
962 oldFiber,
@@ -1038,7 +1038,7 @@ function createChildReconciler(
1038 }
1039 case REACT_LAZY_TYPE: {
1040 const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
1041 - const resolvedChild = resolveLazy((newChild: any));
1041 + const resolvedChild = resolveLazy(newChild as any);
1042 const updated = updateFromMap(
1043 existingChildren,
1044 returnFiber,
@@ -1074,8 +1074,8 @@ function createChildReconciler(
1074 //
1075 // Unwrap the inner value and recursively call this function again.
1076 if (typeof newChild.then === 'function') {
1077 - const thenable: Thenable<any> = (newChild: any);
1078 - const prevDebugInfo = pushDebugInfo((thenable: any)._debugInfo);
1077 + const thenable: Thenable<any> = newChild as any;
1078 + const prevDebugInfo = pushDebugInfo((thenable as any)._debugInfo);
1079 const updated = updateFromMap(
1080 existingChildren,
1081 returnFiber,
@@ -1089,7 +1089,7 @@ function createChildReconciler(
1089
1090 // $FlowFixMe[invalid-compare]
1091 if (newChild.$$typeof === REACT_CONTEXT_TYPE) {
1092 - const context: ReactContext<mixed> = (newChild: any);
1092 + const context: ReactContext<mixed> = newChild as any;
1093 return updateFromMap(
1094 existingChildren,
1095 returnFiber,
@@ -1156,7 +1156,7 @@ function createChildReconciler(
1156 });
1157 break;
1158 case REACT_LAZY_TYPE: {
1159 - const resolvedChild = resolveLazy((child: any));
1159 + const resolvedChild = resolveLazy(child as any);
1160 warnOnInvalidKey(
1161 returnFiber,
1162 workInProgress,
@@ -1412,7 +1412,7 @@ function createChildReconciler(
1412 }
1413 didWarnAboutGenerators = true;
1414 }
1415 - } else if ((newChildrenIterable: any).entries === iteratorFn) {
1415 + } else if ((newChildrenIterable as any).entries === iteratorFn) {
1416 // Warn about using Maps as children
1417 if (!didWarnAboutMaps) {
1418 console.error(
@@ -1474,11 +1474,11 @@ function createChildReconciler(
1474
1475 // To save bytes, we reuse the logic by creating a synchronous Iterable and
1476 // reusing that code path.
1477 - const iterator: Iterator<mixed> = ({
1477 + const iterator: Iterator<mixed> = {
1478 next(): IteratorResult<mixed, void> {
1479 return unwrapThenable(newChildren.next());
1480 },
1481 - }: any);
1481 + } as any;
1482
1483 return reconcileChildrenIterator(
1484 returnFiber,
@@ -1906,7 +1906,7 @@ function createChildReconciler(
1906 );
1907 case REACT_LAZY_TYPE: {
1908 const prevDebugInfo = pushDebugInfo(newChild._debugInfo);
1909 - const result = resolveLazy((newChild: any));
1909 + const result = resolveLazy(newChild as any);
1910 const firstChild = reconcileChildFibersImpl(
1911 returnFiber,
1912 currentFirstChild,
@@ -1974,8 +1974,8 @@ function createChildReconciler(
1974 // depending on the type of work, not always at the end. We should
1975 // consider as an future improvement.
1976 if (typeof newChild.then === 'function') {
1977 - const thenable: Thenable<any> = (newChild: any);
1978 - const prevDebugInfo = pushDebugInfo((thenable: any)._debugInfo);
1977 + const thenable: Thenable<any> = newChild as any;
1978 + const prevDebugInfo = pushDebugInfo((thenable as any)._debugInfo);
1979 const firstChild = reconcileChildFibersImpl(
1980 returnFiber,
1981 currentFirstChild,
@@ -1988,7 +1988,7 @@ function createChildReconciler(
1988
1989 // $FlowFixMe[invalid-compare]
1990 if (newChild.$$typeof === REACT_CONTEXT_TYPE) {
1991 - const context: ReactContext<mixed> = (newChild: any);
1991 + const context: ReactContext<mixed> = newChild as any;
1992 return reconcileChildFibersImpl(
1993 returnFiber,
1994 currentFirstChild,
@@ -2089,7 +2089,7 @@ function createChildReconciler(
2089 if (debugInfo != null) {
2090 for (let i = debugInfo.length - 1; i >= 0; i--) {
2091 if (typeof debugInfo[i].stack === 'string') {
2092 - throwFiber._debugOwner = (debugInfo[i]: any);
2092 + throwFiber._debugOwner = debugInfo[i] as any;
2093 throwFiber._debugTask = debugInfo[i].debugTask;
2094 break;
2095 }
@@ -2161,7 +2161,7 @@ function validateSuspenseListNestedChild(childSlot: mixed, index: number) {
2161 enableAsyncIterableChildren &&
2162 typeof childSlot === 'object' &&
2163 childSlot !== null &&
2164 - typeof (childSlot: any)[ASYNC_ITERATOR] === 'function';
2164 + typeof (childSlot as any)[ASYNC_ITERATOR] === 'function';
2165 if (isAnArray || isIterable || isAsyncIterable) {
2166 const type = isAnArray
2167 ? 'array'
@@ -2220,7 +2220,7 @@ export function validateSuspenseListChildren(
2220 }
2221 } else if (
2222 enableAsyncIterableChildren &&
2223 - typeof (children: any)[ASYNC_ITERATOR] === 'function'
2223 + typeof (children as any)[ASYNC_ITERATOR] === 'function'
2224 ) {
2225 // TODO: Technically we should warn for nested arrays inside the
2226 // async iterable but it would require unwrapping the array.
packages/react-reconciler/src/ReactFiberApplyGesture.js
+3 -3
@@ -1252,9 +1252,9 @@ export function applyDepartureTransitions(
1252 if (cancelableChildren !== null) {
1253 for (let i = 0; i < cancelableChildren.length; i += 3) {
1254 cancelViewTransitionName(
1255 - ((cancelableChildren[i]: any): Instance),
1256 - ((cancelableChildren[i + 1]: any): string),
1257 - ((cancelableChildren[i + 2]: any): Props),
1255 + cancelableChildren[i] as any as Instance,
1256 + cancelableChildren[i + 1] as any as string,
1257 + cancelableChildren[i + 2] as any as Props,
1258 );
1259 }
1260 }
packages/react-reconciler/src/ReactFiberAsyncAction.js
+4 -4
@@ -122,7 +122,7 @@ function pingEngtangledActionScope() {
122 // and notify all the listeners.
123 if (currentEntangledActionThenable !== null) {
124 const fulfilledThenable: FulfilledThenable<void> =
125 - (currentEntangledActionThenable: any);
125 + currentEntangledActionThenable as any;
126 fulfilledThenable.status = 'fulfilled';
127 }
128 const listeners = currentEntangledListeners;
@@ -160,7 +160,7 @@ export function chainThenableValue<T>(
160 thenable.then(
161 (value: T) => {
162 const fulfilledThenable: FulfilledThenable<T> =
163 - (thenableWithOverride: any);
163 + thenableWithOverride as any;
164 fulfilledThenable.status = 'fulfilled';
165 fulfilledThenable.value = result;
166 for (let i = 0; i < listeners.length; i++) {
@@ -169,7 +169,7 @@ export function chainThenableValue<T>(
169 }
170 },
171 error => {
172 - const rejectedThenable: RejectedThenable<T> = (thenableWithOverride: any);
172 + const rejectedThenable: RejectedThenable<T> = thenableWithOverride as any;
173 rejectedThenable.status = 'rejected';
174 rejectedThenable.reason = error;
175 for (let i = 0; i < listeners.length; i++) {
@@ -179,7 +179,7 @@ export function chainThenableValue<T>(
179 // consumer of these promises, and it passes the same listener to both.
180 // We also know that it will read the error directly off the
181 // `.reason` field.
182 - listener((undefined: any));
182 + listener(undefined as any);
183 }
184 },
185 );
packages/react-reconciler/src/ReactFiberAsyncDispatcher.js
+3 -3
@@ -17,7 +17,7 @@ import {current as currentOwner} from './ReactCurrentFiber';
17
18 function getCacheForType<T>(resourceType: () => T): T {
19 const cache: Cache = readContext(CacheContext);
20 - let cacheForType: T | void = (cache.data.get(resourceType): any);
20 + let cacheForType: T | void = cache.data.get(resourceType) as any;
21 if (cacheForType === undefined) {
22 cacheForType = resourceType();
23 cache.data.set(resourceType, cacheForType);
@@ -30,10 +30,10 @@ function cacheSignal(): null | AbortSignal {
30 return cache.controller.signal;
31 }
32
33 -export const DefaultAsyncDispatcher: AsyncDispatcher = ({
33 +export const DefaultAsyncDispatcher: AsyncDispatcher = {
34 getCacheForType,
35 cacheSignal,
36 -}: any);
36 +} as any;
37
38 if (__DEV__) {
39 DefaultAsyncDispatcher.getOwner = (): null | Fiber => {
packages/react-reconciler/src/ReactFiberBeginWork.js
+41 -37
@@ -328,14 +328,14 @@ let didWarnAboutTailOptions;
328 let didWarnAboutClassNameOnViewTransition;
329
330 if (__DEV__) {
331 - didWarnAboutBadClass = ({}: {[string]: boolean});
332 - didWarnAboutContextTypeOnFunctionComponent = ({}: {[string]: boolean});
333 - didWarnAboutContextTypes = ({}: {[string]: boolean});
334 - didWarnAboutGetDerivedStateOnFunctionComponent = ({}: {[string]: boolean});
331 + didWarnAboutBadClass = {} as {[string]: boolean};
332 + didWarnAboutContextTypeOnFunctionComponent = {} as {[string]: boolean};
333 + didWarnAboutContextTypes = {} as {[string]: boolean};
334 + didWarnAboutGetDerivedStateOnFunctionComponent = {} as {[string]: boolean};
335 didWarnAboutReassigningProps = false;
336 - didWarnAboutRevealOrder = ({}: {[string]: boolean});
337 - didWarnAboutTailOptions = ({}: {[string]: boolean});
338 - didWarnAboutClassNameOnViewTransition = ({}: {[string]: boolean});
336 + didWarnAboutRevealOrder = {} as {[string]: boolean};
337 + didWarnAboutTailOptions = {} as {[string]: boolean};
338 + didWarnAboutClassNameOnViewTransition = {} as {[string]: boolean};
339 }
340
341 export function reconcileChildren(
@@ -421,7 +421,7 @@ function updateForwardRef(
421 // `ref` is just a prop now, but `forwardRef` expects it to not appear in
422 // the props object. This used to happen in the JSX runtime, but now we do
423 // it here.
424 - propsWithoutRef = ({}: {[string]: any});
424 + propsWithoutRef = {} as {[string]: any};
425 for (const key in nextProps) {
426 // Since `ref` should only appear in props via the JSX transform, we can
427 // assume that this is a plain object. So we don't need a
@@ -512,7 +512,7 @@ function updateMemoComponent(
512 workInProgress.child = child;
513 return child;
514 }
515 - const currentChild = ((current.child: any): Fiber); // This is always exactly one child
515 + const currentChild = current.child as any as Fiber; // This is always exactly one child
516 const hasScheduledUpdateOrContext = checkScheduledUpdateOrContext(
517 current,
518 renderLanes,
@@ -703,7 +703,7 @@ function updateOffscreenComponent(
703 }
704 reuseHiddenContextOnStack(workInProgress);
705 pushOffscreenSuspenseHandler(workInProgress);
706 - } else if (!includesSomeLane(renderLanes, (OffscreenLane: Lane))) {
706 + } else if (!includesSomeLane(renderLanes, OffscreenLane as Lane)) {
707 // We're hidden, and we're not rendering at Offscreen. We will bail out
708 // and resume this tree later.
709
@@ -894,7 +894,7 @@ function mountActivityChildren(
894 renderLanes: Lanes,
895 ) {
896 if (__DEV__) {
897 - const hiddenProp = (nextProps: any).hidden;
897 + const hiddenProp = (nextProps as any).hidden;
898 if (hiddenProp !== undefined) {
899 console.error(
900 '<Activity> doesn\'t accept a hidden prop. Use mode="hidden" instead.\n' +
@@ -992,7 +992,7 @@ function updateDehydratedActivityComponent(
992 // but after we've already committed once.
993 warnIfHydrating();
994
995 - if (includesSomeLane(renderLanes, (OffscreenLane: Lane))) {
995 + if (includesSomeLane(renderLanes, OffscreenLane as Lane)) {
996 // If we're rendering Offscreen and we're entering the activity then it's possible
997 // that the only reason we rendered was because this boundary left work. Provide
998 // it as a cause if another one doesn't already exist.
@@ -1098,7 +1098,9 @@ function updateDehydratedActivityComponent(
1098 workInProgress,
1099 renderLanes,
1100 );
1101 - } else if ((workInProgress.memoizedState: null | ActivityState) !== null) {
1101 + } else if (
1102 + (workInProgress.memoizedState as null | ActivityState) !== null
1103 + ) {
1104 // Something suspended and we should still be in dehydrated mode.
1105 // Leave the existing child in place.
1106
@@ -1181,7 +1183,7 @@ function updateActivityComponent(
1183 );
1184 }
1185
1184 - const currentChild: Fiber = (current.child: any);
1186 + const currentChild: Fiber = current.child as any;
1187
1188 const nextChildren = nextProps.children;
1189 const nextMode = nextProps.mode;
@@ -1191,7 +1193,7 @@ function updateActivityComponent(
1193 };
1194
1195 if (
1194 - includesSomeLane(renderLanes, (OffscreenLane: Lane)) &&
1196 + includesSomeLane(renderLanes, OffscreenLane as Lane) &&
1197 includesSomeLane(renderLanes, current.lanes)
1198 ) {
1199 // If we're rendering Offscreen and we're entering the activity then it's possible
@@ -1253,7 +1255,7 @@ function updateCacheComponent(
1255 // queue is empty, persist the derived state onto the base state.
1256 workInProgress.memoizedState = derivedState;
1257 if (workInProgress.lanes === NoLanes) {
1256 - const updateQueue: UpdateQueue<any> = (workInProgress.updateQueue: any);
1258 + const updateQueue: UpdateQueue<any> = workInProgress.updateQueue as any;
1259 workInProgress.memoizedState = updateQueue.baseState = derivedState;
1260 }
1261
@@ -1785,7 +1787,7 @@ function finishClassComponent(
1787 }
1788
1789 function pushHostRootContext(workInProgress: Fiber) {
1788 - const root = (workInProgress.stateNode: FiberRoot);
1790 + const root = workInProgress.stateNode as FiberRoot;
1791 if (root.pendingContext) {
1792 pushTopLevelContextObject(
1793 workInProgress,
@@ -1852,7 +1854,7 @@ function updateHostRoot(
1854 cache: nextState.cache,
1855 };
1856 const updateQueue: UpdateQueue<RootState> =
1855 - (workInProgress.updateQueue: any);
1857 + workInProgress.updateQueue as any;
1858 // `baseState` can always be the last state because the root doesn't
1859 // have reducer functions so it doesn't need rebasing.
1860 updateQueue.baseState = overrideState;
@@ -2336,7 +2338,7 @@ function shouldRemainOnFallback(
2338 const suspenseContext: SuspenseContext = suspenseStackCursor.current;
2339 return hasSuspenseListContext(
2340 suspenseContext,
2339 - (ForceSuspenseFallback: SuspenseContext),
2341 + ForceSuspenseFallback as SuspenseContext,
2342 );
2343 }
2344
@@ -2446,7 +2448,7 @@ function updateSuspenseComponent(
2448 nextFallbackChildren,
2449 renderLanes,
2450 );
2449 - const primaryChildFragment: Fiber = (workInProgress.child: any);
2451 + const primaryChildFragment: Fiber = workInProgress.child as any;
2452 primaryChildFragment.memoizedState =
2453 mountSuspenseOffscreenState(renderLanes);
2454 primaryChildFragment.childLanes = getRemainingWorkInPrimaryTree(
@@ -2460,7 +2462,7 @@ function updateSuspenseComponent(
2462 if (currentTransitions !== null) {
2463 const parentMarkerInstances = getMarkerInstances();
2464 const offscreenQueue: OffscreenQueue | null =
2463 - (primaryChildFragment.updateQueue: any);
2465 + primaryChildFragment.updateQueue as any;
2466 if (offscreenQueue === null) {
2467 const newOffscreenQueue: OffscreenQueue = {
2468 transitions: currentTransitions,
@@ -2487,7 +2489,7 @@ function updateSuspenseComponent(
2489 nextFallbackChildren,
2490 renderLanes,
2491 );
2490 - const primaryChildFragment: Fiber = (workInProgress.child: any);
2492 + const primaryChildFragment: Fiber = workInProgress.child as any;
2493 primaryChildFragment.memoizedState =
2494 mountSuspenseOffscreenState(renderLanes);
2495 primaryChildFragment.childLanes = getRemainingWorkInPrimaryTree(
@@ -2550,8 +2552,8 @@ function updateSuspenseComponent(
2552 nextFallbackChildren,
2553 renderLanes,
2554 );
2553 - const primaryChildFragment: Fiber = (workInProgress.child: any);
2554 - const prevOffscreenState: OffscreenState | null = (current.child: any)
2555 + const primaryChildFragment: Fiber = workInProgress.child as any;
2556 + const prevOffscreenState: OffscreenState | null = (current.child as any)
2557 .memoizedState;
2558 primaryChildFragment.memoizedState =
2559 prevOffscreenState === null
@@ -2562,9 +2564,9 @@ function updateSuspenseComponent(
2564 if (currentTransitions !== null) {
2565 const parentMarkerInstances = getMarkerInstances();
2566 const offscreenQueue: OffscreenQueue | null =
2565 - (primaryChildFragment.updateQueue: any);
2567 + primaryChildFragment.updateQueue as any;
2568 const currentOffscreenQueue: OffscreenQueue | null =
2567 - (current.updateQueue: any);
2569 + current.updateQueue as any;
2570 if (offscreenQueue === null) {
2571 const newOffscreenQueue: OffscreenQueue = {
2572 transitions: currentTransitions,
@@ -2734,7 +2736,7 @@ function updateSuspensePrimaryChildren(
2736 primaryChildren: $FlowFixMe,
2737 renderLanes: Lanes,
2738 ) {
2737 - const currentPrimaryChildFragment: Fiber = (current.child: any);
2739 + const currentPrimaryChildFragment: Fiber = current.child as any;
2740 const currentFallbackChildFragment: Fiber | null =
2741 currentPrimaryChildFragment.sibling;
2742
@@ -2773,7 +2775,7 @@ function updateSuspenseFallbackChildren(
2775 renderLanes: Lanes,
2776 ) {
2777 const mode = workInProgress.mode;
2776 - const currentPrimaryChildFragment: Fiber = (current.child: any);
2778 + const currentPrimaryChildFragment: Fiber = current.child as any;
2779 const currentFallbackChildFragment: Fiber | null =
2780 currentPrimaryChildFragment.sibling;
2781
@@ -2796,7 +2798,7 @@ function updateSuspenseFallbackChildren(
2798 // only codepath.)
2799 workInProgress.child !== currentPrimaryChildFragment
2800 ) {
2799 - const progressedPrimaryFragment: Fiber = (workInProgress.child: any);
2801 + const progressedPrimaryFragment: Fiber = workInProgress.child as any;
2802 primaryChildFragment = progressedPrimaryFragment;
2803 primaryChildFragment.childLanes = NoLanes;
2804 primaryChildFragment.pendingProps = primaryChildProps;
@@ -2965,7 +2967,7 @@ function updateDehydratedSuspenseComponent(
2967 // but after we've already committed once.
2968 warnIfHydrating();
2969
2968 - if (includesSomeLane(renderLanes, (OffscreenLane: Lane))) {
2970 + if (includesSomeLane(renderLanes, OffscreenLane as Lane)) {
2971 // If we're rendering Offscreen and we're entering the activity then it's possible
2972 // that the only reason we rendered was because this boundary left work. Provide
2973 // it as a cause if another one doesn't already exist.
@@ -3000,7 +3002,7 @@ function updateDehydratedSuspenseComponent(
3002 }
3003 // Replace the stack with the server stack
3004 error.stack = (__DEV__ && stack) || '';
3003 - (error: any).digest = digest;
3005 + (error as any).digest = digest;
3006 const capturedValue = createCapturedValueFromError(
3007 error,
3008 componentStack === undefined ? null : componentStack,
@@ -3135,7 +3137,9 @@ function updateDehydratedSuspenseComponent(
3137 workInProgress,
3138 renderLanes,
3139 );
3138 - } else if ((workInProgress.memoizedState: null | SuspenseState) !== null) {
3140 + } else if (
3141 + (workInProgress.memoizedState as null | SuspenseState) !== null
3142 + ) {
3143 // Something suspended and we should still be in dehydrated mode.
3144 // Leave the existing child in place.
3145
@@ -3161,7 +3165,7 @@ function updateDehydratedSuspenseComponent(
3165 nextFallbackChildren,
3166 renderLanes,
3167 );
3164 - const primaryChildFragment: Fiber = (workInProgress.child: any);
3168 + const primaryChildFragment: Fiber = workInProgress.child as any;
3169 primaryChildFragment.memoizedState =
3170 mountSuspenseOffscreenState(renderLanes);
3171 primaryChildFragment.childLanes = getRemainingWorkInPrimaryTree(
@@ -3364,7 +3368,7 @@ function initSuspenseListRenderState(
3368 const renderState: null | SuspenseListRenderState =
3369 workInProgress.memoizedState;
3370 if (renderState === null) {
3367 - workInProgress.memoizedState = ({
3371 + workInProgress.memoizedState = {
3372 isBackwards: isBackwards,
3373 rendering: null,
3374 renderingStartTime: 0,
@@ -3372,7 +3376,7 @@ function initSuspenseListRenderState(
3376 tail: tail,
3377 tailMode: tailMode,
3378 treeForkCount: treeForkCount,
3375 - }: SuspenseListRenderState);
3379 + } as SuspenseListRenderState;
3380 } else {
3381 // We can reuse the existing object from previous renders.
3382 renderState.isBackwards = isBackwards;
@@ -3424,7 +3428,7 @@ function updateSuspenseListComponent(
3428
3429 const shouldForceFallback = hasSuspenseListContext(
3430 suspenseContext,
3427 - (ForceSuspenseFallback: SuspenseContext),
3431 + ForceSuspenseFallback as SuspenseContext,
3432 );
3433 if (shouldForceFallback) {
3434 suspenseContext = setShallowSuspenseListContext(
@@ -4026,7 +4030,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
4030 workInProgress,
4031 renderLanes,
4032 );
4029 - const primaryChildFragment: Fiber = (workInProgress.child: any);
4033 + const primaryChildFragment: Fiber = workInProgress.child as any;
4034 const primaryChildLanes = primaryChildFragment.childLanes;
4035 if (
4036 contextChanged ||
packages/react-reconciler/src/ReactFiberCacheComponent.js
+4 -4
@@ -63,11 +63,11 @@ const {
63 export const CacheContext: ReactContext<Cache> = {
64 $$typeof: REACT_CONTEXT_TYPE,
65 // We don't use Consumer/Provider for Cache components. So we'll cheat.
66 - Consumer: (null: any),
67 - Provider: (null: any),
66 + Consumer: null as any,
67 + Provider: null as any,
68 // We'll initialize these at the root.
69 - _currentValue: (null: any),
70 - _currentValue2: (null: any),
69 + _currentValue: null as any,
70 + _currentValue2: null as any,
71 _threadCount: 0,
72 };
73
packages/react-reconciler/src/ReactFiberCallUserSpace.js
+18 -18
@@ -41,8 +41,8 @@ export const callComponentInDEV: <Props, Arg, R>(
41 secondArg: Arg,
42 ) => R = __DEV__
43 ? // We use this technique to trick minifiers to preserve the function name.
44 - (callComponent.react_stack_bottom_frame.bind(callComponent): any)
45 - : (null: any);
44 + (callComponent.react_stack_bottom_frame.bind(callComponent) as any)
45 + : (null as any);
46
47 interface ClassInstance<R> {
48 render(): R;
@@ -72,8 +72,8 @@ const callRender = {
72 export const callRenderInDEV: <R>(instance: ClassInstance<R>) => R => R =
73 __DEV__
74 ? // We use this technique to trick minifiers to preserve the function name.
75 - (callRender.react_stack_bottom_frame.bind(callRender): any)
76 - : (null: any);
75 + (callRender.react_stack_bottom_frame.bind(callRender) as any)
76 + : (null as any);
77
78 const callComponentDidMount = {
79 react_stack_bottom_frame: function (
@@ -95,8 +95,8 @@ export const callComponentDidMountInDEV: (
95 ? // We use this technique to trick minifiers to preserve the function name.
96 (callComponentDidMount.react_stack_bottom_frame.bind(
97 callComponentDidMount,
98 - ): any)
99 - : (null: any);
98 + ) as any)
99 + : (null as any);
100
101 const callComponentDidUpdate = {
102 react_stack_bottom_frame: function (
@@ -124,8 +124,8 @@ export const callComponentDidUpdateInDEV: (
124 ? // We use this technique to trick minifiers to preserve the function name.
125 (callComponentDidUpdate.react_stack_bottom_frame.bind(
126 callComponentDidUpdate,
127 - ): any)
128 - : (null: any);
127 + ) as any)
128 + : (null as any);
129
130 const callComponentDidCatch = {
131 react_stack_bottom_frame: function (
@@ -147,8 +147,8 @@ export const callComponentDidCatchInDEV: (
147 ? // We use this technique to trick minifiers to preserve the function name.
148 (callComponentDidCatch.react_stack_bottom_frame.bind(
149 callComponentDidCatch,
150 - ): any)
151 - : (null: any);
150 + ) as any)
151 + : (null as any);
152
153 const callComponentWillUnmount = {
154 react_stack_bottom_frame: function (
@@ -172,8 +172,8 @@ export const callComponentWillUnmountInDEV: (
172 ? // We use this technique to trick minifiers to preserve the function name.
173 (callComponentWillUnmount.react_stack_bottom_frame.bind(
174 callComponentWillUnmount,
175 - ): any)
176 - : (null: any);
175 + ) as any)
176 + : (null as any);
177
178 const callCreate = {
179 react_stack_bottom_frame: function (
@@ -189,8 +189,8 @@ const callCreate = {
189
190 export const callCreateInDEV: (effect: Effect) => (() => void) | void = __DEV__
191 ? // We use this technique to trick minifiers to preserve the function name.
192 - (callCreate.react_stack_bottom_frame.bind(callCreate): any)
193 - : (null: any);
192 + (callCreate.react_stack_bottom_frame.bind(callCreate) as any)
193 + : (null as any);
194
195 const callDestroy = {
196 react_stack_bottom_frame: function (
@@ -212,8 +212,8 @@ export const callDestroyInDEV: (
212 destroy: (() => void) | (({...}) => void),
213 ) => void = __DEV__
214 ? // We use this technique to trick minifiers to preserve the function name.
215 - (callDestroy.react_stack_bottom_frame.bind(callDestroy): any)
216 - : (null: any);
215 + (callDestroy.react_stack_bottom_frame.bind(callDestroy) as any)
216 + : (null as any);
217
218 const callLazyInit = {
219 react_stack_bottom_frame: function (lazy: LazyComponent<any, any>): any {
@@ -225,5 +225,5 @@ const callLazyInit = {
225
226 export const callLazyInitInDEV: (lazy: LazyComponent<any, any>) => any = __DEV__
227 ? // We use this technique to trick minifiers to preserve the function name.
228 - (callLazyInit.react_stack_bottom_frame.bind(callLazyInit): any)
229 - : (null: any);
228 + (callLazyInit.react_stack_bottom_frame.bind(callLazyInit) as any)
229 + : (null as any);
packages/react-reconciler/src/ReactFiberClassComponent.js
+3 -3
@@ -157,7 +157,7 @@ function applyDerivedStateFromProps(
157 // base state.
158 if (workInProgress.lanes === NoLanes) {
159 // Queue is always non-null for classes
160 - const updateQueue: UpdateQueue<any> = (workInProgress.updateQueue: any);
160 + const updateQueue: UpdateQueue<any> = workInProgress.updateQueue as any;
161 updateQueue.baseState = memoizedState;
162 }
163 }
@@ -574,7 +574,7 @@ function constructClassInstance(
574 }
575
576 if (typeof contextType === 'object' && contextType !== null) {
577 - context = readContext((contextType: any));
577 + context = readContext(contextType as any);
578 } else if (!disableLegacyContext) {
579 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
580 const contextTypes = ctor.contextTypes;
@@ -1192,7 +1192,7 @@ export function resolveClassComponentProps(
1192
1193 // Remove ref from the props object, if it exists.
1194 if ('ref' in baseProps) {
1195 - newProps = ({}: any);
1195 + newProps = {} as any;
1196 for (const propName in baseProps) {
1197 if (propName !== 'ref') {
1198 newProps[propName] = baseProps[propName];
packages/react-reconciler/src/ReactFiberClassUpdateQueue.js
+10 -10
@@ -193,8 +193,8 @@ export function cloneUpdateQueue<State>(
193 workInProgress: Fiber,
194 ): void {
195 // Clone the update queue from current. Unless it's already a clone.
196 - const queue: UpdateQueue<State> = (workInProgress.updateQueue: any);
197 - const currentQueue: UpdateQueue<State> = (current.updateQueue: any);
196 + const queue: UpdateQueue<State> = workInProgress.updateQueue as any;
197 + const currentQueue: UpdateQueue<State> = current.updateQueue as any;
198 if (queue === currentQueue) {
199 const clone: UpdateQueue<State> = {
200 baseState: currentQueue.baseState,
@@ -231,7 +231,7 @@ export function enqueueUpdate<State>(
231 return null;
232 }
233
234 - const sharedQueue: SharedQueue<State> = (updateQueue: any).shared;
234 + const sharedQueue: SharedQueue<State> = (updateQueue as any).shared;
235
236 if (__DEV__) {
237 if (
@@ -280,7 +280,7 @@ export function entangleTransitions(root: FiberRoot, fiber: Fiber, lane: Lane) {
280 return;
281 }
282
283 - const sharedQueue: SharedQueue<mixed> = (updateQueue: any).shared;
283 + const sharedQueue: SharedQueue<mixed> = (updateQueue as any).shared;
284 if (isTransitionLane(lane)) {
285 let queueLanes = sharedQueue.lanes;
286
@@ -308,12 +308,12 @@ export function enqueueCapturedUpdate<State>(
308 // Captured updates are updates that are thrown by a child during the render
309 // phase. They should be discarded if the render is aborted. Therefore,
310 // we should only put them on the work-in-progress queue, not the current one.
311 - let queue: UpdateQueue<State> = (workInProgress.updateQueue: any);
311 + let queue: UpdateQueue<State> = workInProgress.updateQueue as any;
312
313 // Check if the work-in-progress queue is a clone.
314 const current = workInProgress.alternate;
315 if (current !== null) {
316 - const currentQueue: UpdateQueue<State> = (current.updateQueue: any);
316 + const currentQueue: UpdateQueue<State> = current.updateQueue as any;
317 if (queue === currentQueue) {
318 // The work-in-progress queue is the same as current. This happens when
319 // we bail out on a parent fiber that then captures an error thrown by
@@ -493,7 +493,7 @@ export function processUpdateQueue<State>(
493 didReadFromEntangledAsyncAction = false;
494
495 // This is always non-null on a ClassComponent or HostRoot
496 - const queue: UpdateQueue<State> = (workInProgress.updateQueue: any);
496 + const queue: UpdateQueue<State> = workInProgress.updateQueue as any;
497
498 hasForceUpdate = false;
499
@@ -530,7 +530,7 @@ export function processUpdateQueue<State>(
530 const current = workInProgress.alternate;
531 if (current !== null) {
532 // This is always non-null on a ClassComponent or HostRoot
533 - const currentQueue: UpdateQueue<State> = (current.updateQueue: any);
533 + const currentQueue: UpdateQueue<State> = current.updateQueue as any;
534 const currentLastBaseUpdate = currentQueue.lastBaseUpdate;
535 if (currentLastBaseUpdate !== lastBaseUpdate) {
536 if (currentLastBaseUpdate === null) {
@@ -656,7 +656,7 @@ export function processUpdateQueue<State>(
656 // Intentionally unsound. Pending updates form a circular list, but we
657 // unravel them when transferring them to the base queue.
658 const firstPendingUpdate =
659 - ((lastPendingUpdate.next: any): Update<State>);
659 + lastPendingUpdate.next as any as Update<State>;
660 lastPendingUpdate.next = null;
661 update = firstPendingUpdate;
662 queue.lastBaseUpdate = lastPendingUpdate;
@@ -669,7 +669,7 @@ export function processUpdateQueue<State>(
669 newBaseState = newState;
670 }
671
672 - queue.baseState = ((newBaseState: any): State);
672 + queue.baseState = newBaseState as any as State;
673 queue.firstBaseUpdate = newFirstBaseUpdate;
674 queue.lastBaseUpdate = newLastBaseUpdate;
675
packages/react-reconciler/src/ReactFiberCommitEffects.js
+9 -9
@@ -144,7 +144,7 @@ export function commitHookEffectListMount(
144 ) {
145 try {
146 const updateQueue: FunctionComponentUpdateQueue | null =
147 - (finishedWork.updateQueue: any);
147 + finishedWork.updateQueue as any;
148 const lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
149 if (lastEffect !== null) {
150 const firstEffect = lastEffect.next;
@@ -253,7 +253,7 @@ export function commitHookEffectListUnmount(
253 ) {
254 try {
255 const updateQueue: FunctionComponentUpdateQueue | null =
256 - (finishedWork.updateQueue: any);
256 + finishedWork.updateQueue as any;
257 const lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
258 if (lastEffect !== null) {
259 const firstEffect = lastEffect.next;
@@ -519,7 +519,7 @@ export function commitClassCallbacks(finishedWork: Fiber) {
519 // TODO: I think this is now always non-null by the time it reaches the
520 // commit phase. Consider removing the type check.
521 const updateQueue: UpdateQueue<mixed> | null =
522 - (finishedWork.updateQueue: any);
522 + finishedWork.updateQueue as any;
523 if (updateQueue !== null) {
524 const instance = finishedWork.stateNode;
525 if (__DEV__) {
@@ -569,7 +569,7 @@ export function commitClassHiddenCallbacks(finishedWork: Fiber) {
569 // Commit any callbacks that would have fired while the component
570 // was hidden.
571 const updateQueue: UpdateQueue<mixed> | null =
572 - (finishedWork.updateQueue: any);
572 + finishedWork.updateQueue as any;
573 if (updateQueue !== null) {
574 const instance = finishedWork.stateNode;
575 try {
@@ -593,7 +593,7 @@ export function commitRootCallbacks(finishedWork: Fiber) {
593 // TODO: I think this is now always non-null by the time it reaches the
594 // commit phase. Consider removing the type check.
595 const updateQueue: UpdateQueue<mixed> | null =
596 - (finishedWork.updateQueue: any);
596 + finishedWork.updateQueue as any;
597 if (updateQueue !== null) {
598 let instance = null;
599 if (finishedWork.child !== null) {
@@ -682,7 +682,7 @@ export function commitClassSnapshot(finishedWork: Fiber, current: Fiber) {
682 prevState,
683 );
684 const didWarnSet =
685 - ((didWarnAboutUndefinedSnapshotBeforeUpdate: any): Set<mixed>);
685 + didWarnAboutUndefinedSnapshotBeforeUpdate as any as Set<mixed>;
686 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
687 didWarnSet.add(finishedWork.type);
688 runWithFiberInDEV(finishedWork, () => {
@@ -883,7 +883,7 @@ export function safelyDetachRef(
883 try {
884 startEffectTimer();
885 if (__DEV__) {
886 - (runWithFiberInDEV(current, ref, null): void);
886 + runWithFiberInDEV(current, ref, null) as void;
887 } else {
888 ref(null);
889 }
@@ -892,7 +892,7 @@ export function safelyDetachRef(
892 }
893 } else {
894 if (__DEV__) {
895 - (runWithFiberInDEV(current, ref, null): void);
895 + runWithFiberInDEV(current, ref, null) as void;
896 } else {
897 ref(null);
898 }
@@ -939,7 +939,7 @@ function commitProfiler(
939 commitStartTime: number,
940 effectDuration: number,
941 ) {
942 - const {id, onCommit, onRender} = (finishedWork.memoizedProps: ProfilerProps);
942 + const {id, onCommit, onRender} = finishedWork.memoizedProps as ProfilerProps;
943
944 let phase: ProfilerPhase = current === null ? 'mount' : 'update';
945 if (enableProfilerNestedUpdatePhase) {
packages/react-reconciler/src/ReactFiberCommitWork.js
+50 -50
@@ -333,7 +333,7 @@ function isHydratingParent(current: Fiber, finishedWork: Fiber): boolean {
333 );
334 } else if (finishedWork.tag === HostRoot) {
335 return (
336 - (current.memoizedState: RootState).isDehydrated &&
336 + (current.memoizedState as RootState).isDehydrated &&
337 (finishedWork.flags & ForceClientRender) === NoFlags
338 );
339 } else {
@@ -502,7 +502,7 @@ function commitBeforeMutationEffectsOnFiber(
502 case SimpleMemoComponent: {
503 if (!enableEffectEventMutationPhase && (flags & Update) !== NoFlags) {
504 const updateQueue: FunctionComponentUpdateQueue | null =
505 - (finishedWork.updateQueue: any);
505 + finishedWork.updateQueue as any;
506 const eventPayloads = updateQueue !== null ? updateQueue.events : null;
507 if (eventPayloads !== null) {
508 for (let ii = 0; ii < eventPayloads.length; ii++) {
@@ -579,7 +579,7 @@ function commitBeforeMutationEffectsDeletion(
579 // Maybe we can repurpose one of the subtreeFlags positions for this instead?
580 // Use it to store which part of the tree the focused instance is in?
581 // This assumes we can safely determine that instance during the "render" phase.
582 - if (doesFiberContain(deletion, ((focusedInstanceHandle: any): Fiber))) {
582 + if (doesFiberContain(deletion, focusedInstanceHandle as any as Fiber)) {
583 shouldFireAfterActiveInstanceBlur = true;
584 beforeActiveInstanceBlur(deletion);
585 }
@@ -928,9 +928,9 @@ function abortRootTransitions(
928 const rootTransitions = root.incompleteTransitions;
929 deletedTransitions.forEach(transition => {
930 if (rootTransitions.has(transition)) {
931 - const transitionInstance: TracingMarkerInstance = (rootTransitions.get(
931 + const transitionInstance: TracingMarkerInstance = rootTransitions.get(
932 transition,
933 - ): any);
933 + ) as any;
934 if (transitionInstance.aborts === null) {
935 transitionInstance.aborts = [];
936 }
@@ -1578,15 +1578,15 @@ function commitDeletionEffectsOnFiber(
1578 commitHostRemoveChildFromContainer(
1579 deletedFiber,
1580 nearestMountedAncestor,
1581 - ((hostParent: any): Container),
1582 - (deletedFiber.stateNode: Instance | TextInstance),
1581 + hostParent as any as Container,
1582 + deletedFiber.stateNode as Instance | TextInstance,
1583 );
1584 } else {
1585 commitHostRemoveChild(
1586 deletedFiber,
1587 nearestMountedAncestor,
1588 - ((hostParent: any): Instance),
1589 - (deletedFiber.stateNode: Instance | TextInstance),
1588 + hostParent as any as Instance,
1589 + deletedFiber.stateNode as Instance | TextInstance,
1590 );
1591 }
1592 }
@@ -1607,7 +1607,7 @@ function commitDeletionEffectsOnFiber(
1607 const onDeleted = hydrationCallbacks.onDeleted;
1608 if (onDeleted) {
1609 onDeleted(
1610 - (deletedFiber.stateNode: SuspenseInstance | ActivityInstance),
1610 + deletedFiber.stateNode as SuspenseInstance | ActivityInstance,
1611 );
1612 }
1613 } catch (error) {
@@ -1628,13 +1628,13 @@ function commitDeletionEffectsOnFiber(
1628 if (hostParent !== null) {
1629 if (hostParentIsContainer) {
1630 clearSuspenseBoundaryFromContainer(
1631 - ((hostParent: any): Container),
1632 - (deletedFiber.stateNode: SuspenseInstance),
1631 + hostParent as any as Container,
1632 + deletedFiber.stateNode as SuspenseInstance,
1633 );
1634 } else {
1635 clearSuspenseBoundary(
1636 - ((hostParent: any): Instance),
1637 - (deletedFiber.stateNode: SuspenseInstance),
1636 + hostParent as any as Instance,
1637 + deletedFiber.stateNode as SuspenseInstance,
1638 );
1639 }
1640 }
@@ -1831,7 +1831,7 @@ function commitSuspenseCallback(finishedWork: Fiber) {
1831 if (enableSuspenseCallback && newState !== null) {
1832 const suspenseCallback = finishedWork.memoizedProps.suspenseCallback;
1833 if (typeof suspenseCallback === 'function') {
1834 - const retryQueue: RetryQueue | null = (finishedWork.updateQueue: any);
1834 + const retryQueue: RetryQueue | null = finishedWork.updateQueue as any;
1835 if (retryQueue !== null) {
1836 suspenseCallback(new Set(retryQueue));
1837 }
@@ -2067,7 +2067,7 @@ function commitMutationEffectsOnFiber(
2067 if (enableEffectEventMutationPhase) {
2068 if (flags & Update) {
2069 const updateQueue: FunctionComponentUpdateQueue | null =
2070 - (finishedWork.updateQueue: any);
2070 + finishedWork.updateQueue as any;
2071 const eventPayloads =
2072 updateQueue !== null ? updateQueue.events : null;
2073 if (eventPayloads !== null) {
@@ -2109,7 +2109,7 @@ function commitMutationEffectsOnFiber(
2109
2110 if (flags & Callback && offscreenSubtreeIsHidden) {
2111 const updateQueue: UpdateQueue<mixed> | null =
2112 - (finishedWork.updateQueue: any);
2112 + finishedWork.updateQueue as any;
2113 if (updateQueue !== null) {
2114 deferHiddenCallbacks(updateQueue);
2115 }
@@ -2121,7 +2121,7 @@ function commitMutationEffectsOnFiber(
2121 if (supportsResources) {
2122 // We cast because we always set the root at the React root and so it cannot be
2123 // null while we are processing mutation effects
2124 - const hoistableRoot: HoistableRoot = (currentHoistableRoot: any);
2124 + const hoistableRoot: HoistableRoot = currentHoistableRoot as any;
2125 recursivelyTraverseMutationEffects(root, finishedWork, lanes);
2126 commitReconciliationEffects(finishedWork, lanes);
2127
@@ -2449,7 +2449,7 @@ function commitMutationEffectsOnFiber(
2449 recursivelyTraverseMutationEffects(root, finishedWork, lanes);
2450 commitReconciliationEffects(finishedWork, lanes);
2451 if (flags & Update) {
2452 - const retryQueue: RetryQueue | null = (finishedWork.updateQueue: any);
2452 + const retryQueue: RetryQueue | null = finishedWork.updateQueue as any;
2453 if (retryQueue !== null) {
2454 finishedWork.updateQueue = null;
2455 attachSuspenseRetryListeners(finishedWork, retryQueue);
@@ -2472,14 +2472,14 @@ function commitMutationEffectsOnFiber(
2472 //
2473 // Also, all this logic could/should move to the passive phase so it
2474 // doesn't block paint.
2475 - const offscreenFiber: Fiber = (finishedWork.child: any);
2475 + const offscreenFiber: Fiber = finishedWork.child as any;
2476 if (offscreenFiber.flags & Visibility) {
2477 // Throttle the appearance and disappearance of Suspense fallbacks.
2478 const isShowingFallback =
2479 - (finishedWork.memoizedState: SuspenseState | null) !== null;
2479 + (finishedWork.memoizedState as SuspenseState | null) !== null;
2480 const wasShowingFallback =
2481 current !== null &&
2482 - (current.memoizedState: SuspenseState | null) !== null;
2482 + (current.memoizedState as SuspenseState | null) !== null;
2483
2484 if (alwaysThrottleRetries) {
2485 if (isShowingFallback !== wasShowingFallback) {
@@ -2501,7 +2501,7 @@ function commitMutationEffectsOnFiber(
2501 } catch (error) {
2502 captureCommitPhaseError(finishedWork, finishedWork.return, error);
2503 }
2504 - const retryQueue: RetryQueue | null = (finishedWork.updateQueue: any);
2504 + const retryQueue: RetryQueue | null = finishedWork.updateQueue as any;
2505 if (retryQueue !== null) {
2506 finishedWork.updateQueue = null;
2507 attachSuspenseRetryListeners(finishedWork, retryQueue);
@@ -2617,7 +2617,7 @@ function commitMutationEffectsOnFiber(
2617 // TODO: Move to passive phase
2618 if (flags & Update) {
2619 const offscreenQueue: OffscreenQueue | null =
2620 - (finishedWork.updateQueue: any);
2620 + finishedWork.updateQueue as any;
2621 if (offscreenQueue !== null) {
2622 const retryQueue = offscreenQueue.retryQueue;
2623 if (retryQueue !== null) {
@@ -2634,7 +2634,7 @@ function commitMutationEffectsOnFiber(
2634
2635 if (flags & Update) {
2636 const retryQueue: Set<Wakeable> | null =
2637 - (finishedWork.updateQueue: any);
2637 + finishedWork.updateQueue as any;
2638 if (retryQueue !== null) {
2639 finishedWork.updateQueue = null;
2640 attachSuspenseRetryListeners(finishedWork, retryQueue);
@@ -2863,9 +2863,9 @@ function commitAfterMutationEffectsOnFiber(
2863 if (cancelableChildren !== null) {
2864 for (let i = 0; i < cancelableChildren.length; i += 3) {
2865 cancelViewTransitionName(
2866 - ((cancelableChildren[i]: any): Instance),
2867 - ((cancelableChildren[i + 1]: any): string),
2868 - ((cancelableChildren[i + 2]: any): Props),
2866 + cancelableChildren[i] as any as Instance,
2867 + cancelableChildren[i + 1] as any as string,
2868 + cancelableChildren[i + 2] as any as Props,
2869 );
2870 }
2871 }
@@ -3429,7 +3429,7 @@ function commitOffscreenPassiveMountEffects(
3429 // may add separate logs for pre-rendering, but it's not part of the
3430 // primary metrics.
3431 const offscreenState: OffscreenState = finishedWork.memoizedState;
3432 - const queue: OffscreenQueue | null = (finishedWork.updateQueue: any);
3432 + const queue: OffscreenQueue | null = finishedWork.updateQueue as any;
3433
3434 // $FlowFixMe[invalid-compare]
3435 const isHidden = offscreenState !== null;
@@ -3579,7 +3579,7 @@ function recursivelyTraversePassiveMountEffects(
3579 committedLanes,
3580 committedTransitions,
3581 nextSibling !== null
3582 - ? ((nextSibling.actualStartTime: any): number)
3582 + ? (nextSibling.actualStartTime as any as number)
3583 : endTime,
3584 );
3585 child = nextSibling;
@@ -3653,12 +3653,12 @@ function commitPassiveMountOnFiber(
3653 enableProfilerTimer &&
3654 enableComponentPerformanceTrack &&
3655 (finishedWork.mode & ProfileMode) !== NoMode &&
3656 - ((finishedWork.actualStartTime: any): number) > 0 &&
3656 + (finishedWork.actualStartTime as any as number) > 0 &&
3657 (finishedWork.flags & PerformedWork) !== NoFlags
3658 ) {
3659 logComponentRender(
3660 finishedWork,
3661 - ((finishedWork.actualStartTime: any): number),
3661 + finishedWork.actualStartTime as any as number,
3662 endTime,
3663 inHydratedSubtree,
3664 committedLanes,
@@ -3689,12 +3689,12 @@ function commitPassiveMountOnFiber(
3689 enableProfilerTimer &&
3690 enableComponentPerformanceTrack &&
3691 (finishedWork.mode & ProfileMode) !== NoMode &&
3692 - ((finishedWork.actualStartTime: any): number) > 0
3692 + (finishedWork.actualStartTime as any as number) > 0
3693 ) {
3694 if ((finishedWork.flags & DidCapture) !== NoFlags) {
3695 logComponentErrored(
3696 finishedWork,
3697 - ((finishedWork.actualStartTime: any): number),
3697 + finishedWork.actualStartTime as any as number,
3698 endTime,
3699 // TODO: The captured values are all hidden inside the updater/callback closures so
3700 // we can't get to the errors but they're there so we should be able to log them.
@@ -3703,7 +3703,7 @@ function commitPassiveMountOnFiber(
3703 } else if ((finishedWork.flags & PerformedWork) !== NoFlags) {
3704 logComponentRender(
3705 finishedWork,
3706 - ((finishedWork.actualStartTime: any): number),
3706 + finishedWork.actualStartTime as any as number,
3707 endTime,
3708 inHydratedSubtree,
3709 committedLanes,
@@ -3729,7 +3729,7 @@ function commitPassiveMountOnFiber(
3729 // dehydrated and this wasn't a forced client render.
3730 inHydratedSubtree =
3731 finishedWork.alternate !== null &&
3732 - (finishedWork.alternate.memoizedState: RootState).isDehydrated &&
3732 + (finishedWork.alternate.memoizedState as RootState).isDehydrated &&
3733 (finishedWork.flags & ForceClientRender) === NoFlags;
3734 }
3735
@@ -3871,7 +3871,7 @@ function commitPassiveMountOnFiber(
3871 // If there were no hydration errors, that suggests that this was an intentional client
3872 // rendered boundary.
3873 if (hydrationErrors !== null) {
3874 - const startTime: number = (finishedWork.actualStartTime: any);
3874 + const startTime: number = finishedWork.actualStartTime as any;
3875 logComponentErrored(
3876 finishedWork,
3877 startTime,
@@ -3929,7 +3929,7 @@ function commitPassiveMountOnFiber(
3929 // If there were no hydration errors, that suggests that this was an intentional client
3930 // rendered boundary.
3931 if (hydrationErrors !== null) {
3932 - const startTime: number = (finishedWork.actualStartTime: any);
3932 + const startTime: number = finishedWork.actualStartTime as any;
3933 logComponentErrored(
3934 finishedWork,
3935 startTime,
@@ -4082,7 +4082,7 @@ function commitPassiveMountOnFiber(
4082 !inHydratedSubtree
4083 ) {
4084 // Log the reappear in the render phase.
4085 - const startTime = ((finishedWork.actualStartTime: any): number);
4085 + const startTime = finishedWork.actualStartTime as any as number;
4086 if (startTime >= 0 && endTime - startTime > 0.05) {
4087 logComponentReappeared(finishedWork, startTime, endTime);
4088 }
@@ -4187,7 +4187,7 @@ function commitPassiveMountOnFiber(
4187 finishedWork.return.alternate !== null;
4188 if (isMount) {
4189 // Log the mount in the render phase.
4190 - const startTime = ((finishedWork.actualStartTime: any): number);
4190 + const startTime = finishedWork.actualStartTime as any as number;
4191 if (startTime >= 0 && endTime - startTime > 0.05) {
4192 logComponentMount(finishedWork, startTime, endTime);
4193 }
@@ -4251,7 +4251,7 @@ function recursivelyTraverseReconnectPassiveEffects(
4251 committedTransitions,
4252 childShouldIncludeWorkInProgressEffects,
4253 nextSibling !== null
4254 - ? ((nextSibling.actualStartTime: any): number)
4254 + ? (nextSibling.actualStartTime as any as number)
4255 : endTime,
4256 );
4257 child = nextSibling;
@@ -4295,12 +4295,12 @@ export function reconnectPassiveEffects(
4295 enableComponentPerformanceTrack &&
4296 includeWorkInProgressEffects &&
4297 (finishedWork.mode & ProfileMode) !== NoMode &&
4298 - ((finishedWork.actualStartTime: any): number) > 0 &&
4298 + (finishedWork.actualStartTime as any as number) > 0 &&
4299 (finishedWork.flags & PerformedWork) !== NoFlags
4300 ) {
4301 logComponentRender(
4302 finishedWork,
4303 - ((finishedWork.actualStartTime: any): number),
4303 + finishedWork.actualStartTime as any as number,
4304 endTime,
4305 inHydratedSubtree,
4306 committedLanes,
@@ -4521,7 +4521,7 @@ function recursivelyTraverseAtomicPassiveEffects(
4521 committedLanes,
4522 committedTransitions,
4523 nextSibling !== null
4524 - ? ((nextSibling.actualStartTime: any): number)
4524 + ? (nextSibling.actualStartTime as any as number)
4525 : endTime,
4526 );
4527 child = nextSibling;
@@ -4554,12 +4554,12 @@ function commitAtomicPassiveEffects(
4554 enableProfilerTimer &&
4555 enableComponentPerformanceTrack &&
4556 (finishedWork.mode & ProfileMode) !== NoMode &&
4557 - ((finishedWork.actualStartTime: any): number) > 0 &&
4557 + (finishedWork.actualStartTime as any as number) > 0 &&
4558 (finishedWork.flags & PerformedWork) !== NoFlags
4559 ) {
4560 logComponentRender(
4561 finishedWork,
4562 - ((finishedWork.actualStartTime: any): number),
4562 + finishedWork.actualStartTime as any as number,
4563 endTime,
4564 inHydratedSubtree,
4565 committedLanes,
@@ -4681,7 +4681,7 @@ function accumulateSuspenseyCommitOnFiber(
4681 suspendResource(
4682 suspendedState,
4683 // This should always be set by visiting HostRoot first
4684 - (currentHoistableRoot: any),
4684 + currentHoistableRoot as any,
4685 fiber.memoizedState,
4686 fiber.memoizedProps,
4687 );
@@ -4744,14 +4744,14 @@ function accumulateSuspenseyCommitOnFiber(
4744 break;
4745 }
4746 case OffscreenComponent: {
4747 - const isHidden = (fiber.memoizedState: OffscreenState | null) !== null;
4747 + const isHidden = (fiber.memoizedState as OffscreenState | null) !== null;
4748 if (isHidden) {
4749 // Don't suspend in hidden trees
4750 } else {
4751 const current = fiber.alternate;
4752 const wasHidden =
4753 current !== null &&
4754 - (current.memoizedState: OffscreenState | null) !== null;
4754 + (current.memoizedState as OffscreenState | null) !== null;
4755 if (wasHidden) {
4756 // This tree is being revealed. Visit all newly visible suspensey
4757 // instances, even if they're in the current tree.
@@ -5210,7 +5210,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
5210 case SuspenseComponent: {
5211 if (enableTransitionTracing) {
5212 // We need to mark this fiber's parents as deleted
5213 - const offscreenFiber: Fiber = (current.child: any);
5213 + const offscreenFiber: Fiber = current.child as any;
5214 const instance: OffscreenInstance = offscreenFiber.stateNode;
5215 const transitions = instance._transitions;
5216 if (transitions !== null) {
packages/react-reconciler/src/ReactFiberCompleteWork.js
+18 -18
@@ -411,7 +411,7 @@ function appendAllChildrenToContainer(
411 node = node.child;
412 continue;
413 }
414 - node = (node: Fiber);
414 + node = node as Fiber;
415 if (node === workInProgress) {
416 return hasOffscreenComponentChild;
417 }
@@ -802,7 +802,7 @@ function bubbleProperties(completedWork: Fiber) {
802 // In profiling mode, resetChildExpirationTime is also used to reset
803 // profiler durations.
804 let actualDuration = completedWork.actualDuration;
805 - let treeBaseDuration = ((completedWork.selfBaseDuration: any): number);
805 + let treeBaseDuration = completedWork.selfBaseDuration as any as number;
806
807 let child = completedWork.child;
808 while (child !== null) {
@@ -857,7 +857,7 @@ function bubbleProperties(completedWork: Fiber) {
857 if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) {
858 // In profiling mode, resetChildExpirationTime is also used to reset
859 // profiler durations.
860 - let treeBaseDuration = ((completedWork.selfBaseDuration: any): number);
860 + let treeBaseDuration = completedWork.selfBaseDuration as any as number;
861
862 let child = completedWork.child;
863 while (child !== null) {
@@ -940,7 +940,7 @@ function completeDehydratedActivityBoundary(
940 if (primaryChildFragment !== null) {
941 // $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
942 workInProgress.treeBaseDuration -=
943 - ((primaryChildFragment.treeBaseDuration: any): number);
943 + primaryChildFragment.treeBaseDuration as any as number;
944 }
945 }
946 }
@@ -971,7 +971,7 @@ function completeDehydratedActivityBoundary(
971 if (primaryChildFragment !== null) {
972 // $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
973 workInProgress.treeBaseDuration -=
974 - ((primaryChildFragment.treeBaseDuration: any): number);
974 + primaryChildFragment.treeBaseDuration as any as number;
975 }
976 }
977 }
@@ -1023,7 +1023,7 @@ function completeDehydratedSuspenseBoundary(
1023 if (primaryChildFragment !== null) {
1024 // $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
1025 workInProgress.treeBaseDuration -=
1026 - ((primaryChildFragment.treeBaseDuration: any): number);
1026 + primaryChildFragment.treeBaseDuration as any as number;
1027 }
1028 }
1029 }
@@ -1054,7 +1054,7 @@ function completeDehydratedSuspenseBoundary(
1054 if (primaryChildFragment !== null) {
1055 // $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
1056 workInProgress.treeBaseDuration -=
1057 - ((primaryChildFragment.treeBaseDuration: any): number);
1057 + primaryChildFragment.treeBaseDuration as any as number;
1058 }
1059 }
1060 }
@@ -1115,7 +1115,7 @@ function completeWork(
1115 return null;
1116 }
1117 case HostRoot: {
1118 - const fiberRoot = (workInProgress.stateNode: FiberRoot);
1118 + const fiberRoot = workInProgress.stateNode as FiberRoot;
1119
1120 if (enableTransitionTracing) {
1121 const transitions = getWorkInProgressTransitions();
@@ -1598,10 +1598,10 @@ function completeWork(
1598 const nextDidTimeout = nextState !== null;
1599 const prevDidTimeout =
1600 current !== null &&
1601 - (current.memoizedState: null | SuspenseState) !== null;
1601 + (current.memoizedState as null | SuspenseState) !== null;
1602
1603 if (nextDidTimeout) {
1604 - const offscreenFiber: Fiber = (workInProgress.child: any);
1604 + const offscreenFiber: Fiber = workInProgress.child as any;
1605 let previousCache: Cache | null = null;
1606 if (
1607 offscreenFiber.alternate !== null &&
@@ -1627,7 +1627,7 @@ function completeWork(
1627 // a passive effect, which is when we process the transitions
1628 if (nextDidTimeout !== prevDidTimeout) {
1629 if (enableTransitionTracing) {
1630 - const offscreenFiber: Fiber = (workInProgress.child: any);
1630 + const offscreenFiber: Fiber = workInProgress.child as any;
1631 offscreenFiber.flags |= Passive;
1632 }
1633
@@ -1643,12 +1643,12 @@ function completeWork(
1643 // phase will handle scheduling the effect. It's only when the fallback
1644 // is active that we have to do anything special.
1645 if (nextDidTimeout) {
1646 - const offscreenFiber: Fiber = (workInProgress.child: any);
1646 + const offscreenFiber: Fiber = workInProgress.child as any;
1647 offscreenFiber.flags |= Visibility;
1648 }
1649 }
1650
1651 - const retryQueue: RetryQueue | null = (workInProgress.updateQueue: any);
1651 + const retryQueue: RetryQueue | null = workInProgress.updateQueue as any;
1652 scheduleRetryEffect(workInProgress, retryQueue);
1653
1654 if (
@@ -1669,7 +1669,7 @@ function completeWork(
1669 if (primaryChildFragment !== null) {
1670 // $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
1671 workInProgress.treeBaseDuration -=
1672 - ((primaryChildFragment.treeBaseDuration: any): number);
1672 + primaryChildFragment.treeBaseDuration as any as number;
1673 }
1674 }
1675 }
@@ -1759,7 +1759,7 @@ function completeWork(
1759 // doesn't matter since that means that the other boundaries that
1760 // we did find already has their listeners attached.
1761 const retryQueue: RetryQueue | null =
1762 - (suspended.updateQueue: any);
1762 + suspended.updateQueue as any;
1763 workInProgress.updateQueue = retryQueue;
1764 scheduleRetryEffect(workInProgress, retryQueue);
1765
@@ -1823,7 +1823,7 @@ function completeWork(
1823
1824 // Ensure we transfer the update queue to the parent so that it doesn't
1825 // get lost if this row ends up dropped during a second pass.
1826 - const retryQueue: RetryQueue | null = (suspended.updateQueue: any);
1826 + const retryQueue: RetryQueue | null = suspended.updateQueue as any;
1827 workInProgress.updateQueue = retryQueue;
1828 scheduleRetryEffect(workInProgress, retryQueue);
1829
@@ -1997,7 +1997,7 @@ function completeWork(
1997 // Don't bubble properties for hidden children unless we're rendering
1998 // at offscreen priority.
1999 if (
2000 - includesSomeLane(renderLanes, (OffscreenLane: Lane)) &&
2000 + includesSomeLane(renderLanes, OffscreenLane as Lane) &&
2001 // Also don't bubble if the tree suspended
2002 (workInProgress.flags & DidCapture) === NoLanes
2003 ) {
@@ -2016,7 +2016,7 @@ function completeWork(
2016 }
2017
2018 const offscreenQueue: OffscreenQueue | null =
2019 - (workInProgress.updateQueue: any);
2019 + workInProgress.updateQueue as any;
2020 if (offscreenQueue !== null) {
2021 const retryQueue = offscreenQueue.retryQueue;
2022 scheduleRetryEffect(workInProgress, retryQueue);
packages/react-reconciler/src/ReactFiberComponentStack.js
+2 -2
@@ -120,7 +120,7 @@ export function getOwnerStackByFiberInDev(workInProgress: Fiber): string {
120 if (workInProgress.tag === HostText) {
121 // Text nodes never have an owner/stack because they're not created through JSX.
122 // We use the parent since text nodes are always created through a host parent.
123 - workInProgress = (workInProgress.return: any);
123 + workInProgress = workInProgress.return as any;
124 }
125
126 // The owner stack of the current fiber will be where it was created, i.e. inside its owner.
@@ -175,7 +175,7 @@ export function getOwnerStackByFiberInDev(workInProgress: Fiber): string {
175
176 while (owner) {
177 if (typeof owner.tag === 'number') {
178 - const fiber: Fiber = (owner: any);
178 + const fiber: Fiber = owner as any;
179 owner = fiber._debugOwner;
180 const debugStack = fiber._debugStack;
181 // If we don't actually print the stack if there is no owner of this JSX element.
packages/react-reconciler/src/ReactFiberConcurrentUpdates.js
+7 -7
@@ -118,8 +118,8 @@ export function enqueueConcurrentHookUpdate<S, A>(
118 update: HookUpdate<S, A>,
119 lane: Lane,
120 ): FiberRoot | null {
121 - const concurrentQueue: ConcurrentQueue = (queue: any);
122 - const concurrentUpdate: ConcurrentUpdate = (update: any);
121 + const concurrentQueue: ConcurrentQueue = queue as any;
122 + const concurrentUpdate: ConcurrentUpdate = update as any;
123 enqueueUpdate(fiber, concurrentQueue, concurrentUpdate, lane);
124 return getRootForUpdatedFiber(fiber);
125 }
@@ -133,8 +133,8 @@ export function enqueueConcurrentHookUpdateAndEagerlyBailout<S, A>(
133 // only reason we queue it is in case there's a subsequent higher priority
134 // update that causes it to be rebased.
135 const lane = NoLane;
136 - const concurrentQueue: ConcurrentQueue = (queue: any);
137 - const concurrentUpdate: ConcurrentUpdate = (update: any);
136 + const concurrentQueue: ConcurrentQueue = queue as any;
137 + const concurrentUpdate: ConcurrentUpdate = update as any;
138 enqueueUpdate(fiber, concurrentQueue, concurrentUpdate, lane);
139
140 // Usually we can rely on the upcoming render phase to process the concurrent
@@ -156,8 +156,8 @@ export function enqueueConcurrentClassUpdate<State>(
156 update: ClassUpdate<State>,
157 lane: Lane,
158 ): FiberRoot | null {
159 - const concurrentQueue: ConcurrentQueue = (queue: any);
160 - const concurrentUpdate: ConcurrentUpdate = (update: any);
159 + const concurrentQueue: ConcurrentQueue = queue as any;
160 + const concurrentUpdate: ConcurrentUpdate = update as any;
161 enqueueUpdate(fiber, concurrentQueue, concurrentUpdate, lane);
162 return getRootForUpdatedFiber(fiber);
163 }
@@ -272,7 +272,7 @@ function getRootForUpdatedFiber(sourceFiber: Fiber): FiberRoot | null {
272 node = parent;
273 parent = node.return;
274 }
275 - return node.tag === HostRoot ? (node.stateNode: FiberRoot) : null;
275 + return node.tag === HostRoot ? (node.stateNode as FiberRoot) : null;
276 }
277
278 function detectUpdateOnUnmountedFiber(sourceFiber: Fiber, parent: Fiber) {
packages/react-reconciler/src/ReactFiberDuplicateViewTransitions.js
+4 -4
@@ -18,12 +18,12 @@ import {runWithFiberInDEV} from './ReactCurrentFiber';
18 // assigned view-transition-name outside React too.
19 const mountedNamedViewTransitions: Map<string, Fiber> = __DEV__
20 ? new Map()
21 - : (null: any);
22 -const didWarnAboutName: {[string]: boolean} = __DEV__ ? {} : (null: any);
21 + : (null as any);
22 +const didWarnAboutName: {[string]: boolean} = __DEV__ ? {} : (null as any);
23
24 export function trackNamedViewTransition(fiber: Fiber): void {
25 if (__DEV__) {
26 - const name = (fiber.memoizedProps: ViewTransitionProps).name;
26 + const name = (fiber.memoizedProps as ViewTransitionProps).name;
27 if (name != null && name !== 'auto') {
28 const existing = mountedNamedViewTransitions.get(name);
29 if (existing !== undefined) {
@@ -57,7 +57,7 @@ export function trackNamedViewTransition(fiber: Fiber): void {
57
58 export function untrackNamedViewTransition(fiber: Fiber): void {
59 if (__DEV__) {
60 - const name = (fiber.memoizedProps: ViewTransitionProps).name;
60 + const name = (fiber.memoizedProps as ViewTransitionProps).name;
61 if (name != null && name !== 'auto') {
62 const existing = mountedNamedViewTransitions.get(name);
63 if (
packages/react-reconciler/src/ReactFiberErrorLogger.js
+2 -2
@@ -138,7 +138,7 @@ export function logUncaughtError(
138 : null;
139 errorBoundaryName = null;
140 }
141 - const error = (errorInfo.value: any);
141 + const error = errorInfo.value as any;
142 if (__DEV__ && ReactSharedInternals.actQueue !== null) {
143 // For uncaught errors inside act, we track them on the act and then
144 // rethrow them into the test.
@@ -172,7 +172,7 @@ export function logCaughtError(
172 : null;
173 errorBoundaryName = getComponentNameFromFiber(boundary);
174 }
175 - const error = (errorInfo.value: any);
175 + const error = errorInfo.value as any;
176 const onCaughtError = root.onCaughtError;
177 onCaughtError(error, {
178 componentStack: errorInfo.stack,
packages/react-reconciler/src/ReactFiberHooks.js
+76 -77
@@ -258,7 +258,7 @@ type Dispatch<A> = A => void;
258 let renderLanes: Lanes = NoLanes;
259 // The work-in-progress fiber. I've named it differently to distinguish it from
260 // the work-in-progress hook.
261 -let currentlyRenderingFiber: Fiber = (null: any);
261 +let currentlyRenderingFiber: Fiber = null as any;
262
263 // Hooks are stored as a linked list on the fiber's memoizedState field. The
264 // current hook list is the list that belongs to the current fiber. The
@@ -307,7 +307,7 @@ let ignorePreviousDependencies: boolean = false;
307
308 function mountHookTypesDev(): void {
309 if (__DEV__) {
310 - const hookName = ((currentHookNameInDev: any): HookType);
310 + const hookName = currentHookNameInDev as any as HookType;
311
312 if (hookTypesDev === null) {
313 hookTypesDev = [hookName];
@@ -319,7 +319,7 @@ function mountHookTypesDev(): void {
319
320 function updateHookTypesDev(): void {
321 if (__DEV__) {
322 - const hookName = ((currentHookNameInDev: any): HookType);
322 + const hookName = currentHookNameInDev as any as HookType;
323
324 if (hookTypesDev !== null) {
325 hookTypesUpdateIndexDev++;
@@ -356,10 +356,10 @@ function warnOnHookMismatchInDev(currentHookName: HookType): void {
356
357 const secondColumnStart = 30;
358
359 - for (let i = 0; i <= ((hookTypesUpdateIndexDev: any): number); i++) {
359 + for (let i = 0; i <= (hookTypesUpdateIndexDev as any as number); i++) {
360 const oldHookName = hookTypesDev[i];
361 const newHookName =
362 - i === ((hookTypesUpdateIndexDev: any): number)
362 + i === (hookTypesUpdateIndexDev as any as number)
363 ? currentHookName
364 : oldHookName;
365
@@ -513,7 +513,7 @@ export function renderWithHooks<Props, SecondArg>(
513 if (__DEV__) {
514 hookTypesDev =
515 current !== null
516 - ? ((current._debugHookTypes: any): Array<HookType>)
516 + ? (current._debugHookTypes as any as Array<HookType>)
517 : null;
518 hookTypesUpdateIndexDev = -1;
519 // Used for hot reloading:
@@ -661,7 +661,7 @@ function finishRenderingHooks<Props, SecondArg>(
661 currentHook !== null && currentHook.next !== null;
662
663 renderLanes = NoLanes;
664 - currentlyRenderingFiber = (null: any);
664 + currentlyRenderingFiber = null as any;
665
666 currentHook = null;
667 workInProgressHook = null;
@@ -833,7 +833,7 @@ function renderWithHooksAgain<Props, SecondArg>(
833 workInProgressHook = null;
834
835 if (workInProgress.updateQueue != null) {
836 - resetFunctionComponentUpdateQueue((workInProgress.updateQueue: any));
836 + resetFunctionComponentUpdateQueue(workInProgress.updateQueue as any);
837 }
838
839 if (__DEV__) {
@@ -872,7 +872,7 @@ export function TransitionAwareHostComponent(): TransitionStatus {
872 const [maybeThenable] = dispatcher.useState();
873 let nextState;
874 if (typeof maybeThenable.then === 'function') {
875 - const thenable: Thenable<TransitionStatus> = (maybeThenable: any);
875 + const thenable: Thenable<TransitionStatus> = maybeThenable as any;
876 nextState = useThenable(thenable);
877 } else {
878 const status: TransitionStatus = maybeThenable;
@@ -929,7 +929,7 @@ export function resetHooksAfterThrow(): void {
929 //
930 // It should only reset things like the current dispatcher, to prevent hooks
931 // from being called outside of a component.
932 - currentlyRenderingFiber = (null: any);
932 + currentlyRenderingFiber = null as any;
933
934 // We can assume the previous dispatcher is always this one, since we set it
935 // at the beginning of the render phase and there's no re-entrance.
@@ -958,7 +958,7 @@ export function resetHooksOnUnwind(workInProgress: Fiber): void {
958 }
959
960 renderLanes = NoLanes;
961 - currentlyRenderingFiber = (null: any);
961 + currentlyRenderingFiber = null as any;
962
963 currentHook = null;
964 workInProgressHook = null;
@@ -1153,10 +1153,10 @@ function use<T>(usable: Usable<T>): T {
1153 // $FlowFixMe[method-unbinding]
1154 if (typeof usable.then === 'function') {
1155 // This is a thenable.
1156 - const thenable: Thenable<T> = (usable: any);
1156 + const thenable: Thenable<T> = usable as any;
1157 return useThenable(thenable);
1158 } else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
1159 - const context: ReactContext<T> = (usable: any);
1159 + const context: ReactContext<T> = usable as any;
1160 return readContext(context);
1161 }
1162 }
@@ -1169,7 +1169,7 @@ function useMemoCache(size: number): Array<mixed> {
1169 let memoCache = null;
1170 // Fast-path, load memo cache from wip fiber if already prepared
1171 let updateQueue: FunctionComponentUpdateQueue | null =
1172 - (currentlyRenderingFiber.updateQueue: any);
1172 + currentlyRenderingFiber.updateQueue as any;
1173 if (updateQueue !== null) {
1174 memoCache = updateQueue.memoCache;
1175 }
@@ -1178,7 +1178,7 @@ function useMemoCache(size: number): Array<mixed> {
1178 const current: Fiber | null = currentlyRenderingFiber.alternate;
1179 if (current !== null) {
1180 const currentUpdateQueue: FunctionComponentUpdateQueue | null =
1181 - (current.updateQueue: any);
1181 + current.updateQueue as any;
1182 if (currentUpdateQueue !== null) {
1183 const currentMemoCache: ?MemoCache = currentUpdateQueue.memoCache;
1184 if (currentMemoCache != null) {
@@ -1272,7 +1272,7 @@ function mountReducer<S, I, A>(
1272 }
1273 }
1274 } else {
1275 - initialState = ((initialArg: any): S);
1275 + initialState = initialArg as any as S;
1276 }
1277 hook.memoizedState = hook.baseState = initialState;
1278 const queue: UpdateQueue<S, A> = {
@@ -1280,14 +1280,14 @@ function mountReducer<S, I, A>(
1280 lanes: NoLanes,
1281 dispatch: null,
1282 lastRenderedReducer: reducer,
1283 - lastRenderedState: (initialState: any),
1283 + lastRenderedState: initialState as any,
1284 };
1285 hook.queue = queue;
1286 - const dispatch: Dispatch<A> = (queue.dispatch = (dispatchReducerAction.bind(
1286 + const dispatch: Dispatch<A> = (queue.dispatch = dispatchReducerAction.bind(
1287 null,
1288 currentlyRenderingFiber,
1289 queue,
1290 - ): any));
1290 + ) as any);
1291 return [hook.memoizedState, dispatch];
1292 }
1293
@@ -1297,7 +1297,7 @@ function updateReducer<S, I, A>(
1297 init?: I => S,
1298 ): [S, Dispatch<A>] {
1299 const hook = updateWorkInProgressHook();
1300 - return updateReducerImpl(hook, ((currentHook: any): Hook), reducer);
1300 + return updateReducerImpl(hook, currentHook as any as Hook, reducer);
1301 }
1302
1303 function updateReducerImpl<S, A>(
@@ -1414,7 +1414,7 @@ function updateReducerImpl<S, A>(
1414 action: update.action,
1415 hasEagerState: update.hasEagerState,
1416 eagerState: update.eagerState,
1417 - next: (null: any),
1417 + next: null as any,
1418 };
1419 if (newBaseQueueLast === null) {
1420 newBaseQueueFirst = newBaseQueueLast = clone;
@@ -1450,7 +1450,7 @@ function updateReducerImpl<S, A>(
1450 action: update.action,
1451 hasEagerState: update.hasEagerState,
1452 eagerState: update.eagerState,
1453 - next: (null: any),
1453 + next: null as any,
1454 };
1455 newBaseQueueLast = newBaseQueueLast.next = clone;
1456 }
@@ -1494,7 +1494,7 @@ function updateReducerImpl<S, A>(
1494 action: update.action,
1495 hasEagerState: update.hasEagerState,
1496 eagerState: update.eagerState,
1497 - next: (null: any),
1497 + next: null as any,
1498 };
1499 if (newBaseQueueLast === null) {
1500 newBaseQueueFirst = newBaseQueueLast = clone;
@@ -1521,7 +1521,7 @@ function updateReducerImpl<S, A>(
1521 if (update.hasEagerState) {
1522 // If this update is a state update (not a reducer) and was processed eagerly,
1523 // we can use the eagerly computed state
1524 - newState = ((update.eagerState: any): S);
1524 + newState = update.eagerState as any as S;
1525 } else {
1526 newState = reducer(newState, action);
1527 }
@@ -1533,7 +1533,7 @@ function updateReducerImpl<S, A>(
1533 if (newBaseQueueLast === null) {
1534 newBaseState = newState;
1535 } else {
1536 - newBaseQueueLast.next = (newBaseQueueFirst: any);
1536 + newBaseQueueLast.next = newBaseQueueFirst as any;
1537 }
1538
1539 // Mark that the fiber performed work, but only if the new state is
@@ -1571,7 +1571,7 @@ function updateReducerImpl<S, A>(
1571 queue.lanes = NoLanes;
1572 }
1573
1574 - const dispatch: Dispatch<A> = (queue.dispatch: any);
1574 + const dispatch: Dispatch<A> = queue.dispatch as any;
1575 return [hook.memoizedState, dispatch];
1576 }
1577
@@ -1594,7 +1594,7 @@ function rerenderReducer<S, I, A>(
1594
1595 // This is a re-render. Apply the new render phase updates to the previous
1596 // work-in-progress hook.
1597 - const dispatch: Dispatch<A> = (queue.dispatch: any);
1597 + const dispatch: Dispatch<A> = queue.dispatch as any;
1598 const lastRenderPhaseUpdate = queue.pending;
1599 let newState = hook.memoizedState;
1600 if (lastRenderPhaseUpdate !== null) {
@@ -1820,10 +1820,10 @@ function pushStoreConsistencyCheck<T>(
1820 value: renderedSnapshot,
1821 };
1822 let componentUpdateQueue: null | FunctionComponentUpdateQueue =
1823 - (currentlyRenderingFiber.updateQueue: any);
1823 + currentlyRenderingFiber.updateQueue as any;
1824 if (componentUpdateQueue === null) {
1825 componentUpdateQueue = createFunctionComponentUpdateQueue();
1826 - currentlyRenderingFiber.updateQueue = (componentUpdateQueue: any);
1826 + currentlyRenderingFiber.updateQueue = componentUpdateQueue as any;
1827 componentUpdateQueue.stores = [check];
1828 } else {
1829 const stores = componentUpdateQueue.stores;
@@ -1915,7 +1915,7 @@ function mountStateImpl<S>(initialState: (() => S) | S): Hook {
1915 lanes: NoLanes,
1916 dispatch: null,
1917 lastRenderedReducer: basicStateReducer,
1918 - lastRenderedState: (initialState: any),
1918 + lastRenderedState: initialState as any,
1919 };
1920 hook.queue = queue;
1921 return hook;
@@ -1926,11 +1926,11 @@ function mountState<S>(
1926 ): [S, Dispatch<BasicStateAction<S>>] {
1927 const hook = mountStateImpl(initialState);
1928 const queue = hook.queue;
1929 - const dispatch: Dispatch<BasicStateAction<S>> = (dispatchSetState.bind(
1929 + const dispatch: Dispatch<BasicStateAction<S>> = dispatchSetState.bind(
1930 null,
1931 currentlyRenderingFiber,
1932 queue,
1933 - ): any);
1933 + ) as any;
1934 queue.dispatch = dispatch;
1935 return [hook.memoizedState, dispatch];
1936 }
@@ -1963,12 +1963,12 @@ function mountOptimistic<S, A>(
1963 };
1964 hook.queue = queue;
1965 // This is different than the normal setState function.
1966 - const dispatch: A => void = (dispatchOptimisticSetState.bind(
1966 + const dispatch: A => void = dispatchOptimisticSetState.bind(
1967 null,
1968 currentlyRenderingFiber,
1969 true,
1970 queue,
1971 - ): any);
1971 + ) as any;
1972 queue.dispatch = dispatch;
1973 return [passthrough, dispatch];
1974 }
@@ -1980,7 +1980,7 @@ function updateOptimistic<S, A>(
1980 const hook = updateWorkInProgressHook();
1981 return updateOptimisticImpl(
1982 hook,
1983 - ((currentHook: any): Hook),
1983 + currentHook as any as Hook,
1984 passthrough,
1985 reducer,
1986 );
@@ -2002,9 +2002,9 @@ function updateOptimisticImpl<S, A>(
2002
2003 // If a reducer is not provided, default to the same one used by useState.
2004 const resolvedReducer: (S, A) => S =
2005 - typeof reducer === 'function' ? reducer : (basicStateReducer: any);
2005 + typeof reducer === 'function' ? reducer : (basicStateReducer as any);
2006
2007 - return updateReducerImpl(hook, ((currentHook: any): Hook), resolvedReducer);
2007 + return updateReducerImpl(hook, currentHook as any as Hook, resolvedReducer);
2008 }
2009
2010 function rerenderOptimistic<S, A>(
@@ -2024,7 +2024,7 @@ function rerenderOptimistic<S, A>(
2024 // This is an update. Process the update queue.
2025 return updateOptimisticImpl(
2026 hook,
2027 - ((currentHook: any): Hook),
2027 + currentHook as any as Hook,
2028 passthrough,
2029 reducer,
2030 );
@@ -2099,8 +2099,7 @@ function dispatchActionState<S, P>(
2099 const actionNode: ActionStateQueueNode<S, P> = {
2100 payload,
2101 action: currentAction,
2102 - next: (null: any), // circular
2103 -
2102 + next: null as any, // circular
2103 isTransition: true,
2104
2105 status: 'pending',
@@ -2166,7 +2165,7 @@ function runActionStateAction<S, P>(
2165
2166 // This is a fork of startTransition
2167 const prevTransition = ReactSharedInternals.T;
2169 - const currentTransition: Transition = ({}: any);
2168 + const currentTransition: Transition = {} as any;
2169 if (enableViewTransition) {
2170 currentTransition.types =
2171 prevTransition !== null
@@ -2255,7 +2254,7 @@ function handleActionReturnValue<S, P>(
2254 // $FlowFixMe[method-unbinding]
2255 typeof returnValue.then === 'function'
2256 ) {
2258 - const thenable = ((returnValue: any): Thenable<Awaited<S>>);
2257 + const thenable = returnValue as any as Thenable<Awaited<S>>;
2258 if (__DEV__) {
2259 // Keep track of the number of async transitions still running so we can warn.
2260 ReactSharedInternals.asyncTransitions++;
@@ -2281,7 +2280,7 @@ function handleActionReturnValue<S, P>(
2280 }
2281 }
2282 } else {
2284 - const nextState = ((returnValue: any): Awaited<S>);
2283 + const nextState = returnValue as any as Awaited<S>;
2284 onActionSuccess(actionQueue, node, nextState);
2285 }
2286 }
@@ -2361,7 +2360,7 @@ function mountActionState<S, P>(
2360 ): [Awaited<S>, (P) => void, boolean] {
2361 let initialState: Awaited<S> = initialStateProp;
2362 if (getIsHydrating()) {
2364 - const root: FiberRoot = (getWorkInProgressRoot(): any);
2363 + const root: FiberRoot = getWorkInProgressRoot() as any;
2364 const ssrFormState = root.formState;
2365 // If a formState option was passed to the root, there are form state
2366 // markers that we need to hydrate. These indicate whether the form state
@@ -2385,30 +2384,30 @@ function mountActionState<S, P>(
2384 const stateQueue = {
2385 pending: null,
2386 lanes: NoLanes,
2388 - dispatch: (null: any),
2387 + dispatch: null as any,
2388 lastRenderedReducer: actionStateReducer,
2389 lastRenderedState: initialState,
2390 };
2391 stateHook.queue = stateQueue;
2393 - const setState: Dispatch<S | Awaited<S>> = (dispatchSetState.bind(
2392 + const setState: Dispatch<S | Awaited<S>> = dispatchSetState.bind(
2393 null,
2394 currentlyRenderingFiber,
2396 - ((stateQueue: any): UpdateQueue<S | Awaited<S>, S | Awaited<S>>),
2397 - ): any);
2395 + stateQueue as any as UpdateQueue<S | Awaited<S>, S | Awaited<S>>,
2396 + ) as any;
2397 stateQueue.dispatch = setState;
2398
2399 // Pending state. This is used to store the pending state of the action.
2400 // Tracked optimistically, like a transition pending state.
2402 - const pendingStateHook = mountStateImpl((false: Thenable<boolean> | boolean));
2403 - const setPendingState: boolean => void = (dispatchOptimisticSetState.bind(
2401 + const pendingStateHook = mountStateImpl(false as Thenable<boolean> | boolean);
2402 + const setPendingState: boolean => void = dispatchOptimisticSetState.bind(
2403 null,
2404 currentlyRenderingFiber,
2405 false,
2407 - ((pendingStateHook.queue: any): UpdateQueue<
2406 + pendingStateHook.queue as any as UpdateQueue<
2407 S | Awaited<S>,
2408 S | Awaited<S>,
2410 - >),
2411 - ): any);
2409 + >,
2410 + ) as any;
2411
2412 // Action queue hook. This is used to queue pending actions. The queue is
2413 // shared between all instances of the hook. Similar to a regular state queue,
@@ -2417,12 +2416,12 @@ function mountActionState<S, P>(
2416 const actionQueueHook = mountWorkInProgressHook();
2417 const actionQueue: ActionStateQueue<S, P> = {
2418 state: initialState,
2420 - dispatch: (null: any), // circular
2419 + dispatch: null as any, // circular
2420 action,
2421 pending: null,
2422 };
2423 actionQueueHook.queue = actionQueue;
2425 - const dispatch = (dispatchActionState: any).bind(
2424 + const dispatch = (dispatchActionState as any).bind(
2425 null,
2426 currentlyRenderingFiber,
2427 actionQueue,
@@ -2445,7 +2444,7 @@ function updateActionState<S, P>(
2444 permalink?: string,
2445 ): [Awaited<S>, (P) => void, boolean] {
2446 const stateHook = updateWorkInProgressHook();
2448 - const currentStateHook = ((currentHook: any): Hook);
2447 + const currentStateHook = currentHook as any as Hook;
2448 return updateActionStateImpl(
2449 stateHook,
2450 currentStateHook,
@@ -2480,7 +2479,7 @@ function updateActionStateImpl<S, P>(
2479 typeof actionResult.then === 'function'
2480 ) {
2481 try {
2483 - state = useThenable(((actionResult: any): Thenable<Awaited<S>>));
2482 + state = useThenable(actionResult as any as Thenable<Awaited<S>>);
2483 } catch (x) {
2484 if (x === SuspenseException) {
2485 // If we Suspend here, mark this separately so that we can track this
@@ -2491,7 +2490,7 @@ function updateActionStateImpl<S, P>(
2490 }
2491 }
2492 } else {
2494 - state = (actionResult: any);
2493 + state = actionResult as any;
2494 }
2495
2496 const actionQueueHook = updateWorkInProgressHook();
@@ -2574,17 +2573,17 @@ function pushSimpleEffect(
2573 deps,
2574 inst,
2575 // Circular
2577 - next: (null: any),
2576 + next: null as any,
2577 };
2578 return pushEffectImpl(effect);
2579 }
2580
2581 function pushEffectImpl(effect: Effect): Effect {
2582 let componentUpdateQueue: null | FunctionComponentUpdateQueue =
2584 - (currentlyRenderingFiber.updateQueue: any);
2583 + currentlyRenderingFiber.updateQueue as any;
2584 if (componentUpdateQueue === null) {
2585 componentUpdateQueue = createFunctionComponentUpdateQueue();
2587 - currentlyRenderingFiber.updateQueue = (componentUpdateQueue: any);
2586 + currentlyRenderingFiber.updateQueue = componentUpdateQueue as any;
2587 }
2588 const lastEffect = componentUpdateQueue.lastEffect;
2589 if (lastEffect === null) {
@@ -2707,10 +2706,10 @@ function useEffectEventImpl<Args, Return, F: (...Array<Args>) => Return>(
2706 ) {
2707 currentlyRenderingFiber.flags |= UpdateEffect;
2708 let componentUpdateQueue: null | FunctionComponentUpdateQueue =
2710 - (currentlyRenderingFiber.updateQueue: any);
2709 + currentlyRenderingFiber.updateQueue as any;
2710 if (componentUpdateQueue === null) {
2711 componentUpdateQueue = createFunctionComponentUpdateQueue();
2713 - currentlyRenderingFiber.updateQueue = (componentUpdateQueue: any);
2712 + currentlyRenderingFiber.updateQueue = componentUpdateQueue as any;
2713 componentUpdateQueue.events = [payload];
2714 } else {
2715 const events = componentUpdateQueue.events;
@@ -2971,7 +2970,7 @@ function mountDeferredValue<T>(value: T, initialValue?: T): T {
2970
2971 function updateDeferredValue<T>(value: T, initialValue?: T): T {
2972 const hook = updateWorkInProgressHook();
2974 - const resolvedCurrentHook: Hook = (currentHook: any);
2973 + const resolvedCurrentHook: Hook = currentHook as any;
2974 const prevValue: T = resolvedCurrentHook.memoizedState;
2975 return updateDeferredValueImpl(hook, prevValue, value, initialValue);
2976 }
@@ -3105,7 +3104,7 @@ function startTransition<S>(
3104 );
3105
3106 const prevTransition = ReactSharedInternals.T;
3108 - const currentTransition: Transition = ({}: any);
3107 + const currentTransition: Transition = {} as any;
3108 if (enableViewTransition) {
3109 currentTransition.types =
3110 prevTransition !== null
@@ -3158,7 +3157,7 @@ function startTransition<S>(
3157 typeof returnValue === 'object' &&
3158 typeof returnValue.then === 'function'
3159 ) {
3161 - const thenable = ((returnValue: any): Thenable<mixed>);
3160 + const thenable = returnValue as any as Thenable<mixed>;
3161 if (__DEV__) {
3162 // Keep track of the number of async transitions still running so we can warn.
3163 ReactSharedInternals.asyncTransitions++;
@@ -3173,7 +3172,7 @@ function startTransition<S>(
3172 dispatchSetStateInternal(
3173 fiber,
3174 queue,
3176 - (thenableForFinishedState: any),
3175 + thenableForFinishedState as any,
3176 requestUpdateLane(fiber),
3177 );
3178 } else {
@@ -3304,7 +3303,7 @@ function ensureFormComponentIsStateful(formFiber: Fiber) {
3303 lanes: NoLanes,
3304 // We're going to cheat and intentionally not create a bound dispatch
3305 // method, because we can call it directly in startTransition.
3307 - dispatch: (null: any),
3306 + dispatch: null as any,
3307 lastRenderedReducer: basicStateReducer,
3308 lastRenderedState: NoPendingHostTransition,
3309 };
@@ -3327,7 +3326,7 @@ function ensureFormComponentIsStateful(formFiber: Fiber) {
3326 lanes: NoLanes,
3327 // We're going to cheat and intentionally not create a bound dispatch
3328 // method, because we can call it directly in startTransition.
3330 - dispatch: (null: any),
3329 + dispatch: null as any,
3330 lastRenderedReducer: basicStateReducer,
3331 lastRenderedState: initialResetState,
3332 };
@@ -3387,9 +3386,9 @@ export function requestFormReset(formFiber: Fiber) {
3386 // instead.
3387 // TODO: We should really stash the Queue somewhere stateful
3388 // just like how setState binds the Queue.
3390 - stateHook = (formFiber.alternate: any).memoizedState;
3389 + stateHook = (formFiber.alternate as any).memoizedState;
3390 }
3392 - const resetStateHook: Hook = (stateHook.next: any);
3391 + const resetStateHook: Hook = stateHook.next as any;
3392 const resetStateQueue = resetStateHook.queue;
3393 dispatchSetStateInternal(
3394 formFiber,
@@ -3403,7 +3402,7 @@ function mountTransition(): [
3402 boolean,
3403 (callback: () => void, options?: StartTransitionOptions) => void,
3404 ] {
3406 - const stateHook = mountStateImpl((false: Thenable<boolean> | boolean));
3405 + const stateHook = mountStateImpl(false as Thenable<boolean> | boolean);
3406 // The `start` method never changes.
3407 const start = startTransition.bind(
3408 null,
@@ -3454,7 +3453,7 @@ function useHostTransitionStatus(): TransitionStatus {
3453 function mountId(): string {
3454 const hook = mountWorkInProgressHook();
3455
3457 - const root = ((getWorkInProgressRoot(): any): FiberRoot);
3456 + const root = getWorkInProgressRoot() as any as FiberRoot;
3457 // TODO: In Fizz, id generation is specific to each server config. Maybe we
3458 // should do this in Fiber, too? Deferring this decision for now because
3459 // there's no other place to store the prefix except for an internal field on
@@ -3583,7 +3582,7 @@ function dispatchReducerAction<S, A>(
3582 action,
3583 hasEagerState: false,
3584 eagerState: null,
3586 - next: (null: any),
3585 + next: null as any,
3586 };
3587
3588 if (isRenderPhaseUpdate(fiber)) {
@@ -3643,7 +3642,7 @@ function dispatchSetStateInternal<S, A>(
3642 action,
3643 hasEagerState: false,
3644 eagerState: null,
3646 - next: (null: any),
3645 + next: null as any,
3646 };
3647
3648 if (isRenderPhaseUpdate(fiber)) {
@@ -3665,7 +3664,7 @@ function dispatchSetStateInternal<S, A>(
3664 ReactSharedInternals.H = InvalidNestedHooksDispatcherOnUpdateInDEV;
3665 }
3666 try {
3668 - const currentState: S = (queue.lastRenderedState: any);
3667 + const currentState: S = queue.lastRenderedState as any;
3668 const eagerState = lastRenderedReducer(currentState, action);
3669 // Stash the eagerly computed state, and the reducer used to compute
3670 // it, on the update object. If the reducer hasn't changed by the
@@ -3762,7 +3761,7 @@ function dispatchOptimisticSetState<S, A>(
3761 action,
3762 hasEagerState: false,
3763 eagerState: null,
3765 - next: (null: any),
3764 + next: null as any,
3765 };
3766
3767 if (isRenderPhaseUpdate(fiber)) {
packages/react-reconciler/src/ReactFiberHostContext.js
+1 -1
@@ -46,7 +46,7 @@ function requiredContext<Value>(c: Value | null): Value {
46 );
47 }
48 }
49 - return (c: any);
49 + return c as any;
50 }
51
52 function getCurrentRootHostContainer(): null | Container {
packages/react-reconciler/src/ReactFiberHotReloading.js
+1 -1
@@ -107,7 +107,7 @@ export function resolveForwardRefForHotReloading(type: any): any {
107 render: currentRender,
108 };
109 if (type.displayName !== undefined) {
110 - (syntheticType: any).displayName = type.displayName;
110 + (syntheticType as any).displayName = type.displayName;
111 }
112 return syntheticType;
113 }
packages/react-reconciler/src/ReactFiberHydrationContext.js
+3 -3
@@ -263,7 +263,7 @@ function tryHydrateInstance(
263 // $FlowFixMe[invalid-compare]
264 // $FlowFixMe[invalid-compare]
265 if (instance !== null) {
266 - fiber.stateNode = (instance: Instance);
266 + fiber.stateNode = instance as Instance;
267
268 if (__DEV__) {
269 if (!didSuspendOrErrorDEV) {
@@ -301,7 +301,7 @@ function tryHydrateText(fiber: Fiber, nextInstance: any) {
301 );
302 // $FlowFixMe[invalid-compare]
303 if (textInstance !== null) {
304 - fiber.stateNode = (textInstance: TextInstance);
304 + fiber.stateNode = textInstance as TextInstance;
305 hydrationParentFiber = fiber;
306 // Text Instances don't have children so there's nothing to hydrate.
307 nextHydratableInstance = null;
@@ -844,7 +844,7 @@ function warnIfUnhydratedTailNodes(fiber: Fiber) {
844 diffNode.serverTail.push(description);
845 // $FlowFixMe[invalid-compare]
846 if (description.type === 'Suspense') {
847 - const suspenseInstance: SuspenseInstance = (nextInstance: any);
847 + const suspenseInstance: SuspenseInstance = nextInstance as any;
848 nextInstance =
849 getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
850 } else {
packages/react-reconciler/src/ReactFiberHydrationDiffs.js
+4 -4
@@ -197,8 +197,8 @@ function describeValue(value: mixed, maxLength: number): string {
197 if (isArray(value)) {
198 return '[...]';
199 }
200 - if ((value: any).$$typeof === REACT_ELEMENT_TYPE) {
201 - const type = getComponentNameFromType((value: any).type);
200 + if ((value as any).$$typeof === REACT_ELEMENT_TYPE) {
201 + const type = getComponentNameFromType((value as any).type);
202 return type ? '<' + type + '>' : '<...>';
203 }
204 const name = objectName(value);
@@ -228,12 +228,12 @@ function describeValue(value: mixed, maxLength: number): string {
228 }
229 return '{' + properties + '}';
230 } else if (enableSrcObject && (name === 'Blob' || name === 'File')) {
231 - return name + ':' + (value: any).type;
231 + return name + ':' + (value as any).type;
232 }
233 return name;
234 }
235 case 'function': {
236 - const name = (value: any).displayName || value.name;
236 + const name = (value as any).displayName || value.name;
237 return name ? 'function ' + name : 'function';
238 }
239 default:
packages/react-reconciler/src/ReactFiberLegacyContext.js
+1 -1
@@ -19,7 +19,7 @@ import {createCursor, push, pop} from './ReactFiberStack';
19 let warnedAboutMissingGetChildContext;
20
21 if (__DEV__) {
22 - warnedAboutMissingGetChildContext = ({}: {[string]: boolean});
22 + warnedAboutMissingGetChildContext = {} as {[string]: boolean};
23 }
24
25 export const emptyContextObject: {} = {};
packages/react-reconciler/src/ReactFiberNewContext.js
+1 -1
@@ -587,7 +587,7 @@ function readContextForConsumer<T>(
587 : context._currentValue2;
588
589 const contextItem = {
590 - context: ((context: any): ReactContext<mixed>),
590 + context: context as any as ReactContext<mixed>,
591 memoizedValue: value,
592 next: null,
593 };
packages/react-reconciler/src/ReactFiberPerformanceTrack.js
+4 -4
@@ -189,7 +189,7 @@ export function popDeepEquality(prev: boolean): void {
189
190 const reusableComponentDevToolDetails = {
191 color: 'primary',
192 - properties: (null: null | Array<[string, string]>),
192 + properties: null as null | Array<[string, string]>,
193 tooltipText: '',
194 track: COMPONENTS_TRACK,
195 };
@@ -232,10 +232,10 @@ export function logComponentRender(
232 }
233 if (supportsUserTiming) {
234 const alternate = fiber.alternate;
235 - let selfTime: number = (fiber.actualDuration: any);
235 + let selfTime: number = fiber.actualDuration as any;
236 if (alternate === null || alternate.child !== fiber.child) {
237 for (let child = fiber.child; child !== null; child = child.sibling) {
238 - selfTime -= (child.actualDuration: any);
238 + selfTime -= child.actualDuration as any;
239 }
240 }
241 const color =
@@ -284,7 +284,7 @@ export function logComponentRender(
284 isDeeplyEqual &&
285 !alreadyWarnedForDeepEquality &&
286 !includesSomeLane(alternate.lanes, committedLanes) &&
287 - (fiber.actualDuration: any) > 100
287 + (fiber.actualDuration as any) > 100
288 ) {
289 alreadyWarnedForDeepEquality = true;
290 // This is the first component in a subtree which rerendered with deeply equal props
packages/react-reconciler/src/ReactFiberReconciler.js
+5 -5
@@ -134,7 +134,7 @@ let didWarnAboutFindNodeInStrictMode;
134
135 if (__DEV__) {
136 didWarnAboutNestedUpdates = false;
137 - didWarnAboutFindNodeInStrictMode = ({}: {[string]: boolean});
137 + didWarnAboutFindNodeInStrictMode = {} as {[string]: boolean};
138 }
139
140 function getContextForSubtree(
@@ -609,7 +609,7 @@ if (__DEV__) {
609 const updated = isArray(obj) ? obj.slice() : {...obj};
610 if (index + 1 === path.length) {
611 if (isArray(updated)) {
612 - updated.splice(((key: any): number), 1);
612 + updated.splice(key as any as number, 1);
613 } else {
614 delete updated[key];
615 }
@@ -640,7 +640,7 @@ if (__DEV__) {
640 // $FlowFixMe[incompatible-use] number or string is fine here
641 updated[newKey] = updated[oldKey];
642 if (isArray(updated)) {
643 - updated.splice(((oldKey: any): number), 1);
643 + updated.splice(oldKey as any as number, 1);
644 } else {
645 delete updated[oldKey];
646 }
@@ -859,7 +859,7 @@ function getLaneLabelMap(): Map<Lane, string> | null {
859
860 let lane = 1;
861 for (let index = 0; index < TotalLanes; index++) {
862 - const label = ((getLabelForLane(lane): any): string);
862 + const label = getLabelForLane(lane) as any as string;
863 map.set(lane, label);
864 lane *= 2;
865 }
@@ -882,7 +882,7 @@ export function injectIntoDevTools(): boolean {
882 };
883 // $FlowFixMe[invalid-compare]
884 if (extraDevToolsConfig !== null) {
885 - internals.rendererConfig = (extraDevToolsConfig: RendererInspectionConfig);
885 + internals.rendererConfig = extraDevToolsConfig as RendererInspectionConfig;
886 }
887 if (__DEV__) {
888 internals.overrideHookState = overrideHookState;
packages/react-reconciler/src/ReactFiberRoot.js
+2 -2
@@ -186,7 +186,7 @@ export function createFiberRoot(
186 transitionCallbacks: null | TransitionTracingCallbacks,
187 ): FiberRoot {
188 // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
189 - const root: FiberRoot = (new FiberRootNode(
189 + const root: FiberRoot = new FiberRootNode(
190 containerInfo,
191 tag,
192 hydrate,
@@ -196,7 +196,7 @@ export function createFiberRoot(
196 onRecoverableError,
197 onDefaultTransitionIndicator,
198 formState,
199 - ): any);
199 + ) as any;
200 if (enableSuspenseCallback) {
201 root.hydrationCallbacks = hydrationCallbacks;
202 }
packages/react-reconciler/src/ReactFiberScope.js
+1 -1
@@ -25,7 +25,7 @@ import {HostComponent, ScopeComponent, ContextProvider} from './ReactWorkTags';
25 import {enableScopeAPI} from 'shared/ReactFeatureFlags';
26
27 function getSuspenseFallbackChild(fiber: Fiber): Fiber | null {
28 - return ((((fiber.child: any): Fiber).sibling: any): Fiber).child;
28 + return ((fiber.child as any as Fiber).sibling as any as Fiber).child;
29 }
30
31 const emptyObject = {};
packages/react-reconciler/src/ReactFiberThenable.js
+10 -10
@@ -38,10 +38,10 @@ export opaque type ThenableState = ThenableStateDev | ThenableStateProd;
38
39 function getThenablesFromState(state: ThenableState): Array<Thenable<any>> {
40 if (__DEV__) {
41 - const devState: ThenableStateDev = (state: any);
41 + const devState: ThenableStateDev = state as any;
42 return devState.thenables;
43 } else {
44 - const prodState = (state: any);
44 + const prodState = state as any;
45 return prodState;
46 }
47 }
@@ -122,7 +122,7 @@ export function trackUsedThenable<T>(
122 // they represent the same value, because components are idempotent.
123
124 if (__DEV__) {
125 - const thenableStateDev: ThenableStateDev = (thenableState: any);
125 + const thenableStateDev: ThenableStateDev = thenableState as any;
126 if (!thenableStateDev.didWarnAboutUncachedPromise) {
127 // We should only warn the first time an uncached thenable is
128 // discovered per component, because if there are multiple, the
@@ -168,7 +168,7 @@ export function trackUsedThenable<T>(
168 name: typeof displayName === 'string' ? displayName : 'Promise',
169 start: startTime,
170 end: startTime,
171 - value: (thenable: any),
171 + value: thenable as any,
172 // We don't know the requesting owner nor stack.
173 };
174 // We can infer the await owner/stack lazily from where this promise ends up
@@ -254,19 +254,19 @@ export function trackUsedThenable<T>(
254 );
255 }
256
257 - const pendingThenable: PendingThenable<T> = (thenable: any);
257 + const pendingThenable: PendingThenable<T> = thenable as any;
258 pendingThenable.status = 'pending';
259 pendingThenable.then(
260 fulfilledValue => {
261 if (thenable.status === 'pending') {
262 - const fulfilledThenable: FulfilledThenable<T> = (thenable: any);
262 + const fulfilledThenable: FulfilledThenable<T> = thenable as any;
263 fulfilledThenable.status = 'fulfilled';
264 fulfilledThenable.value = fulfilledValue;
265 }
266 },
267 (error: mixed) => {
268 if (thenable.status === 'pending') {
269 - const rejectedThenable: RejectedThenable<T> = (thenable: any);
269 + const rejectedThenable: RejectedThenable<T> = thenable as any;
270 rejectedThenable.status = 'rejected';
271 rejectedThenable.reason = error;
272 }
@@ -275,13 +275,13 @@ export function trackUsedThenable<T>(
275 }
276
277 // Check one more time in case the thenable resolved synchronously.
278 - switch ((thenable: Thenable<T>).status) {
278 + switch ((thenable as Thenable<T>).status) {
279 case 'fulfilled': {
280 - const fulfilledThenable: FulfilledThenable<T> = (thenable: any);
280 + const fulfilledThenable: FulfilledThenable<T> = thenable as any;
281 return fulfilledThenable.value;
282 }
283 case 'rejected': {
284 - const rejectedThenable: RejectedThenable<T> = (thenable: any);
284 + const rejectedThenable: RejectedThenable<T> = thenable as any;
285 const rejectedError = rejectedThenable.reason;
286 checkIfUseWrappedInAsyncCatch(rejectedError);
287 throw rejectedError;
packages/react-reconciler/src/ReactFiberThrow.js
+6 -6
@@ -187,7 +187,7 @@ function initializeClassErrorUpdate(
187 // If componentDidCatch is the only error boundary method defined,
188 // then it needs to call setState to recover from errors.
189 // If no state update is scheduled then the boundary will swallow the error.
190 - if (!includesSomeLane(fiber.lanes, (SyncLane: Lane))) {
190 + if (!includesSomeLane(fiber.lanes, SyncLane as Lane)) {
191 console.error(
192 '%s: Error boundaries should implement getDerivedStateFromError(). ' +
193 'In that method, return a state update to display an error message or fallback UI.',
@@ -381,7 +381,7 @@ function throwException(
381 if (value !== null && typeof value === 'object') {
382 if (typeof value.then === 'function') {
383 // This is a wakeable. The component suspended.
384 - const wakeable: Wakeable = (value: any);
384 + const wakeable: Wakeable = value as any;
385 resetSuspendedComponent(sourceFiber, rootRenderLanes);
386
387 if (__DEV__) {
@@ -468,7 +468,7 @@ function throwException(
468 suspenseBoundary.flags |= ScheduleRetry;
469 } else {
470 const retryQueue: RetryQueue | null =
471 - (suspenseBoundary.updateQueue: any);
471 + suspenseBoundary.updateQueue as any;
472 if (retryQueue === null) {
473 suspenseBoundary.updateQueue = new Set([wakeable]);
474 } else {
@@ -493,7 +493,7 @@ function throwException(
493 suspenseBoundary.flags |= ScheduleRetry;
494 } else {
495 const offscreenQueue: OffscreenQueue | null =
496 - (suspenseBoundary.updateQueue: any);
496 + suspenseBoundary.updateQueue as any;
497 if (offscreenQueue === null) {
498 const newOffscreenQueue: OffscreenQueue = {
499 transitions: null,
@@ -604,7 +604,7 @@ function throwException(
604 createCapturedValueAtFiber(wrapperError, sourceFiber),
605 );
606 }
607 - const workInProgress: Fiber = (root.current: any).alternate;
607 + const workInProgress: Fiber = (root.current as any).alternate;
608 // Schedule an update at the root to log the error but this shouldn't
609 // actually happen because we should recover.
610 workInProgress.flags |= ShouldCapture;
@@ -681,7 +681,7 @@ function throwException(
681 break;
682 case OffscreenComponent: {
683 const offscreenState: OffscreenState | null =
684 - (workInProgress.memoizedState: any);
684 + workInProgress.memoizedState as any;
685 if (offscreenState !== null) {
686 // An error was thrown inside a hidden Offscreen boundary. This should
687 // not be allowed to escape into the visible part of the UI. Mark the
packages/react-reconciler/src/ReactFiberTransition.js
+3 -3
@@ -94,7 +94,7 @@ ReactSharedInternals.S = function onStartTransitionFinishForReconciler(
94 startAsyncTransitionTimer();
95
96 // This is an async action
97 - const thenable: Thenable<mixed> = (returnValue: any);
97 + const thenable: Thenable<mixed> = returnValue as any;
98 entangleAsyncAction(transition, thenable);
99 }
100 if (enableViewTransition) {
@@ -218,7 +218,7 @@ function peekCacheFromPool(): Cache | null {
218 }
219
220 // Otherwise, check the root's cache pool.
221 - const root = (getWorkInProgressRoot(): any);
221 + const root = getWorkInProgressRoot() as any;
222 const cacheFromRootCachePool = root.pooledCache;
223
224 return cacheFromRootCachePool;
@@ -242,7 +242,7 @@ export function requestCacheFromPool(renderLanes: Lanes): Cache {
242 // - One of several fiber types: host root, cache boundary, suspense
243 // component. These retain and release in the commit phase.
244
245 - const root = (getWorkInProgressRoot(): any);
245 + const root = getWorkInProgressRoot() as any;
246 const freshCache = createCache();
247 root.pooledCache = freshCache;
248 retainCache(freshCache);
packages/react-reconciler/src/ReactFiberTreeReflection.js
+1 -1
@@ -102,7 +102,7 @@ export function getActivityInstanceFromFiber(
102
103 export function getContainerFromFiber(fiber: Fiber): null | Container {
104 return fiber.tag === HostRoot
105 - ? (fiber.stateNode.containerInfo: Container)
105 + ? (fiber.stateNode.containerInfo as Container)
106 : null;
107 }
108
packages/react-reconciler/src/ReactFiberViewTransitionComponent.js
+1 -1
@@ -37,7 +37,7 @@ export function getViewTransitionName(
37 }
38
39 // We assume we always call this in the commit phase.
40 - const root = ((getCommittingRoot(): any): FiberRoot);
40 + const root = getCommittingRoot() as any as FiberRoot;
41 const identifierPrefix = root.identifierPrefix;
42 const globalClientId = globalClientIdCounter++;
43 const name =
packages/react-reconciler/src/ReactFiberWorkLoop.js
+30 -30
@@ -560,7 +560,7 @@ export function addTransitionStartCallbackToPendingTransition(
560
561 if (currentPendingTransitionCallbacks.transitionStart === null) {
562 currentPendingTransitionCallbacks.transitionStart =
563 - ([]: Array<Transition>);
563 + [] as Array<Transition>;
564 }
565
566 currentPendingTransitionCallbacks.transitionStart.push(transition);
@@ -574,14 +574,14 @@ export function addMarkerProgressCallbackToPendingTransition(
574 ) {
575 if (enableTransitionTracing) {
576 if (currentPendingTransitionCallbacks === null) {
577 - currentPendingTransitionCallbacks = ({
577 + currentPendingTransitionCallbacks = {
578 transitionStart: null,
579 transitionProgress: null,
580 transitionComplete: null,
581 markerProgress: new Map(),
582 markerIncomplete: null,
583 markerComplete: null,
584 - }: PendingTransitionCallbacks);
584 + } as PendingTransitionCallbacks;
585 }
586
587 if (currentPendingTransitionCallbacks.markerProgress === null) {
@@ -694,7 +694,7 @@ export function addTransitionCompleteCallbackToPendingTransition(
694
695 if (currentPendingTransitionCallbacks.transitionComplete === null) {
696 currentPendingTransitionCallbacks.transitionComplete =
697 - ([]: Array<Transition>);
697 + [] as Array<Transition>;
698 }
699
700 currentPendingTransitionCallbacks.transitionComplete.push(transition);
@@ -728,8 +728,8 @@ const PENDING_PASSIVE_PHASE = 5;
728 const PENDING_GESTURE_MUTATION_PHASE = 6;
729 const PENDING_GESTURE_ANIMATION_PHASE = 7;
730 let pendingEffectsStatus: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 = 0;
731 -let pendingEffectsRoot: FiberRoot = (null: any);
732 -let pendingFinishedWork: Fiber = (null: any);
731 +let pendingEffectsRoot: FiberRoot = null as any;
732 +let pendingFinishedWork: Fiber = null as any;
733 let pendingEffectsLanes: Lanes = NoLanes;
734 let pendingEffectsRemainingLanes: Lanes = NoLanes;
735 let pendingEffectsRenderEndTime: number = -0; // Profiling-only
@@ -811,7 +811,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
811 // Special cases
812 const mode = fiber.mode;
813 if (!disableLegacyMode && (mode & ConcurrentMode) === NoMode) {
814 - return (SyncLane: Lane);
814 + return SyncLane as Lane;
815 } else if (
816 (executionContext & RenderContext) !== NoContext &&
817 workInProgressRootRenderLanes !== NoLanes
@@ -861,7 +861,7 @@ function requestRetryLane(fiber: Fiber) {
861 // Special cases
862 const mode = fiber.mode;
863 if (!disableLegacyMode && (mode & ConcurrentMode) === NoMode) {
864 - return (SyncLane: Lane);
864 + return SyncLane as Lane;
865 }
866
867 return claimNextRetryLane();
@@ -1205,7 +1205,7 @@ export function performWorkOnRoot(
1205 // TODO: It's possible that even a concurrent render may never have yielded
1206 // to the main thread, if it was fast enough, or if it expired. We could
1207 // skip the consistency check in that case, too.
1208 - const finishedWork: Fiber = (root.current.alternate: any);
1208 + const finishedWork: Fiber = root.current.alternate as any;
1209 if (
1210 renderWasConcurrent &&
1211 !isRenderConsistentWithExternalStores(finishedWork)
@@ -1695,7 +1695,7 @@ function isRenderConsistentWithExternalStores(finishedWork: Fiber): boolean {
1695 node.flags & StoreConsistency
1696 ) {
1697 const updateQueue: FunctionComponentUpdateQueue | null =
1698 - (node.updateQueue: any);
1698 + node.updateQueue as any;
1699 if (updateQueue !== null) {
1700 const checks = updateQueue.stores;
1701 if (checks !== null) {
@@ -2384,7 +2384,7 @@ function handleThrow(root: FiberRoot, thrownValue: any): void {
2384 case SuspendedOnImmediate:
2385 case SuspendedOnDeprecatedThrowPromise:
2386 case SuspendedAndReadyToContinue: {
2387 - const wakeable: Wakeable = (thrownValue: any);
2387 + const wakeable: Wakeable = thrownValue as any;
2388 markComponentSuspended(
2389 erroredWork,
2390 wakeable,
@@ -2823,7 +2823,7 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes): RootExitStatus {
2823 }
2824 case SuspendedOnData:
2825 case SuspendedOnAction: {
2826 - const thenable: Thenable<mixed> = (thrownValue: any);
2826 + const thenable: Thenable<mixed> = thrownValue as any;
2827 if (isThenableResolved(thenable)) {
2828 // The data resolved. Try rendering the component again.
2829 workInProgressSuspendedReason = NotSuspended;
@@ -2868,7 +2868,7 @@ function renderRootConcurrent(root: FiberRoot, lanes: Lanes): RootExitStatus {
2868 break outer;
2869 }
2870 case SuspendedAndReadyToContinue: {
2871 - const thenable: Thenable<mixed> = (thrownValue: any);
2871 + const thenable: Thenable<mixed> = thrownValue as any;
2872 if (isThenableResolved(thenable)) {
2873 // The data resolved. Try rendering the component again.
2874 workInProgressSuspendedReason = NotSuspended;
@@ -3547,7 +3547,7 @@ function completeRoot(
3547 const hydrationFailed =
3548 finishedWork !== null &&
3549 finishedWork.alternate !== null &&
3550 - (finishedWork.alternate.memoizedState: RootState).isDehydrated &&
3550 + (finishedWork.alternate.memoizedState as RootState).isDehydrated &&
3551 (finishedWork.flags & ForceClientRender) !== NoFlags;
3552 logRecoveredRenderPhase(
3553 completedRenderStartTime,
@@ -3659,8 +3659,8 @@ function completeRoot(
3659 finalizeRender(lanes, completedRenderEndTime);
3660 }
3661 // We are no longer committing.
3662 - pendingEffectsRoot = (null: any); // Clear for GC purposes.
3663 - pendingFinishedWork = (null: any); // Clear for GC purposes.
3662 + pendingEffectsRoot = null as any; // Clear for GC purposes.
3663 + pendingFinishedWork = null as any; // Clear for GC purposes.
3664 pendingEffectsLanes = NoLanes;
3665 }
3666 // Schedule the root to be committed when the gesture completes.
@@ -3887,11 +3887,11 @@ function commitRoot(
3887 flushSpawnedWork,
3888 flushPassiveEffects,
3889 reportViewTransitionError,
3890 - enableProfilerTimer ? suspendedViewTransition : (null: any),
3890 + enableProfilerTimer ? suspendedViewTransition : (null as any),
3891 enableProfilerTimer
3892 ? // This callback fires after "pendingEffects" so we need to snapshot the arguments.
3893 finishedViewTransition.bind(null, lanes)
3894 - : (null: any),
3894 + : (null as any),
3895 );
3896 } else {
3897 // Flush synchronously.
@@ -4190,8 +4190,8 @@ function flushSpawnedWork(): void {
4190 pendingEffectsStatus = PENDING_PASSIVE_PHASE;
4191 } else {
4192 pendingEffectsStatus = NO_PENDING_EFFECTS;
4193 - pendingEffectsRoot = (null: any); // Clear for GC purposes.
4194 - pendingFinishedWork = (null: any); // Clear for GC purposes.
4193 + pendingEffectsRoot = null as any; // Clear for GC purposes.
4194 + pendingFinishedWork = null as any; // Clear for GC purposes.
4195 // There were no passive effects, so we can immediately release the cache
4196 // pool for this render.
4197 releaseRootPooledCache(root, root.pendingLanes);
@@ -4469,7 +4469,7 @@ function applyGestureOnRoot(
4469 enableProfilerTimer
4470 ? // This callback fires after "pendingEffects" so we need to snapshot the arguments.
4471 finishedViewTransition.bind(null, pendingEffectsLanes)
4472 - : (null: any),
4472 + : (null as any),
4473 );
4474 }
4475
@@ -4542,8 +4542,8 @@ function flushGestureAnimations(): void {
4542 pendingEffectsStatus = NO_PENDING_EFFECTS;
4543 const root = pendingEffectsRoot;
4544 const finishedWork = pendingFinishedWork;
4545 - pendingEffectsRoot = (null: any); // Clear for GC purposes.
4546 - pendingFinishedWork = (null: any); // Clear for GC purposes.
4545 + pendingEffectsRoot = null as any; // Clear for GC purposes.
4546 + pendingFinishedWork = null as any; // Clear for GC purposes.
4547 pendingEffectsLanes = NoLanes;
4548
4549 pendingViewTransition = null; // The view transition has now fully started.
@@ -4605,7 +4605,7 @@ function makeErrorInfo(componentStack: ?string) {
4605 componentStack,
4606 };
4607 if (__DEV__) {
4608 - Object.defineProperty((errorInfo: any), 'digest', {
4608 + Object.defineProperty(errorInfo as any, 'digest', {
4609 get() {
4610 console.error(
4611 'You are accessing "digest" from the errorInfo object passed to onRecoverableError.' +
@@ -4714,8 +4714,8 @@ function flushPassiveEffectsImpl() {
4714 const root = pendingEffectsRoot;
4715 const lanes = pendingEffectsLanes;
4716 pendingEffectsStatus = NO_PENDING_EFFECTS;
4717 - pendingEffectsRoot = (null: any); // Clear for GC purposes.
4718 - pendingFinishedWork = (null: any); // Clear for GC purposes.
4717 + pendingEffectsRoot = null as any; // Clear for GC purposes.
4718 + pendingFinishedWork = null as any; // Clear for GC purposes.
4719 // TODO: This is sometimes out of sync with pendingEffectsRoot.
4720 // Figure out why and fix it. It's not causing any known issues (probably
4721 // because it's only used for profiling), but it's a refactor hazard.
@@ -4882,9 +4882,9 @@ function captureCommitPhaseErrorOnRoot(
4882 const update = createRootErrorUpdate(
4883 rootFiber.stateNode,
4884 errorInfo,
4885 - (SyncLane: Lane),
4885 + SyncLane as Lane,
4886 );
4887 - const root = enqueueUpdate(rootFiber, update, (SyncLane: Lane));
4887 + const root = enqueueUpdate(rootFiber, update, SyncLane as Lane);
4888 if (root !== null) {
4889 markRootUpdated(root, SyncLane);
4890 ensureRootIsScheduled(root);
@@ -4923,8 +4923,8 @@ export function captureCommitPhaseError(
4923 if (enableProfilerTimer && enableComponentPerformanceTrack) {
4924 recordEffectError(errorInfo);
4925 }
4926 - const update = createClassErrorUpdate((SyncLane: Lane));
4927 - const root = enqueueUpdate(fiber, update, (SyncLane: Lane));
4926 + const update = createClassErrorUpdate(SyncLane as Lane);
4927 + const root = enqueueUpdate(fiber, update, SyncLane as Lane);
4928 if (root !== null) {
4929 initializeClassErrorUpdate(update, root, fiber, errorInfo);
4930 markRootUpdated(root, SyncLane);
packages/react-reconciler/src/ReactProfilerTimer.js
+2 -2
@@ -107,7 +107,7 @@ export let idleClampTime: number = -0;
107 export let animatingLanes: Lanes = NoLanes;
108 export let animatingTask: null | ConsoleTask = null; // First ViewTransition applying an Animation.
109
110 -export let yieldReason: SuspendedReason = (0: any);
110 +export let yieldReason: SuspendedReason = 0 as any;
111 export let yieldStartTime: number = -1.1; // The time when we yielded to the event loop
112
113 export function startYieldTimer(reason: SuspendedReason) {
@@ -590,7 +590,7 @@ export function startProfilerTimer(fiber: Fiber): void {
590
591 profilerStartTime = now();
592
593 - if (((fiber.actualStartTime: any): number) < 0) {
593 + if ((fiber.actualStartTime as any as number) < 0) {
594 fiber.actualStartTime = profilerStartTime;
595 }
596 }
packages/react-reconciler/src/ReactStrictModeWarnings.js
+1 -1
@@ -321,7 +321,7 @@ if (__DEV__) {
321 };
322
323 ReactStrictModeWarnings.flushLegacyContextWarning = () => {
324 - ((pendingLegacyContextWarning: any): FiberToFiberComponentsMap).forEach(
324 + (pendingLegacyContextWarning as any as FiberToFiberComponentsMap).forEach(
325 (fiberArray: FiberArray, strictRoot) => {
326 if (fiberArray.length === 0) {
327 return;
packages/react-reconciler/src/ReactTestSelectors.js
+18 -18
@@ -118,7 +118,7 @@ export function createTestNameSelector(id: string): TestNameSelector {
118 }
119
120 function findFiberRootForHostRoot(hostRoot: Instance): Fiber {
121 - const maybeFiber = getInstanceFromNode((hostRoot: any));
121 + const maybeFiber = getInstanceFromNode(hostRoot as any);
122 if (maybeFiber != null) {
123 if (typeof maybeFiber.memoizedProps['data-testname'] !== 'string') {
124 throw new Error(
@@ -126,7 +126,7 @@ function findFiberRootForHostRoot(hostRoot: Instance): Fiber {
126 );
127 }
128
129 - return ((maybeFiber: any): Fiber);
129 + return maybeFiber as any as Fiber;
130 } else {
131 const fiberRoot = findFiberRoot(hostRoot);
132
@@ -139,7 +139,7 @@ function findFiberRootForHostRoot(hostRoot: Instance): Fiber {
139
140 // The Flow type for FiberRoot is a little funky.
141 // createFiberRoot() cheats this by treating the root as :any and adding stateNode lazily.
142 - return ((fiberRoot: any).stateNode.current: Fiber);
142 + return (fiberRoot as any).stateNode.current as Fiber;
143 }
144 }
145
@@ -154,7 +154,7 @@ function matchSelector(fiber: Fiber, selector: Selector): boolean {
154 case HAS_PSEUDO_CLASS_TYPE:
155 return hasMatchingPaths(
156 fiber,
157 - ((selector: any): HasPseudoClassSelector).value,
157 + (selector as any as HasPseudoClassSelector).value,
158 );
159 case ROLE_TYPE:
160 if (
@@ -164,7 +164,7 @@ function matchSelector(fiber: Fiber, selector: Selector): boolean {
164 ) {
165 const node = fiber.stateNode;
166 if (
167 - matchAccessibilityRole(node, ((selector: any): RoleSelector).value)
167 + matchAccessibilityRole(node, (selector as any as RoleSelector).value)
168 ) {
169 return true;
170 }
@@ -182,7 +182,7 @@ function matchSelector(fiber: Fiber, selector: Selector): boolean {
182 if (
183 // $FlowFixMe[invalid-compare]
184 textContent !== null &&
185 - textContent.indexOf(((selector: any): TextSelector).value) >= 0
185 + textContent.indexOf((selector as any as TextSelector).value) >= 0
186 ) {
187 return true;
188 }
@@ -198,7 +198,7 @@ function matchSelector(fiber: Fiber, selector: Selector): boolean {
198 if (
199 typeof dataTestID === 'string' &&
200 dataTestID.toLowerCase() ===
201 - ((selector: any): TestNameSelector).value.toLowerCase()
201 + (selector as any as TestNameSelector).value.toLowerCase()
202 ) {
203 return true;
204 }
@@ -219,11 +219,11 @@ function selectorToString(selector: Selector): string | null {
219 case HAS_PSEUDO_CLASS_TYPE:
220 return `:has(${selectorToString(selector) || ''})`;
221 case ROLE_TYPE:
222 - return `[role="${((selector: any): RoleSelector).value}"]`;
222 + return `[role="${(selector as any as RoleSelector).value}"]`;
223 case TEXT_TYPE:
224 - return `"${((selector: any): TextSelector).value}"`;
224 + return `"${(selector as any as TextSelector).value}"`;
225 case TEST_NAME_TYPE:
226 - return `[data-testname="${((selector: any): TestNameSelector).value}"]`;
226 + return `[data-testname="${(selector as any as TestNameSelector).value}"]`;
227 default:
228 throw new Error('Invalid selector type specified.');
229 }
@@ -235,9 +235,9 @@ function findPaths(root: Fiber, selectors: Array<Selector>): Array<Fiber> {
235 const stack = [root, 0];
236 let index = 0;
237 while (index < stack.length) {
238 - const fiber = ((stack[index++]: any): Fiber);
238 + const fiber = stack[index++] as any as Fiber;
239 const tag = fiber.tag;
240 - let selectorIndex = ((stack[index++]: any): number);
240 + let selectorIndex = stack[index++] as any as number;
241 let selector = selectors[selectorIndex];
242
243 if (
@@ -273,9 +273,9 @@ function hasMatchingPaths(root: Fiber, selectors: Array<Selector>): boolean {
273 const stack = [root, 0];
274 let index = 0;
275 while (index < stack.length) {
276 - const fiber = ((stack[index++]: any): Fiber);
276 + const fiber = stack[index++] as any as Fiber;
277 const tag = fiber.tag;
278 - let selectorIndex = ((stack[index++]: any): number);
278 + let selectorIndex = stack[index++] as any as number;
279 let selector = selectors[selectorIndex];
280
281 if (
@@ -323,7 +323,7 @@ export function findAllNodes(
323 const stack = Array.from(matchingFibers);
324 let index = 0;
325 while (index < stack.length) {
326 - const node = ((stack[index++]: any): Fiber);
326 + const node = stack[index++] as any as Fiber;
327 const tag = node.tag;
328 if (
329 tag === HostComponent ||
@@ -364,9 +364,9 @@ export function getFindAllNodesFailureDescription(
364 const stack = [root, 0];
365 let index = 0;
366 while (index < stack.length) {
367 - const fiber = ((stack[index++]: any): Fiber);
367 + const fiber = stack[index++] as any as Fiber;
368 const tag = fiber.tag;
369 - let selectorIndex = ((stack[index++]: any): number);
369 + let selectorIndex = stack[index++] as any as number;
370 const selector = selectors[selectorIndex];
371
372 if (
@@ -524,7 +524,7 @@ export function focusWithin(
524 const stack = Array.from(matchingFibers);
525 let index = 0;
526 while (index < stack.length) {
527 - const fiber = ((stack[index++]: any): Fiber);
527 + const fiber = stack[index++] as any as Fiber;
528 const tag = fiber.tag;
529 if (isHiddenSubtree(fiber)) {
530 continue;
packages/react-reconciler/src/getComponentNameFromFiber.js
+5 -5
@@ -60,7 +60,7 @@ function getWrappedName(
60 ): string {
61 const functionName = innerType.displayName || innerType.name || '';
62 return (
63 - (outerType: any).displayName ||
63 + (outerType as any).displayName ||
64 (functionName !== '' ? `${wrapperName}(${functionName})` : wrapperName)
65 );
66 }
@@ -74,7 +74,7 @@ export function getComponentNameFromOwner(
74 owner: Fiber | ReactComponentInfo,
75 ): string | null {
76 if (typeof owner.tag === 'number') {
77 - return getComponentNameFromFiber((owner: any));
77 + return getComponentNameFromFiber(owner as any);
78 }
79 if (typeof owner.name === 'string') {
80 return owner.name;
@@ -90,10 +90,10 @@ export default function getComponentNameFromFiber(fiber: Fiber): string | null {
90 case CacheComponent:
91 return 'Cache';
92 case ContextConsumer:
93 - const consumer: ReactConsumerType<any> = (type: any);
93 + const consumer: ReactConsumerType<any> = type as any;
94 return getContextName(consumer._context) + '.Consumer';
95 case ContextProvider:
96 - const context: ReactContext<any> = (type: any);
96 + const context: ReactContext<any> = type as any;
97 return getContextName(context);
98 case DehydratedFragment:
99 return 'DehydratedFragment';
@@ -153,7 +153,7 @@ export default function getComponentNameFromFiber(fiber: Fiber): string | null {
153 case MemoComponent:
154 case SimpleMemoComponent:
155 if (typeof type === 'function') {
156 - return (type: any).displayName || type.name || null;
156 + return (type as any).displayName || type.name || null;
157 }
158 if (typeof type === 'string') {
159 return type;
packages/react-refresh/src/ReactFreshRuntime.js
+2 -2
@@ -463,7 +463,7 @@ export function injectIntoGlobalHook(globalObject: any): void {
463 typeof injected.setRefreshHandler === 'function'
464 ) {
465 // This version supports React Refresh.
466 - helpersByRendererID.set(id, ((injected: any): RendererHelpers));
466 + helpersByRendererID.set(id, injected as any as RendererHelpers);
467 }
468 return id;
469 };
@@ -477,7 +477,7 @@ export function injectIntoGlobalHook(globalObject: any): void {
477 typeof injected.setRefreshHandler === 'function'
478 ) {
479 // This version supports React Refresh.
480 - helpersByRendererID.set(id, ((injected: any): RendererHelpers));
480 + helpersByRendererID.set(id, injected as any as RendererHelpers);
481 }
482 });
483
packages/react-server-dom-esm/src/ReactFlightESMReferences.js
+2 -2
@@ -65,7 +65,7 @@ function bind(this: ServerReference<any>): any {
65 const $$id = {value: this.$$id};
66 const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
67 return Object.defineProperties(
68 - (newFn: any),
68 + newFn as any,
69 (__DEV__
70 ? {
71 $$typeof,
@@ -106,7 +106,7 @@ export function registerServerReference<T: Function>(
106 };
107 const $$bound = {value: null, configurable: true};
108 return Object.defineProperties(
109 - (reference: any),
109 + reference as any,
110 (__DEV__
111 ? {
112 $$typeof,
packages/react-server-dom-esm/src/client/ReactFlightClientConfigBundlerESM.js
+6 -6
@@ -95,12 +95,12 @@ export function preloadModule<T>(
95 modulePromise.then(
96 value => {
97 const fulfilledThenable: FulfilledThenable<mixed> =
98 - (modulePromise: any);
98 + modulePromise as any;
99 fulfilledThenable.status = 'fulfilled';
100 fulfilledThenable.value = value;
101 },
102 reason => {
103 - const rejectedThenable: RejectedThenable<mixed> = (modulePromise: any);
103 + const rejectedThenable: RejectedThenable<mixed> = modulePromise as any;
104 rejectedThenable.status = 'rejected';
105 rejectedThenable.reason = reason;
106 },
@@ -126,7 +126,7 @@ export function requireModule<T>(metadata: ClientReference<T>): T {
126 // We cache ReactIOInfo across requests so that inner refreshes can dedupe with outer.
127 const moduleIOInfoCache: Map<string, ReactIOInfo> = __DEV__
128 ? new Map()
129 - : (null: any);
129 + : (null as any);
130
131 export function getModuleDebugInfo<T>(
132 metadata: ClientReference<T>,
@@ -157,7 +157,7 @@ export function getModuleDebugInfo<T>(
157 start = resourceEntry.startTime;
158 end = start + resourceEntry.duration;
159 // $FlowFixMe[prop-missing]
160 - byteSize = (resourceEntry.transferSize: any) || 0;
160 + byteSize = (resourceEntry.transferSize as any) || 0;
161 }
162 }
163 }
@@ -193,13 +193,13 @@ export function getModuleDebugInfo<T>(
193 href +
194 ':1:1';
195 }
196 - ioInfo = ({
196 + ioInfo = {
197 name: 'script',
198 start: start,
199 end: end,
200 value: value,
201 debugStack: fakeStack,
202 - }: ReactIOInfo);
202 + } as ReactIOInfo;
203 if (byteSize > 0) {
204 // $FlowFixMe[cannot-write]
205 ioInfo.byteSize = byteSize;
packages/react-server-dom-esm/src/client/ReactFlightDOMClientBrowser.js
+5 -5
@@ -174,7 +174,7 @@ function startReadingFromStream(
174 if (done) {
175 return onDone();
176 }
177 - const buffer: Uint8Array = (value: any);
177 + const buffer: Uint8Array = value as any;
178 processBinaryChunk(response, streamState, buffer);
179 return reader.read().then(progress).catch(error);
180 }
@@ -241,11 +241,11 @@ function createFromFetch<T>(
241 options.debugChannel.readable,
242 handleDone,
243 );
244 - startReadingFromStream(response, (r.body: any), handleDone, r);
244 + startReadingFromStream(response, r.body as any, handleDone, r);
245 } else {
246 startReadingFromStream(
247 response,
248 - (r.body: any),
248 + r.body as any,
249 close.bind(null, response),
250 r,
251 );
@@ -277,10 +277,10 @@ function encodeReply(
277 if (options && options.signal) {
278 const signal = options.signal;
279 if (signal.aborted) {
280 - abort((signal: any).reason);
280 + abort((signal as any).reason);
281 } else {
282 const listener = () => {
283 - abort((signal: any).reason);
283 + abort((signal as any).reason);
284 signal.removeEventListener('abort', listener);
285 };
286 signal.addEventListener('abort', listener);
packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js
+13 -13
@@ -94,7 +94,7 @@ function startReadingFromDebugChannelReadable(
94 }
95 stringBuffer += chunk;
96 } else {
97 - const buffer: Uint8Array = (chunk: any);
97 + const buffer: Uint8Array = chunk as any;
98 stringBuffer += readPartialStringChunk(stringDecoder, buffer);
99 lastWasPartial = true;
100 }
@@ -121,7 +121,7 @@ function startReadingFromDebugChannelReadable(
121 // $FlowFixMe[method-unbinding]
122 typeof stream.binaryType === 'string'
123 ) {
124 - const ws: WebSocket = (stream: any);
124 + const ws: WebSocket = stream as any;
125 ws.binaryType = 'arraybuffer';
126 ws.addEventListener('message', event => {
127 // $FlowFixMe[incompatible-type]
@@ -133,7 +133,7 @@ function startReadingFromDebugChannelReadable(
133 });
134 ws.addEventListener('close', onClose);
135 } else {
136 - const readable: Readable = (stream: any);
136 + const readable: Readable = stream as any;
137 readable.on('data', onData);
138 readable.on('error', onError);
139 readable.on('end', onClose);
@@ -167,16 +167,16 @@ function renderToPipeableStream(
167 // $FlowFixMe[method-unbinding]
168 (typeof debugChannel.read === 'function' ||
169 typeof debugChannel.readyState === 'number')
170 - ? (debugChannel: any)
170 + ? (debugChannel as any)
171 : undefined;
172 const debugChannelWritable: void | Writable =
173 __DEV__ && debugChannel !== undefined
174 ? // $FlowFixMe[method-unbinding]
175 typeof debugChannel.write === 'function'
176 - ? (debugChannel: any)
176 + ? (debugChannel as any)
177 : // $FlowFixMe[method-unbinding]
178 typeof debugChannel.send === 'function'
179 - ? createFakeWritableFromWebSocket((debugChannel: any))
179 + ? createFakeWritableFromWebSocket(debugChannel as any)
180 : undefined
181 : undefined;
182 const request = createRequest(
@@ -231,9 +231,9 @@ function renderToPipeableStream(
231 }
232
233 function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
234 - return ({
234 + return {
235 write(chunk: string | Uint8Array) {
236 - webSocket.send((chunk: any));
236 + webSocket.send(chunk as any);
237 return true;
238 },
239 end() {
@@ -249,13 +249,13 @@ function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
249 webSocket.close(1011);
250 }
251 },
252 - }: any);
252 + } as any;
253 }
254
255 function createFakeWritable(readable: any): Writable {
256 // The current host config expects a Writable so we create
257 // a fake writable for now to push into the Readable.
258 - return ({
258 + return {
259 write(chunk: string | Uint8Array) {
260 return readable.push(chunk);
261 },
@@ -265,7 +265,7 @@ function createFakeWritable(readable: any): Writable {
265 destroy(error) {
266 readable.destroy(error);
267 },
268 - }: any);
268 + } as any;
269 }
270
271 type PrerenderOptions = {
@@ -315,11 +315,11 @@ function prerenderToNodeStream(
315 if (options && options.signal) {
316 const signal = options.signal;
317 if (signal.aborted) {
318 - const reason = (signal: any).reason;
318 + const reason = (signal as any).reason;
319 abort(request, reason);
320 } else {
321 const listener = () => {
322 - const reason = (signal: any).reason;
322 + const reason = (signal as any).reason;
323 abort(request, reason);
324 signal.removeEventListener('abort', listener);
325 };
packages/react-server-dom-fb/src/ReactDOMServerFB.js
+1 -1
@@ -103,7 +103,7 @@ function hasFinished(stream: Stream): boolean {
103
104 function debug(stream: Stream): any {
105 // convert to any to silence flow errors from opaque type
106 - const request = (stream.request: any);
106 + const request = stream.request as any;
107 return {
108 pendingRootTasks: request.pendingRootTasks,
109 clientRenderedBoundaries: request.clientRenderedBoundaries.length,
packages/react-server-dom-parcel/src/ReactFlightParcelReferences.js
+2 -2
@@ -72,7 +72,7 @@ function bind(this: ServerReference<any>): any {
72 const $$id = {value: this.$$id};
73 const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
74 return Object.defineProperties(
75 - (newFn: any),
75 + newFn as any,
76 (__DEV__
77 ? {
78 $$typeof,
@@ -113,7 +113,7 @@ export function registerServerReference<T>(
113 };
114 const $$bound = {value: null, configurable: true};
115 return Object.defineProperties(
116 - (reference: any),
116 + reference as any,
117 (__DEV__
118 ? {
119 $$typeof,
packages/react-server-dom-parcel/src/client/ReactFlightClientConfigBundlerParcel.js
+1 -1
@@ -83,7 +83,7 @@ export function requireModule<T>(metadata: ClientReference<T>): T {
83 if (hasOwnProperty.call(moduleExports, metadata[NAME])) {
84 return moduleExports[metadata[NAME]];
85 }
86 - return (undefined: any);
86 + return undefined as any;
87 }
88
89 export function getModuleDebugInfo<T>(
packages/react-server-dom-parcel/src/client/ReactFlightDOMClientBrowser.js
+5 -5
@@ -197,7 +197,7 @@ function startReadingFromStream(
197 if (done) {
198 return onDone();
199 }
200 - const buffer: Uint8Array = (value: any);
200 + const buffer: Uint8Array = value as any;
201 processBinaryChunk(response, streamState, buffer);
202 return reader.read().then(progress).catch(error);
203 }
@@ -275,11 +275,11 @@ export function createFromFetch<T>(
275 options.debugChannel.readable,
276 handleDone,
277 );
278 - startReadingFromStream(response, (r.body: any), handleDone, r);
278 + startReadingFromStream(response, r.body as any, handleDone, r);
279 } else {
280 startReadingFromStream(
281 response,
282 - (r.body: any),
282 + r.body as any,
283 close.bind(null, response),
284 r,
285 );
@@ -311,10 +311,10 @@ export function encodeReply(
311 if (options && options.signal) {
312 const signal = options.signal;
313 if (signal.aborted) {
314 - abort((signal: any).reason);
314 + abort((signal as any).reason);
315 } else {
316 const listener = () => {
317 - abort((signal: any).reason);
317 + abort((signal as any).reason);
318 signal.removeEventListener('abort', listener);
319 };
320 signal.addEventListener('abort', listener);
packages/react-server-dom-parcel/src/client/ReactFlightDOMClientEdge.js
+5 -5
@@ -140,7 +140,7 @@ function startReadingFromStream(
140 if (done) {
141 return onDone();
142 }
143 - const buffer: Uint8Array = (value: any);
143 + const buffer: Uint8Array = value as any;
144 processBinaryChunk(response, streamState, buffer);
145 return reader.read().then(progress).catch(error);
146 }
@@ -206,11 +206,11 @@ export function createFromFetch<T>(
206 options.debugChannel.readable,
207 handleDone,
208 );
209 - startReadingFromStream(response, (r.body: any), handleDone, r);
209 + startReadingFromStream(response, r.body as any, handleDone, r);
210 } else {
211 startReadingFromStream(
212 response,
213 - (r.body: any),
213 + r.body as any,
214 close.bind(null, response),
215 r,
216 );
@@ -242,10 +242,10 @@ export function encodeReply(
242 if (options && options.signal) {
243 const signal = options.signal;
244 if (signal.aborted) {
245 - abort((signal: any).reason);
245 + abort((signal as any).reason);
246 } else {
247 const listener = () => {
248 - abort((signal: any).reason);
248 + abort((signal as any).reason);
249 signal.removeEventListener('abort', listener);
250 };
251 signal.addEventListener('abort', listener);
packages/react-server-dom-parcel/src/server/ReactFlightDOMServerBrowser.js
+5 -5
@@ -86,7 +86,7 @@ function startReadingFromDebugChannelReadableStream(
86 value: ?any,
87 ...
88 }): void | Promise<void> {
89 - const buffer: Uint8Array = (value: any);
89 + const buffer: Uint8Array = value as any;
90 stringBuffer += done
91 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
92 : readPartialStringChunk(stringDecoder, buffer);
@@ -138,10 +138,10 @@ export function renderToReadableStream(
138 if (options && options.signal) {
139 const signal = options.signal;
140 if (signal.aborted) {
141 - abort(request, (signal: any).reason);
141 + abort(request, (signal as any).reason);
142 } else {
143 const listener = () => {
144 - abort(request, (signal: any).reason);
144 + abort(request, (signal as any).reason);
145 signal.removeEventListener('abort', listener);
146 };
147 signal.addEventListener('abort', listener);
@@ -229,11 +229,11 @@ export function prerender(
229 if (options && options.signal) {
230 const signal = options.signal;
231 if (signal.aborted) {
232 - const reason = (signal: any).reason;
232 + const reason = (signal as any).reason;
233 abort(request, reason);
234 } else {
235 const listener = () => {
236 - const reason = (signal: any).reason;
236 + const reason = (signal as any).reason;
237 abort(request, reason);
238 signal.removeEventListener('abort', listener);
239 };
packages/react-server-dom-parcel/src/server/ReactFlightDOMServerEdge.js
+6 -6
@@ -91,7 +91,7 @@ function startReadingFromDebugChannelReadableStream(
91 value: ?any,
92 ...
93 }): void | Promise<void> {
94 - const buffer: Uint8Array = (value: any);
94 + const buffer: Uint8Array = value as any;
95 stringBuffer += done
96 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
97 : readPartialStringChunk(stringDecoder, buffer);
@@ -143,10 +143,10 @@ export function renderToReadableStream(
143 if (options && options.signal) {
144 const signal = options.signal;
145 if (signal.aborted) {
146 - abort(request, (signal: any).reason);
146 + abort(request, (signal as any).reason);
147 } else {
148 const listener = () => {
149 - abort(request, (signal: any).reason);
149 + abort(request, (signal as any).reason);
150 signal.removeEventListener('abort', listener);
151 };
152 signal.addEventListener('abort', listener);
@@ -234,11 +234,11 @@ export function prerender(
234 if (options && options.signal) {
235 const signal = options.signal;
236 if (signal.aborted) {
237 - const reason = (signal: any).reason;
237 + const reason = (signal as any).reason;
238 abort(request, reason);
239 } else {
240 const listener = () => {
241 - const reason = (signal: any).reason;
241 + const reason = (signal as any).reason;
242 abort(request, reason);
243 signal.removeEventListener('abort', listener);
244 };
@@ -311,7 +311,7 @@ export function decodeReplyFromAsyncIterable<T>(
311 }
312 function error(reason: Error) {
313 reportGlobalError(response, reason);
314 - if (typeof (iterator: any).throw === 'function') {
314 + if (typeof (iterator as any).throw === 'function') {
315 // The iterator protocol doesn't necessarily include this but a generator do.
316 // $FlowFixMe[prop-missing] should be able to pass mixed
317 iterator.throw(reason).then(error, error);
packages/react-server-dom-parcel/src/server/ReactFlightDOMServerNode.js
+21 -21
@@ -107,7 +107,7 @@ function startReadingFromDebugChannelReadable(
107 }
108 stringBuffer += chunk;
109 } else {
110 - const buffer: Uint8Array = (chunk: any);
110 + const buffer: Uint8Array = chunk as any;
111 stringBuffer += readPartialStringChunk(stringDecoder, buffer);
112 lastWasPartial = true;
113 }
@@ -134,7 +134,7 @@ function startReadingFromDebugChannelReadable(
134 // $FlowFixMe[method-unbinding]
135 typeof stream.binaryType === 'string'
136 ) {
137 - const ws: WebSocket = (stream: any);
137 + const ws: WebSocket = stream as any;
138 ws.binaryType = 'arraybuffer';
139 ws.addEventListener('message', event => {
140 // $FlowFixMe[incompatible-type]
@@ -146,7 +146,7 @@ function startReadingFromDebugChannelReadable(
146 });
147 ws.addEventListener('close', onClose);
148 } else {
149 - const readable: Readable = (stream: any);
149 + const readable: Readable = stream as any;
150 readable.on('data', onData);
151 readable.on('error', onError);
152 readable.on('end', onClose);
@@ -179,16 +179,16 @@ export function renderToPipeableStream(
179 // $FlowFixMe[method-unbinding]
180 (typeof debugChannel.read === 'function' ||
181 typeof debugChannel.readyState === 'number')
182 - ? (debugChannel: any)
182 + ? (debugChannel as any)
183 : undefined;
184 const debugChannelWritable: void | Writable =
185 __DEV__ && debugChannel !== undefined
186 ? // $FlowFixMe[method-unbinding]
187 typeof debugChannel.write === 'function'
188 - ? (debugChannel: any)
188 + ? (debugChannel as any)
189 : // $FlowFixMe[method-unbinding]
190 typeof debugChannel.send === 'function'
191 - ? createFakeWritableFromWebSocket((debugChannel: any))
191 + ? createFakeWritableFromWebSocket(debugChannel as any)
192 : undefined
193 : undefined;
194 const request = createRequest(
@@ -243,9 +243,9 @@ export function renderToPipeableStream(
243 }
244
245 function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
246 - return ({
246 + return {
247 write(chunk: string | Uint8Array) {
248 - webSocket.send((chunk: any));
248 + webSocket.send(chunk as any);
249 return true;
250 },
251 end() {
@@ -261,7 +261,7 @@ function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
261 webSocket.close(1011);
262 }
263 },
264 - }: any);
264 + } as any;
265 }
266
267 function createFakeWritableFromReadableStreamController(
@@ -269,7 +269,7 @@ function createFakeWritableFromReadableStreamController(
269 ): Writable {
270 // The current host config expects a Writable so we create
271 // a fake writable for now to push into the Readable.
272 - return ({
272 + return {
273 write(chunk: string | Uint8Array) {
274 if (typeof chunk === 'string') {
275 chunk = textEncoder.encode(chunk);
@@ -290,7 +290,7 @@ function createFakeWritableFromReadableStreamController(
290 controller.close();
291 }
292 },
293 - }: any);
293 + } as any;
294 }
295
296 function startReadingFromDebugChannelReadableStream(
@@ -308,7 +308,7 @@ function startReadingFromDebugChannelReadableStream(
308 value: ?any,
309 ...
310 }): void | Promise<void> {
311 - const buffer: Uint8Array = (value: any);
311 + const buffer: Uint8Array = value as any;
312 stringBuffer += done
313 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
314 : readPartialStringChunk(stringDecoder, buffer);
@@ -363,10 +363,10 @@ export function renderToReadableStream(
363 if (options && options.signal) {
364 const signal = options.signal;
365 if (signal.aborted) {
366 - abort(request, (signal: any).reason);
366 + abort(request, (signal as any).reason);
367 } else {
368 const listener = () => {
369 - abort(request, (signal: any).reason);
369 + abort(request, (signal as any).reason);
370 signal.removeEventListener('abort', listener);
371 };
372 signal.addEventListener('abort', listener);
@@ -420,7 +420,7 @@ export function renderToReadableStream(
420 function createFakeWritableFromNodeReadable(readable: any): Writable {
421 // The current host config expects a Writable so we create
422 // a fake writable for now to push into the Readable.
423 - return ({
423 + return {
424 write(chunk: string | Uint8Array) {
425 return readable.push(chunk);
426 },
@@ -430,7 +430,7 @@ function createFakeWritableFromNodeReadable(readable: any): Writable {
430 destroy(error) {
431 readable.destroy(error);
432 },
433 - }: any);
433 + } as any;
434 }
435
436 type PrerenderOptions = {
@@ -479,11 +479,11 @@ export function prerenderToNodeStream(
479 if (options && options.signal) {
480 const signal = options.signal;
481 if (signal.aborted) {
482 - const reason = (signal: any).reason;
482 + const reason = (signal as any).reason;
483 abort(request, reason);
484 } else {
485 const listener = () => {
486 - const reason = (signal: any).reason;
486 + const reason = (signal as any).reason;
487 abort(request, reason);
488 signal.removeEventListener('abort', listener);
489 };
@@ -543,11 +543,11 @@ export function prerender(
543 if (options && options.signal) {
544 const signal = options.signal;
545 if (signal.aborted) {
546 - const reason = (signal: any).reason;
546 + const reason = (signal as any).reason;
547 abort(request, reason);
548 } else {
549 const listener = () => {
550 - const reason = (signal: any).reason;
550 + const reason = (signal as any).reason;
551 abort(request, reason);
552 signal.removeEventListener('abort', listener);
553 };
@@ -769,7 +769,7 @@ export function decodeReplyFromAsyncIterable<T>(
769 }
770 function error(reason: Error) {
771 reportGlobalError(response, reason);
772 - if (typeof (iterator: any).throw === 'function') {
772 + if (typeof (iterator as any).throw === 'function') {
773 // The iterator protocol doesn't necessarily include this but a generator do.
774 // $FlowFixMe[prop-missing] should be able to pass mixed
775 iterator.throw(reason).then(error, error);
packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js
+12 -14
@@ -79,7 +79,7 @@ function bind(this: ServerReference<any>): any {
79 const $$id = {value: this.$$id};
80 const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
81 return Object.defineProperties(
82 - (newFn: any),
82 + newFn as any,
83 (__DEV__
84 ? {
85 $$typeof,
@@ -120,7 +120,7 @@ export function registerServerReference<T: Function>(
120 };
121 const $$bound = {value: null, configurable: true};
122 return Object.defineProperties(
123 - (reference: any),
123 + reference as any,
124 (__DEV__
125 ? {
126 $$typeof,
@@ -237,14 +237,14 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
237 // an ESM compat module but then we'll check again on the client.
238 const moduleId = target.$$id;
239 target.default = registerClientReferenceImpl(
240 - (function () {
240 + function () {
241 throw new Error(
242 `Attempted to call the default export of ${moduleId} from the server ` +
243 `but it's on the client. It's not possible to invoke a client function from ` +
244 `the server, it can only be rendered as a Component or passed to props of a ` +
245 `Client Component.`,
246 );
247 - }: any),
247 + } as any,
248 target.$$id + '#',
249 target.$$async,
250 );
@@ -260,7 +260,7 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
260 // the client.
261
262 const clientReference: ClientReference<any> =
263 - registerClientReferenceImpl(({}: any), target.$$id, true);
263 + registerClientReferenceImpl({} as any, target.$$id, true);
264 // $FlowFixMe[incompatible-variance]
265 // $FlowFixMe[incompatible-type]
266 const proxy = new Proxy(clientReference, proxyHandlers);
@@ -270,10 +270,10 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
270 target.value = proxy;
271
272 const then = (target.then = registerClientReferenceImpl(
273 - (function then(resolve, reject: any) {
273 + function then(resolve, reject: any) {
274 // Expose to React.
275 return Promise.resolve(resolve(proxy));
276 - }: any),
276 + } as any,
277 // If this is not used as a Promise but is treated as a reference to a `.then`
278 // export then we should treat it as a reference to that name.
279 target.$$id + '#then',
@@ -296,20 +296,18 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
296 let cachedReference = target[name];
297 if (!cachedReference) {
298 const reference: ClientReference<any> = registerClientReferenceImpl(
299 - (function () {
299 + function () {
300 throw new Error(
301 // eslint-disable-next-line react-internal/safe-string-coercion
302 - `Attempted to call ${String(name)}() from the server but ${String(
303 - name,
304 - )} is on the client. ` +
302 + `Attempted to call ${String(name)}() from the server but ${String(name)} is on the client. ` +
303 `It's not possible to invoke a client function from the server, it can ` +
304 `only be rendered as a Component or passed to props of a Client Component.`,
305 );
308 - }: any),
306 + } as any,
307 target.$$id + '#' + name,
308 target.$$async,
309 );
312 - Object.defineProperty((reference: any), 'name', {value: name});
310 + Object.defineProperty(reference as any, 'name', {value: name});
311 cachedReference = target[name] = new Proxy(reference, deepProxyHandlers);
312 }
313 return cachedReference;
@@ -352,7 +350,7 @@ export function createClientModuleProxy<T>(
350 moduleId: string,
351 ): ClientReference<T> {
352 const clientReference: ClientReference<T> = registerClientReferenceImpl(
355 - ({}: any),
353 + {} as any,
354 // Represents the whole Module object instead of a particular import.
355 moduleId,
356 false,
packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopack.js
+3 -3
@@ -163,12 +163,12 @@ function requireAsyncModule(id: string): null | Thenable<any> {
163 // Instrument the Promise to stash the result.
164 promise.then(
165 value => {
166 - const fulfilledThenable: FulfilledThenable<mixed> = (promise: any);
166 + const fulfilledThenable: FulfilledThenable<mixed> = promise as any;
167 fulfilledThenable.status = 'fulfilled';
168 fulfilledThenable.value = value;
169 },
170 reason => {
171 - const rejectedThenable: RejectedThenable<mixed> = (promise: any);
171 + const rejectedThenable: RejectedThenable<mixed> = promise as any;
172 rejectedThenable.status = 'rejected';
173 rejectedThenable.reason = reason;
174 },
@@ -250,7 +250,7 @@ export function requireModule<T>(metadata: ClientReference<T>): T {
250 if (hasOwnProperty.call(moduleExports, metadata[NAME])) {
251 return moduleExports[metadata[NAME]];
252 }
253 - return (undefined: any);
253 + return undefined as any;
254 }
255
256 export function getModuleDebugInfo<T>(
packages/react-server-dom-turbopack/src/client/ReactFlightClientConfigBundlerTurbopackBrowser.js
+4 -4
@@ -20,7 +20,7 @@ export function loadChunk(filename: string): Promise<mixed> {
20 // We cache ReactIOInfo across requests so that inner refreshes can dedupe with outer.
21 const chunkIOInfoCache: Map<string, ReactIOInfo> = __DEV__
22 ? new Map()
23 - : (null: any);
23 + : (null as any);
24
25 export function addChunkDebugInfo(
26 target: ReactDebugInfo,
@@ -51,7 +51,7 @@ export function addChunkDebugInfo(
51 start = resourceEntry.startTime;
52 end = start + resourceEntry.duration;
53 // $FlowFixMe[prop-missing]
54 - byteSize = (resourceEntry.transferSize: any) || 0;
54 + byteSize = (resourceEntry.transferSize as any) || 0;
55 }
56 }
57 }
@@ -87,13 +87,13 @@ export function addChunkDebugInfo(
87 href +
88 ':1:1';
89 }
90 - ioInfo = ({
90 + ioInfo = {
91 name: 'script',
92 start: start,
93 end: end,
94 value: value,
95 debugStack: fakeStack,
96 - }: ReactIOInfo);
96 + } as ReactIOInfo;
97 if (byteSize > 0) {
98 // $FlowFixMe[cannot-write]
99 ioInfo.byteSize = byteSize;
packages/react-server-dom-turbopack/src/client/ReactFlightDOMClientBrowser.js
+5 -5
@@ -173,7 +173,7 @@ function startReadingFromStream(
173 if (done) {
174 return onDone();
175 }
176 - const buffer: Uint8Array = (value: any);
176 + const buffer: Uint8Array = value as any;
177 processBinaryChunk(response, streamState, buffer);
178 return reader.read().then(progress).catch(error);
179 }
@@ -241,11 +241,11 @@ function createFromFetch<T>(
241 options.debugChannel.readable,
242 handleDone,
243 );
244 - startReadingFromStream(response, (r.body: any), handleDone, r);
244 + startReadingFromStream(response, r.body as any, handleDone, r);
245 } else {
246 startReadingFromStream(
247 response,
248 - (r.body: any),
248 + r.body as any,
249 close.bind(null, response),
250 r,
251 );
@@ -277,10 +277,10 @@ function encodeReply(
277 if (options && options.signal) {
278 const signal = options.signal;
279 if (signal.aborted) {
280 - abort((signal: any).reason);
280 + abort((signal as any).reason);
281 } else {
282 const listener = () => {
283 - abort((signal: any).reason);
283 + abort((signal as any).reason);
284 signal.removeEventListener('abort', listener);
285 };
286 signal.addEventListener('abort', listener);
packages/react-server-dom-turbopack/src/client/ReactFlightDOMClientEdge.js
+5 -5
@@ -142,7 +142,7 @@ function startReadingFromStream(
142 if (done) {
143 return onDone();
144 }
145 - const buffer: Uint8Array = (value: any);
145 + const buffer: Uint8Array = value as any;
146 processBinaryChunk(response, streamState, buffer);
147 return reader.read().then(progress).catch(error);
148 }
@@ -208,11 +208,11 @@ function createFromFetch<T>(
208 options.debugChannel.readable,
209 handleDone,
210 );
211 - startReadingFromStream(response, (r.body: any), handleDone, r);
211 + startReadingFromStream(response, r.body as any, handleDone, r);
212 } else {
213 startReadingFromStream(
214 response,
215 - (r.body: any),
215 + r.body as any,
216 close.bind(null, response),
217 r,
218 );
@@ -244,10 +244,10 @@ function encodeReply(
244 if (options && options.signal) {
245 const signal = options.signal;
246 if (signal.aborted) {
247 - abort((signal: any).reason);
247 + abort((signal as any).reason);
248 } else {
249 const listener = () => {
250 - abort((signal: any).reason);
250 + abort((signal as any).reason);
251 signal.removeEventListener('abort', listener);
252 };
253 signal.addEventListener('abort', listener);
packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerBrowser.js
+5 -5
@@ -82,7 +82,7 @@ function startReadingFromDebugChannelReadableStream(
82 value: ?any,
83 ...
84 }): void | Promise<void> {
85 - const buffer: Uint8Array = (value: any);
85 + const buffer: Uint8Array = value as any;
86 stringBuffer += done
87 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
88 : readPartialStringChunk(stringDecoder, buffer);
@@ -135,10 +135,10 @@ function renderToReadableStream(
135 if (options && options.signal) {
136 const signal = options.signal;
137 if (signal.aborted) {
138 - abort(request, (signal: any).reason);
138 + abort(request, (signal as any).reason);
139 } else {
140 const listener = () => {
141 - abort(request, (signal: any).reason);
141 + abort(request, (signal as any).reason);
142 signal.removeEventListener('abort', listener);
143 };
144 signal.addEventListener('abort', listener);
@@ -227,11 +227,11 @@ function prerender(
227 if (options && options.signal) {
228 const signal = options.signal;
229 if (signal.aborted) {
230 - const reason = (signal: any).reason;
230 + const reason = (signal as any).reason;
231 abort(request, reason);
232 } else {
233 const listener = () => {
234 - const reason = (signal: any).reason;
234 + const reason = (signal as any).reason;
235 abort(request, reason);
236 signal.removeEventListener('abort', listener);
237 };
packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerEdge.js
+6 -6
@@ -87,7 +87,7 @@ function startReadingFromDebugChannelReadableStream(
87 value: ?any,
88 ...
89 }): void | Promise<void> {
90 - const buffer: Uint8Array = (value: any);
90 + const buffer: Uint8Array = value as any;
91 stringBuffer += done
92 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
93 : readPartialStringChunk(stringDecoder, buffer);
@@ -140,10 +140,10 @@ function renderToReadableStream(
140 if (options && options.signal) {
141 const signal = options.signal;
142 if (signal.aborted) {
143 - abort(request, (signal: any).reason);
143 + abort(request, (signal as any).reason);
144 } else {
145 const listener = () => {
146 - abort(request, (signal: any).reason);
146 + abort(request, (signal as any).reason);
147 signal.removeEventListener('abort', listener);
148 };
149 signal.addEventListener('abort', listener);
@@ -232,11 +232,11 @@ function prerender(
232 if (options && options.signal) {
233 const signal = options.signal;
234 if (signal.aborted) {
235 - const reason = (signal: any).reason;
235 + const reason = (signal as any).reason;
236 abort(request, reason);
237 } else {
238 const listener = () => {
239 - const reason = (signal: any).reason;
239 + const reason = (signal as any).reason;
240 abort(request, reason);
241 signal.removeEventListener('abort', listener);
242 };
@@ -310,7 +310,7 @@ function decodeReplyFromAsyncIterable<T>(
310 }
311 function error(reason: Error) {
312 reportGlobalError(response, reason);
313 - if (typeof (iterator: any).throw === 'function') {
313 + if (typeof (iterator as any).throw === 'function') {
314 // The iterator protocol doesn't necessarily include this but a generator do.
315 // $FlowFixMe[prop-missing] should be able to pass mixed
316 iterator.throw(reason).then(error, error);
packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js
+21 -21
@@ -100,7 +100,7 @@ function startReadingFromDebugChannelReadable(
100 }
101 stringBuffer += chunk;
102 } else {
103 - const buffer: Uint8Array = (chunk: any);
103 + const buffer: Uint8Array = chunk as any;
104 stringBuffer += readPartialStringChunk(stringDecoder, buffer);
105 lastWasPartial = true;
106 }
@@ -127,7 +127,7 @@ function startReadingFromDebugChannelReadable(
127 // $FlowFixMe[method-unbinding]
128 typeof stream.binaryType === 'string'
129 ) {
130 - const ws: WebSocket = (stream: any);
130 + const ws: WebSocket = stream as any;
131 ws.binaryType = 'arraybuffer';
132 ws.addEventListener('message', event => {
133 // $FlowFixMe[incompatible-type]
@@ -139,7 +139,7 @@ function startReadingFromDebugChannelReadable(
139 });
140 ws.addEventListener('close', onClose);
141 } else {
142 - const readable: Readable = (stream: any);
142 + const readable: Readable = stream as any;
143 readable.on('data', onData);
144 readable.on('error', onError);
145 readable.on('end', onClose);
@@ -173,16 +173,16 @@ function renderToPipeableStream(
173 // $FlowFixMe[method-unbinding]
174 (typeof debugChannel.read === 'function' ||
175 typeof debugChannel.readyState === 'number')
176 - ? (debugChannel: any)
176 + ? (debugChannel as any)
177 : undefined;
178 const debugChannelWritable: void | Writable =
179 __DEV__ && debugChannel !== undefined
180 ? // $FlowFixMe[method-unbinding]
181 typeof debugChannel.write === 'function'
182 - ? (debugChannel: any)
182 + ? (debugChannel as any)
183 : // $FlowFixMe[method-unbinding]
184 typeof debugChannel.send === 'function'
185 - ? createFakeWritableFromWebSocket((debugChannel: any))
185 + ? createFakeWritableFromWebSocket(debugChannel as any)
186 : undefined
187 : undefined;
188 const request = createRequest(
@@ -237,9 +237,9 @@ function renderToPipeableStream(
237 }
238
239 function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
240 - return ({
240 + return {
241 write(chunk: string | Uint8Array) {
242 - webSocket.send((chunk: any));
242 + webSocket.send(chunk as any);
243 return true;
244 },
245 end() {
@@ -255,7 +255,7 @@ function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
255 webSocket.close(1011);
256 }
257 },
258 - }: any);
258 + } as any;
259 }
260
261 function createFakeWritableFromReadableStreamController(
@@ -263,7 +263,7 @@ function createFakeWritableFromReadableStreamController(
263 ): Writable {
264 // The current host config expects a Writable so we create
265 // a fake writable for now to push into the Readable.
266 - return ({
266 + return {
267 write(chunk: string | Uint8Array) {
268 if (typeof chunk === 'string') {
269 chunk = textEncoder.encode(chunk);
@@ -284,7 +284,7 @@ function createFakeWritableFromReadableStreamController(
284 controller.close();
285 }
286 },
287 - }: any);
287 + } as any;
288 }
289
290 function startReadingFromDebugChannelReadableStream(
@@ -302,7 +302,7 @@ function startReadingFromDebugChannelReadableStream(
302 value: ?any,
303 ...
304 }): void | Promise<void> {
305 - const buffer: Uint8Array = (value: any);
305 + const buffer: Uint8Array = value as any;
306 stringBuffer += done
307 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
308 : readPartialStringChunk(stringDecoder, buffer);
@@ -358,10 +358,10 @@ function renderToReadableStream(
358 if (options && options.signal) {
359 const signal = options.signal;
360 if (signal.aborted) {
361 - abort(request, (signal: any).reason);
361 + abort(request, (signal as any).reason);
362 } else {
363 const listener = () => {
364 - abort(request, (signal: any).reason);
364 + abort(request, (signal as any).reason);
365 signal.removeEventListener('abort', listener);
366 };
367 signal.addEventListener('abort', listener);
@@ -415,7 +415,7 @@ function renderToReadableStream(
415 function createFakeWritableFromNodeReadable(readable: any): Writable {
416 // The current host config expects a Writable so we create
417 // a fake writable for now to push into the Readable.
418 - return ({
418 + return {
419 write(chunk: string | Uint8Array) {
420 return readable.push(chunk);
421 },
@@ -425,7 +425,7 @@ function createFakeWritableFromNodeReadable(readable: any): Writable {
425 destroy(error) {
426 readable.destroy(error);
427 },
428 - }: any);
428 + } as any;
429 }
430
431 type PrerenderOptions = {
@@ -475,11 +475,11 @@ function prerenderToNodeStream(
475 if (options && options.signal) {
476 const signal = options.signal;
477 if (signal.aborted) {
478 - const reason = (signal: any).reason;
478 + const reason = (signal as any).reason;
479 abort(request, reason);
480 } else {
481 const listener = () => {
482 - const reason = (signal: any).reason;
482 + const reason = (signal as any).reason;
483 abort(request, reason);
484 signal.removeEventListener('abort', listener);
485 };
@@ -540,11 +540,11 @@ function prerender(
540 if (options && options.signal) {
541 const signal = options.signal;
542 if (signal.aborted) {
543 - const reason = (signal: any).reason;
543 + const reason = (signal as any).reason;
544 abort(request, reason);
545 } else {
546 const listener = () => {
547 - const reason = (signal: any).reason;
547 + const reason = (signal as any).reason;
548 abort(request, reason);
549 signal.removeEventListener('abort', listener);
550 };
@@ -763,7 +763,7 @@ function decodeReplyFromAsyncIterable<T>(
763 }
764 function error(reason: Error) {
765 reportGlobalError(response, reason);
766 - if (typeof (iterator: any).throw === 'function') {
766 + if (typeof (iterator as any).throw === 'function') {
767 // The iterator protocol doesn't necessarily include this but a generator do.
768 // $FlowFixMe[prop-missing] should be able to pass mixed
769 iterator.throw(reason).then(error, error);
packages/react-server-dom-unbundled/src/ReactFlightUnbundledNodeRegister.js
+4 -4
@@ -73,14 +73,14 @@ module.exports = function register() {
73 }
74
75 if (useClient) {
76 - const moduleId: string = (url.pathToFileURL(filename).href: any);
76 + const moduleId: string = url.pathToFileURL(filename).href as any;
77 this.exports = createClientModuleProxy(moduleId);
78 }
79
80 if (useServer) {
81 originalCompile.apply(this, arguments);
82
83 - const moduleId: string = (url.pathToFileURL(filename).href: any);
83 + const moduleId: string = url.pathToFileURL(filename).href as any;
84
85 const exports = this.exports;
86
@@ -89,7 +89,7 @@ module.exports = function register() {
89 if (typeof exports === 'function') {
90 // The module exports a function directly,
91 registerServerReference(
92 - (exports: any),
92 + exports as any,
93 moduleId,
94 // Represents the whole Module object instead of a particular import.
95 null,
@@ -100,7 +100,7 @@ module.exports = function register() {
100 const key = keys[i];
101 const value = exports[keys[i]];
102 if (typeof value === 'function') {
103 - registerServerReference((value: any), moduleId, key);
103 + registerServerReference(value as any, moduleId, key);
104 }
105 }
106 }
packages/react-server-dom-unbundled/src/ReactFlightUnbundledReferences.js
+11 -11
@@ -79,7 +79,7 @@ function bind(this: ServerReference<any>): any {
79 const $$id = {value: this.$$id};
80 const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
81 return Object.defineProperties(
82 - (newFn: any),
82 + newFn as any,
83 (__DEV__
84 ? {
85 $$typeof,
@@ -120,7 +120,7 @@ export function registerServerReference<T: Function>(
120 };
121 const $$bound = {value: null, configurable: true};
122 return Object.defineProperties(
123 - (reference: any),
123 + reference as any,
124 __DEV__
125 ? ({
126 $$typeof,
@@ -237,14 +237,14 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
237 // an ESM compat module but then we'll check again on the client.
238 const moduleId = target.$$id;
239 target.default = registerClientReferenceImpl(
240 - (function () {
240 + function () {
241 throw new Error(
242 `Attempted to call the default export of ${moduleId} from the server ` +
243 `but it's on the client. It's not possible to invoke a client function from ` +
244 `the server, it can only be rendered as a Component or passed to props of a ` +
245 `Client Component.`,
246 );
247 - }: any),
247 + } as any,
248 target.$$id + '#',
249 target.$$async,
250 );
@@ -260,7 +260,7 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
260 // the client.
261
262 const clientReference: ClientReference<any> =
263 - registerClientReferenceImpl(({}: any), target.$$id, true);
263 + registerClientReferenceImpl({} as any, target.$$id, true);
264 // $FlowFixMe[incompatible-variance]
265 // $FlowFixMe[incompatible-type]
266 const proxy = new Proxy(clientReference, proxyHandlers);
@@ -270,10 +270,10 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
270 target.value = proxy;
271
272 const then = (target.then = registerClientReferenceImpl(
273 - (function then(resolve, reject: any) {
273 + function then(resolve, reject: any) {
274 // Expose to React.
275 return Promise.resolve(resolve(proxy));
276 - }: any),
276 + } as any,
277 // If this is not used as a Promise but is treated as a reference to a `.then`
278 // export then we should treat it as a reference to that name.
279 target.$$id + '#then',
@@ -296,7 +296,7 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
296 let cachedReference = target[name];
297 if (!cachedReference) {
298 const reference: ClientReference<any> = registerClientReferenceImpl(
299 - (function () {
299 + function () {
300 throw new Error(
301 // eslint-disable-next-line react-internal/safe-string-coercion
302 `Attempted to call ${String(name)}() from the server but ${String(
@@ -305,11 +305,11 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
305 `It's not possible to invoke a client function from the server, it can ` +
306 `only be rendered as a Component or passed to props of a Client Component.`,
307 );
308 - }: any),
308 + } as any,
309 target.$$id + '#' + name,
310 target.$$async,
311 );
312 - Object.defineProperty((reference: any), 'name', {value: name});
312 + Object.defineProperty(reference as any, 'name', {value: name});
313 cachedReference = target[name] = new Proxy(reference, deepProxyHandlers);
314 }
315 return cachedReference;
@@ -352,7 +352,7 @@ export function createClientModuleProxy<T>(
352 moduleId: string,
353 ): ClientReference<T> {
354 const clientReference: ClientReference<T> = registerClientReferenceImpl(
355 - ({}: any),
355 + {} as any,
356 // Represents the whole Module object instead of a particular import.
357 moduleId,
358 false,
packages/react-server-dom-unbundled/src/client/ReactFlightClientConfigBundlerNode.js
+4 -4
@@ -119,18 +119,18 @@ export function preloadModule<T>(
119 // Node.js so we have to get the default export to get the
120 // full module exports.
121 modulePromise = modulePromise.then(function (value) {
122 - return (value: any).default;
122 + return (value as any).default;
123 });
124 }
125 modulePromise.then(
126 value => {
127 const fulfilledThenable: FulfilledThenable<mixed> =
128 - (modulePromise: any);
128 + modulePromise as any;
129 fulfilledThenable.status = 'fulfilled';
130 fulfilledThenable.value = value;
131 },
132 reason => {
133 - const rejectedThenable: RejectedThenable<mixed> = (modulePromise: any);
133 + const rejectedThenable: RejectedThenable<mixed> = modulePromise as any;
134 rejectedThenable.status = 'rejected';
135 rejectedThenable.reason = reason;
136 },
@@ -163,7 +163,7 @@ export function requireModule<T>(metadata: ClientReference<T>): T {
163 if (hasOwnProperty.call(moduleExports, metadata.name)) {
164 return moduleExports[metadata.name];
165 }
166 - return (undefined: any);
166 + return undefined as any;
167 }
168
169 export function getModuleDebugInfo<T>(metadata: ClientReference<T>): null {
packages/react-server-dom-unbundled/src/client/ReactFlightDOMClientEdge.js
+5 -5
@@ -142,7 +142,7 @@ function startReadingFromStream(
142 if (done) {
143 return onDone();
144 }
145 - const buffer: Uint8Array = (value: any);
145 + const buffer: Uint8Array = value as any;
146 processBinaryChunk(response, streamState, buffer);
147 return reader.read().then(progress).catch(error);
148 }
@@ -208,11 +208,11 @@ function createFromFetch<T>(
208 options.debugChannel.readable,
209 handleDone,
210 );
211 - startReadingFromStream(response, (r.body: any), handleDone, r);
211 + startReadingFromStream(response, r.body as any, handleDone, r);
212 } else {
213 startReadingFromStream(
214 response,
215 - (r.body: any),
215 + r.body as any,
216 close.bind(null, response),
217 r,
218 );
@@ -244,10 +244,10 @@ function encodeReply(
244 if (options && options.signal) {
245 const signal = options.signal;
246 if (signal.aborted) {
247 - abort((signal: any).reason);
247 + abort((signal as any).reason);
248 } else {
249 const listener = () => {
250 - abort((signal: any).reason);
250 + abort((signal as any).reason);
251 signal.removeEventListener('abort', listener);
252 };
253 signal.addEventListener('abort', listener);
packages/react-server-dom-unbundled/src/server/ReactFlightDOMServerNode.js
+21 -21
@@ -100,7 +100,7 @@ function startReadingFromDebugChannelReadable(
100 }
101 stringBuffer += chunk;
102 } else {
103 - const buffer: Uint8Array = (chunk: any);
103 + const buffer: Uint8Array = chunk as any;
104 stringBuffer += readPartialStringChunk(stringDecoder, buffer);
105 lastWasPartial = true;
106 }
@@ -127,7 +127,7 @@ function startReadingFromDebugChannelReadable(
127 // $FlowFixMe[method-unbinding]
128 typeof stream.binaryType === 'string'
129 ) {
130 - const ws: WebSocket = (stream: any);
130 + const ws: WebSocket = stream as any;
131 ws.binaryType = 'arraybuffer';
132 ws.addEventListener('message', event => {
133 // $FlowFixMe[incompatible-type]
@@ -139,7 +139,7 @@ function startReadingFromDebugChannelReadable(
139 });
140 ws.addEventListener('close', onClose);
141 } else {
142 - const readable: Readable = (stream: any);
142 + const readable: Readable = stream as any;
143 readable.on('data', onData);
144 readable.on('error', onError);
145 readable.on('end', onClose);
@@ -173,16 +173,16 @@ function renderToPipeableStream(
173 // $FlowFixMe[method-unbinding]
174 (typeof debugChannel.read === 'function' ||
175 typeof debugChannel.readyState === 'number')
176 - ? (debugChannel: any)
176 + ? (debugChannel as any)
177 : undefined;
178 const debugChannelWritable: void | Writable =
179 __DEV__ && debugChannel !== undefined
180 ? // $FlowFixMe[method-unbinding]
181 typeof debugChannel.write === 'function'
182 - ? (debugChannel: any)
182 + ? (debugChannel as any)
183 : // $FlowFixMe[method-unbinding]
184 typeof debugChannel.send === 'function'
185 - ? createFakeWritableFromWebSocket((debugChannel: any))
185 + ? createFakeWritableFromWebSocket(debugChannel as any)
186 : undefined
187 : undefined;
188 const request = createRequest(
@@ -237,9 +237,9 @@ function renderToPipeableStream(
237 }
238
239 function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
240 - return ({
240 + return {
241 write(chunk: string | Uint8Array) {
242 - webSocket.send((chunk: any));
242 + webSocket.send(chunk as any);
243 return true;
244 },
245 end() {
@@ -255,7 +255,7 @@ function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
255 webSocket.close(1011);
256 }
257 },
258 - }: any);
258 + } as any;
259 }
260
261 function createFakeWritableFromReadableStreamController(
@@ -263,7 +263,7 @@ function createFakeWritableFromReadableStreamController(
263 ): Writable {
264 // The current host config expects a Writable so we create
265 // a fake writable for now to push into the Readable.
266 - return ({
266 + return {
267 write(chunk: string | Uint8Array) {
268 if (typeof chunk === 'string') {
269 chunk = textEncoder.encode(chunk);
@@ -284,7 +284,7 @@ function createFakeWritableFromReadableStreamController(
284 controller.close();
285 }
286 },
287 - }: any);
287 + } as any;
288 }
289
290 function startReadingFromDebugChannelReadableStream(
@@ -302,7 +302,7 @@ function startReadingFromDebugChannelReadableStream(
302 value: ?any,
303 ...
304 }): void | Promise<void> {
305 - const buffer: Uint8Array = (value: any);
305 + const buffer: Uint8Array = value as any;
306 stringBuffer += done
307 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
308 : readPartialStringChunk(stringDecoder, buffer);
@@ -358,10 +358,10 @@ function renderToReadableStream(
358 if (options && options.signal) {
359 const signal = options.signal;
360 if (signal.aborted) {
361 - abort(request, (signal: any).reason);
361 + abort(request, (signal as any).reason);
362 } else {
363 const listener = () => {
364 - abort(request, (signal: any).reason);
364 + abort(request, (signal as any).reason);
365 signal.removeEventListener('abort', listener);
366 };
367 signal.addEventListener('abort', listener);
@@ -415,7 +415,7 @@ function renderToReadableStream(
415 function createFakeWritableFromNodeReadable(readable: any): Writable {
416 // The current host config expects a Writable so we create
417 // a fake writable for now to push into the Readable.
418 - return ({
418 + return {
419 write(chunk: string | Uint8Array) {
420 return readable.push(chunk);
421 },
@@ -425,7 +425,7 @@ function createFakeWritableFromNodeReadable(readable: any): Writable {
425 destroy(error) {
426 readable.destroy(error);
427 },
428 - }: any);
428 + } as any;
429 }
430
431 type PrerenderOptions = {
@@ -475,11 +475,11 @@ function prerenderToNodeStream(
475 if (options && options.signal) {
476 const signal = options.signal;
477 if (signal.aborted) {
478 - const reason = (signal: any).reason;
478 + const reason = (signal as any).reason;
479 abort(request, reason);
480 } else {
481 const listener = () => {
482 - const reason = (signal: any).reason;
482 + const reason = (signal as any).reason;
483 abort(request, reason);
484 signal.removeEventListener('abort', listener);
485 };
@@ -540,11 +540,11 @@ function prerender(
540 if (options && options.signal) {
541 const signal = options.signal;
542 if (signal.aborted) {
543 - const reason = (signal: any).reason;
543 + const reason = (signal as any).reason;
544 abort(request, reason);
545 } else {
546 const listener = () => {
547 - const reason = (signal: any).reason;
547 + const reason = (signal as any).reason;
548 abort(request, reason);
549 signal.removeEventListener('abort', listener);
550 };
@@ -763,7 +763,7 @@ function decodeReplyFromAsyncIterable<T>(
763 }
764 function error(reason: Error) {
765 reportGlobalError(response, reason);
766 - if (typeof (iterator: any).throw === 'function') {
766 + if (typeof (iterator as any).throw === 'function') {
767 // The iterator protocol doesn't necessarily include this but a generator do.
768 // $FlowFixMe[prop-missing] should be able to pass mixed
769 iterator.throw(reason).then(error, error);
packages/react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js
+4 -4
@@ -73,14 +73,14 @@ module.exports = function register() {
73 }
74
75 if (useClient) {
76 - const moduleId: string = (url.pathToFileURL(filename).href: any);
76 + const moduleId: string = url.pathToFileURL(filename).href as any;
77 this.exports = createClientModuleProxy(moduleId);
78 }
79
80 if (useServer) {
81 originalCompile.apply(this, arguments);
82
83 - const moduleId: string = (url.pathToFileURL(filename).href: any);
83 + const moduleId: string = url.pathToFileURL(filename).href as any;
84
85 const exports = this.exports;
86
@@ -89,7 +89,7 @@ module.exports = function register() {
89 if (typeof exports === 'function') {
90 // The module exports a function directly,
91 registerServerReference(
92 - (exports: any),
92 + exports as any,
93 moduleId,
94 // Represents the whole Module object instead of a particular import.
95 null,
@@ -100,7 +100,7 @@ module.exports = function register() {
100 const key = keys[i];
101 const value = exports[keys[i]];
102 if (typeof value === 'function') {
103 - registerServerReference((value: any), moduleId, key);
103 + registerServerReference(value as any, moduleId, key);
104 }
105 }
106 }
packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js
+1 -1
@@ -90,7 +90,7 @@ export default class ReactFlightWebpackPlugin {
90 typeof options.clientReferences === 'string' ||
91 !isArray(options.clientReferences)
92 ) {
93 - this.clientReferences = [(options.clientReferences: $FlowFixMe)];
93 + this.clientReferences = [options.clientReferences as $FlowFixMe];
94 } else {
95 // $FlowFixMe[incompatible-type] found when upgrading Flow
96 this.clientReferences = options.clientReferences;
packages/react-server-dom-webpack/src/ReactFlightWebpackReferences.js
+12 -14
@@ -79,7 +79,7 @@ function bind(this: ServerReference<any>): any {
79 const $$id = {value: this.$$id};
80 const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
81 return Object.defineProperties(
82 - (newFn: any),
82 + newFn as any,
83 (__DEV__
84 ? {
85 $$typeof,
@@ -120,7 +120,7 @@ export function registerServerReference<T: Function>(
120 };
121 const $$bound = {value: null, configurable: true};
122 return Object.defineProperties(
123 - (reference: any),
123 + reference as any,
124 __DEV__
125 ? ({
126 $$typeof,
@@ -237,14 +237,14 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
237 // an ESM compat module but then we'll check again on the client.
238 const moduleId = target.$$id;
239 target.default = registerClientReferenceImpl(
240 - (function () {
240 + function () {
241 throw new Error(
242 `Attempted to call the default export of ${moduleId} from the server ` +
243 `but it's on the client. It's not possible to invoke a client function from ` +
244 `the server, it can only be rendered as a Component or passed to props of a ` +
245 `Client Component.`,
246 );
247 - }: any),
247 + } as any,
248 target.$$id + '#',
249 target.$$async,
250 );
@@ -260,7 +260,7 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
260 // the client.
261
262 const clientReference: ClientReference<any> =
263 - registerClientReferenceImpl(({}: any), target.$$id, true);
263 + registerClientReferenceImpl({} as any, target.$$id, true);
264 // $FlowFixMe[incompatible-variance]
265 // $FlowFixMe[incompatible-type]
266 const proxy = new Proxy(clientReference, proxyHandlers);
@@ -270,10 +270,10 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
270 target.value = proxy;
271
272 const then = (target.then = registerClientReferenceImpl(
273 - (function then(resolve, reject: any) {
273 + function then(resolve, reject: any) {
274 // Expose to React.
275 return Promise.resolve(resolve(proxy));
276 - }: any),
276 + } as any,
277 // If this is not used as a Promise but is treated as a reference to a `.then`
278 // export then we should treat it as a reference to that name.
279 target.$$id + '#then',
@@ -296,20 +296,18 @@ function getReference(target: Function, name: string | symbol): $FlowFixMe {
296 let cachedReference = target[name];
297 if (!cachedReference) {
298 const reference: ClientReference<any> = registerClientReferenceImpl(
299 - (function () {
299 + function () {
300 throw new Error(
301 // eslint-disable-next-line react-internal/safe-string-coercion
302 - `Attempted to call ${String(name)}() from the server but ${String(
303 - name,
304 - )} is on the client. ` +
302 + `Attempted to call ${String(name)}() from the server but ${String(name)} is on the client. ` +
303 `It's not possible to invoke a client function from the server, it can ` +
304 `only be rendered as a Component or passed to props of a Client Component.`,
305 );
308 - }: any),
306 + } as any,
307 target.$$id + '#' + name,
308 target.$$async,
309 );
312 - Object.defineProperty((reference: any), 'name', {value: name});
310 + Object.defineProperty(reference as any, 'name', {value: name});
311 cachedReference = target[name] = new Proxy(reference, deepProxyHandlers);
312 }
313 return cachedReference;
@@ -352,7 +350,7 @@ export function createClientModuleProxy<T>(
350 moduleId: string,
351 ): ClientReference<T> {
352 const clientReference: ClientReference<T> = registerClientReferenceImpl(
355 - ({}: any),
353 + {} as any,
354 // Represents the whole Module object instead of a particular import.
355 moduleId,
356 false,
packages/react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpack.js
+3 -3
@@ -176,12 +176,12 @@ function requireAsyncModule(id: string): null | Thenable<any> {
176 // Instrument the Promise to stash the result.
177 promise.then(
178 value => {
179 - const fulfilledThenable: FulfilledThenable<mixed> = (promise: any);
179 + const fulfilledThenable: FulfilledThenable<mixed> = promise as any;
180 fulfilledThenable.status = 'fulfilled';
181 fulfilledThenable.value = value;
182 },
183 reason => {
184 - const rejectedThenable: RejectedThenable<mixed> = (promise: any);
184 + const rejectedThenable: RejectedThenable<mixed> = promise as any;
185 rejectedThenable.status = 'rejected';
186 rejectedThenable.reason = reason;
187 },
@@ -258,7 +258,7 @@ export function requireModule<T>(metadata: ClientReference<T>): T {
258 if (hasOwnProperty.call(moduleExports, metadata[NAME])) {
259 return moduleExports[metadata[NAME]];
260 }
261 - return (undefined: any);
261 + return undefined as any;
262 }
263
264 export function getModuleDebugInfo<T>(
packages/react-server-dom-webpack/src/client/ReactFlightClientConfigBundlerWebpackBrowser.js
+4 -4
@@ -36,7 +36,7 @@ export function loadChunk(chunkId: string, filename: string): Promise<mixed> {
36 // We cache ReactIOInfo across requests so that inner refreshes can dedupe with outer.
37 const chunkIOInfoCache: Map<string, ReactIOInfo> = __DEV__
38 ? new Map()
39 - : (null: any);
39 + : (null as any);
40
41 export function addChunkDebugInfo(
42 target: ReactDebugInfo,
@@ -69,7 +69,7 @@ export function addChunkDebugInfo(
69 start = resourceEntry.startTime;
70 end = start + resourceEntry.duration;
71 // $FlowFixMe[prop-missing]
72 - byteSize = (resourceEntry.transferSize: any) || 0;
72 + byteSize = (resourceEntry.transferSize as any) || 0;
73 }
74 }
75 }
@@ -108,13 +108,13 @@ export function addChunkDebugInfo(
108 href +
109 ':1:1';
110 }
111 - ioInfo = ({
111 + ioInfo = {
112 name: 'script',
113 start: start,
114 end: end,
115 value: value,
116 debugStack: fakeStack,
117 - }: ReactIOInfo);
117 + } as ReactIOInfo;
118 if (byteSize > 0) {
119 // $FlowFixMe[cannot-write]
120 ioInfo.byteSize = byteSize;
packages/react-server-dom-webpack/src/client/ReactFlightDOMClientBrowser.js
+5 -5
@@ -173,7 +173,7 @@ function startReadingFromStream(
173 if (done) {
174 return onDone();
175 }
176 - const buffer: Uint8Array = (value: any);
176 + const buffer: Uint8Array = value as any;
177 processBinaryChunk(response, streamState, buffer);
178 return reader.read().then(progress).catch(error);
179 }
@@ -241,11 +241,11 @@ function createFromFetch<T>(
241 options.debugChannel.readable,
242 handleDone,
243 );
244 - startReadingFromStream(response, (r.body: any), handleDone, r);
244 + startReadingFromStream(response, r.body as any, handleDone, r);
245 } else {
246 startReadingFromStream(
247 response,
248 - (r.body: any),
248 + r.body as any,
249 close.bind(null, response),
250 r,
251 );
@@ -277,10 +277,10 @@ function encodeReply(
277 if (options && options.signal) {
278 const signal = options.signal;
279 if (signal.aborted) {
280 - abort((signal: any).reason);
280 + abort((signal as any).reason);
281 } else {
282 const listener = () => {
283 - abort((signal: any).reason);
283 + abort((signal as any).reason);
284 signal.removeEventListener('abort', listener);
285 };
286 signal.addEventListener('abort', listener);
packages/react-server-dom-webpack/src/client/ReactFlightDOMClientEdge.js
+5 -5
@@ -142,7 +142,7 @@ function startReadingFromStream(
142 if (done) {
143 return onDone();
144 }
145 - const buffer: Uint8Array = (value: any);
145 + const buffer: Uint8Array = value as any;
146 processBinaryChunk(response, streamState, buffer);
147 return reader.read().then(progress).catch(error);
148 }
@@ -208,11 +208,11 @@ function createFromFetch<T>(
208 options.debugChannel.readable,
209 handleDone,
210 );
211 - startReadingFromStream(response, (r.body: any), handleDone, r);
211 + startReadingFromStream(response, r.body as any, handleDone, r);
212 } else {
213 startReadingFromStream(
214 response,
215 - (r.body: any),
215 + r.body as any,
216 close.bind(null, response),
217 r,
218 );
@@ -244,10 +244,10 @@ function encodeReply(
244 if (options && options.signal) {
245 const signal = options.signal;
246 if (signal.aborted) {
247 - abort((signal: any).reason);
247 + abort((signal as any).reason);
248 } else {
249 const listener = () => {
250 - abort((signal: any).reason);
250 + abort((signal as any).reason);
251 signal.removeEventListener('abort', listener);
252 };
253 signal.addEventListener('abort', listener);
packages/react-server-dom-webpack/src/server/ReactFlightDOMServerBrowser.js
+5 -5
@@ -82,7 +82,7 @@ function startReadingFromDebugChannelReadableStream(
82 value: ?any,
83 ...
84 }): void | Promise<void> {
85 - const buffer: Uint8Array = (value: any);
85 + const buffer: Uint8Array = value as any;
86 stringBuffer += done
87 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
88 : readPartialStringChunk(stringDecoder, buffer);
@@ -135,10 +135,10 @@ function renderToReadableStream(
135 if (options && options.signal) {
136 const signal = options.signal;
137 if (signal.aborted) {
138 - abort(request, (signal: any).reason);
138 + abort(request, (signal as any).reason);
139 } else {
140 const listener = () => {
141 - abort(request, (signal: any).reason);
141 + abort(request, (signal as any).reason);
142 signal.removeEventListener('abort', listener);
143 };
144 signal.addEventListener('abort', listener);
@@ -227,11 +227,11 @@ function prerender(
227 if (options && options.signal) {
228 const signal = options.signal;
229 if (signal.aborted) {
230 - const reason = (signal: any).reason;
230 + const reason = (signal as any).reason;
231 abort(request, reason);
232 } else {
233 const listener = () => {
234 - const reason = (signal: any).reason;
234 + const reason = (signal as any).reason;
235 abort(request, reason);
236 signal.removeEventListener('abort', listener);
237 };
packages/react-server-dom-webpack/src/server/ReactFlightDOMServerEdge.js
+6 -6
@@ -87,7 +87,7 @@ function startReadingFromDebugChannelReadableStream(
87 value: ?any,
88 ...
89 }): void | Promise<void> {
90 - const buffer: Uint8Array = (value: any);
90 + const buffer: Uint8Array = value as any;
91 stringBuffer += done
92 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
93 : readPartialStringChunk(stringDecoder, buffer);
@@ -140,10 +140,10 @@ function renderToReadableStream(
140 if (options && options.signal) {
141 const signal = options.signal;
142 if (signal.aborted) {
143 - abort(request, (signal: any).reason);
143 + abort(request, (signal as any).reason);
144 } else {
145 const listener = () => {
146 - abort(request, (signal: any).reason);
146 + abort(request, (signal as any).reason);
147 signal.removeEventListener('abort', listener);
148 };
149 signal.addEventListener('abort', listener);
@@ -232,11 +232,11 @@ function prerender(
232 if (options && options.signal) {
233 const signal = options.signal;
234 if (signal.aborted) {
235 - const reason = (signal: any).reason;
235 + const reason = (signal as any).reason;
236 abort(request, reason);
237 } else {
238 const listener = () => {
239 - const reason = (signal: any).reason;
239 + const reason = (signal as any).reason;
240 abort(request, reason);
241 signal.removeEventListener('abort', listener);
242 };
@@ -310,7 +310,7 @@ function decodeReplyFromAsyncIterable<T>(
310 }
311 function error(reason: Error) {
312 reportGlobalError(response, reason);
313 - if (typeof (iterator: any).throw === 'function') {
313 + if (typeof (iterator as any).throw === 'function') {
314 // The iterator protocol doesn't necessarily include this but a generator do.
315 // $FlowFixMe[prop-missing] should be able to pass mixed
316 iterator.throw(reason).then(error, error);
packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js
+21 -21
@@ -100,7 +100,7 @@ function startReadingFromDebugChannelReadable(
100 }
101 stringBuffer += chunk;
102 } else {
103 - const buffer: Uint8Array = (chunk: any);
103 + const buffer: Uint8Array = chunk as any;
104 stringBuffer += readPartialStringChunk(stringDecoder, buffer);
105 lastWasPartial = true;
106 }
@@ -127,7 +127,7 @@ function startReadingFromDebugChannelReadable(
127 // $FlowFixMe[method-unbinding]
128 typeof stream.binaryType === 'string'
129 ) {
130 - const ws: WebSocket = (stream: any);
130 + const ws: WebSocket = stream as any;
131 ws.binaryType = 'arraybuffer';
132 ws.addEventListener('message', event => {
133 // $FlowFixMe[incompatible-type]
@@ -139,7 +139,7 @@ function startReadingFromDebugChannelReadable(
139 });
140 ws.addEventListener('close', onClose);
141 } else {
142 - const readable: Readable = (stream: any);
142 + const readable: Readable = stream as any;
143 readable.on('data', onData);
144 readable.on('error', onError);
145 readable.on('end', onClose);
@@ -173,16 +173,16 @@ function renderToPipeableStream(
173 // $FlowFixMe[method-unbinding]
174 (typeof debugChannel.read === 'function' ||
175 typeof debugChannel.readyState === 'number')
176 - ? (debugChannel: any)
176 + ? (debugChannel as any)
177 : undefined;
178 const debugChannelWritable: void | Writable =
179 __DEV__ && debugChannel !== undefined
180 ? // $FlowFixMe[method-unbinding]
181 typeof debugChannel.write === 'function'
182 - ? (debugChannel: any)
182 + ? (debugChannel as any)
183 : // $FlowFixMe[method-unbinding]
184 typeof debugChannel.send === 'function'
185 - ? createFakeWritableFromWebSocket((debugChannel: any))
185 + ? createFakeWritableFromWebSocket(debugChannel as any)
186 : undefined
187 : undefined;
188 const request = createRequest(
@@ -237,9 +237,9 @@ function renderToPipeableStream(
237 }
238
239 function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
240 - return ({
240 + return {
241 write(chunk: string | Uint8Array) {
242 - webSocket.send((chunk: any));
242 + webSocket.send(chunk as any);
243 return true;
244 },
245 end() {
@@ -255,7 +255,7 @@ function createFakeWritableFromWebSocket(webSocket: WebSocket): Writable {
255 webSocket.close(1011);
256 }
257 },
258 - }: any);
258 + } as any;
259 }
260
261 function createFakeWritableFromReadableStreamController(
@@ -263,7 +263,7 @@ function createFakeWritableFromReadableStreamController(
263 ): Writable {
264 // The current host config expects a Writable so we create
265 // a fake writable for now to push into the Readable.
266 - return ({
266 + return {
267 write(chunk: string | Uint8Array) {
268 if (typeof chunk === 'string') {
269 chunk = textEncoder.encode(chunk);
@@ -284,7 +284,7 @@ function createFakeWritableFromReadableStreamController(
284 controller.close();
285 }
286 },
287 - }: any);
287 + } as any;
288 }
289
290 function startReadingFromDebugChannelReadableStream(
@@ -302,7 +302,7 @@ function startReadingFromDebugChannelReadableStream(
302 value: ?any,
303 ...
304 }): void | Promise<void> {
305 - const buffer: Uint8Array = (value: any);
305 + const buffer: Uint8Array = value as any;
306 stringBuffer += done
307 ? readFinalStringChunk(stringDecoder, new Uint8Array(0))
308 : readPartialStringChunk(stringDecoder, buffer);
@@ -358,10 +358,10 @@ function renderToReadableStream(
358 if (options && options.signal) {
359 const signal = options.signal;
360 if (signal.aborted) {
361 - abort(request, (signal: any).reason);
361 + abort(request, (signal as any).reason);
362 } else {
363 const listener = () => {
364 - abort(request, (signal: any).reason);
364 + abort(request, (signal as any).reason);
365 signal.removeEventListener('abort', listener);
366 };
367 signal.addEventListener('abort', listener);
@@ -415,7 +415,7 @@ function renderToReadableStream(
415 function createFakeWritableFromNodeReadable(readable: any): Writable {
416 // The current host config expects a Writable so we create
417 // a fake writable for now to push into the Readable.
418 - return ({
418 + return {
419 write(chunk: string | Uint8Array) {
420 return readable.push(chunk);
421 },
@@ -425,7 +425,7 @@ function createFakeWritableFromNodeReadable(readable: any): Writable {
425 destroy(error) {
426 readable.destroy(error);
427 },
428 - }: any);
428 + } as any;
429 }
430
431 type PrerenderOptions = {
@@ -475,11 +475,11 @@ function prerenderToNodeStream(
475 if (options && options.signal) {
476 const signal = options.signal;
477 if (signal.aborted) {
478 - const reason = (signal: any).reason;
478 + const reason = (signal as any).reason;
479 abort(request, reason);
480 } else {
481 const listener = () => {
482 - const reason = (signal: any).reason;
482 + const reason = (signal as any).reason;
483 abort(request, reason);
484 signal.removeEventListener('abort', listener);
485 };
@@ -540,11 +540,11 @@ function prerender(
540 if (options && options.signal) {
541 const signal = options.signal;
542 if (signal.aborted) {
543 - const reason = (signal: any).reason;
543 + const reason = (signal as any).reason;
544 abort(request, reason);
545 } else {
546 const listener = () => {
547 - const reason = (signal: any).reason;
547 + const reason = (signal as any).reason;
548 abort(request, reason);
549 signal.removeEventListener('abort', listener);
550 };
@@ -764,7 +764,7 @@ function decodeReplyFromAsyncIterable<T>(
764 }
765 function error(reason: Error) {
766 reportGlobalError(response, reason);
767 - if (typeof (iterator: any).throw === 'function') {
767 + if (typeof (iterator as any).throw === 'function') {
768 // The iterator protocol doesn't necessarily include this but a generator do.
769 // $FlowFixMe[prop-missing] should be able to pass mixed
770 iterator.throw(reason).then(error, error);
packages/react-server/src/ReactFizzAsyncDispatcher.js
+2 -2
@@ -20,10 +20,10 @@ function cacheSignal(): null | AbortSignal {
20 throw new Error('Not implemented.');
21 }
22
23 -export const DefaultAsyncDispatcher: AsyncDispatcher = ({
23 +export const DefaultAsyncDispatcher: AsyncDispatcher = {
24 getCacheForType,
25 cacheSignal,
26 -}: any);
26 +} as any;
27
28 if (__DEV__) {
29 DefaultAsyncDispatcher.getOwner = (): ComponentStackNode | null => {
packages/react-server/src/ReactFizzCallUserSpace.js
+6 -6
@@ -28,8 +28,8 @@ export const callComponentInDEV: <Props, Arg, R>(
28 secondArg: Arg,
29 ) => R = __DEV__
30 ? // We use this technique to trick minifiers to preserve the function name.
31 - (callComponent.react_stack_bottom_frame.bind(callComponent): any)
32 - : (null: any);
31 + (callComponent.react_stack_bottom_frame.bind(callComponent) as any)
32 + : (null as any);
33
34 interface ClassInstance<R> {
35 render(): R;
@@ -44,8 +44,8 @@ const callRender = {
44 export const callRenderInDEV: <R>(instance: ClassInstance<R>) => R => R =
45 __DEV__
46 ? // We use this technique to trick minifiers to preserve the function name.
47 - (callRender.react_stack_bottom_frame.bind(callRender): any)
48 - : (null: any);
47 + (callRender.react_stack_bottom_frame.bind(callRender) as any)
48 + : (null as any);
49
50 const callLazyInit = {
51 react_stack_bottom_frame: function (lazy: LazyComponent<any, any>): any {
@@ -57,5 +57,5 @@ const callLazyInit = {
57
58 export const callLazyInitInDEV: (lazy: LazyComponent<any, any>) => any = __DEV__
59 ? // We use this technique to trick minifiers to preserve the function name.
60 - (callLazyInit.react_stack_bottom_frame.bind(callLazyInit): any)
61 - : (null: any);
60 + (callLazyInit.react_stack_bottom_frame.bind(callLazyInit) as any)
61 + : (null as any);
packages/react-server/src/ReactFizzClassComponent.js
+1 -1
@@ -214,7 +214,7 @@ export function constructClassInstance(
214 }
215
216 if (typeof contextType === 'object' && contextType !== null) {
217 - context = readContext((contextType: any));
217 + context = readContext(contextType as any);
218 } else if (!disableLegacyContext) {
219 context = maskedLegacyContext;
220 }
packages/react-server/src/ReactFizzComponentStack.js
+4 -4
@@ -69,13 +69,13 @@ function describeComponentStackByType(
69 if (typeof type === 'object' && type !== null) {
70 switch (type.$$typeof) {
71 case REACT_FORWARD_REF_TYPE: {
72 - return describeFunctionComponentFrame((type: any).render);
72 + return describeFunctionComponentFrame((type as any).render);
73 }
74 case REACT_MEMO_TYPE: {
75 - return describeFunctionComponentFrame((type: any).type);
75 + return describeFunctionComponentFrame((type as any).type);
76 }
77 case REACT_LAZY_TYPE: {
78 - const lazyComponent: LazyComponent<any, any> = (type: any);
78 + const lazyComponent: LazyComponent<any, any> = type as any;
79 const payload = lazyComponent._payload;
80 const init = lazyComponent._init;
81 try {
@@ -174,7 +174,7 @@ export function getOwnerStackByComponentStackNodeInDev(
174 owner = owner.owner;
175 } else {
176 // Client Component
177 - const node: ComponentStackNode = (owner: any);
177 + const node: ComponentStackNode = owner as any;
178 if (node.stack != null) {
179 if (typeof node.stack !== 'string') {
180 ownerStack = node.stack = formatOwnerStack(node.stack);
packages/react-server/src/ReactFizzHooks.js
+14 -14
@@ -350,7 +350,7 @@ export function useState<S>(
350 return useReducer(
351 basicStateReducer,
352 // useReducer has a special case to support lazy useState initializers
353 - (initialState: any),
353 + initialState as any,
354 );
355 }
356
@@ -370,8 +370,8 @@ export function useReducer<S, I, A>(
370 if (isReRender) {
371 // This is a re-render. Apply the new render phase updates to the previous
372 // current hook.
373 - const queue: UpdateQueue<A> = (workInProgressHook.queue: any);
374 - const dispatch: Dispatch<A> = (queue.dispatch: any);
373 + const queue: UpdateQueue<A> = workInProgressHook.queue as any;
374 + const dispatch: Dispatch<A> = queue.dispatch as any;
375 if (renderPhaseUpdates !== null) {
376 // Render phase updates are stored in a map of queue -> linked list
377 const firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
@@ -415,11 +415,11 @@ export function useReducer<S, I, A>(
415 // Special case for `useState`.
416 initialState =
417 typeof initialArg === 'function'
418 - ? ((initialArg: any): () => S)()
419 - : ((initialArg: any): S);
418 + ? (initialArg as any as () => S)()
419 + : (initialArg as any as S);
420 } else {
421 initialState =
422 - init !== undefined ? init(initialArg) : ((initialArg: any): S);
422 + init !== undefined ? init(initialArg) : (initialArg as any as S);
423 }
424 if (__DEV__) {
425 isInHookUserCodeInDev = false;
@@ -431,11 +431,11 @@ export function useReducer<S, I, A>(
431 last: null,
432 dispatch: null,
433 });
434 - const dispatch: Dispatch<A> = (queue.dispatch = (dispatchAction.bind(
434 + const dispatch: Dispatch<A> = (queue.dispatch = dispatchAction.bind(
435 null,
436 currentlyRenderingComponent,
437 queue,
438 - ): any));
438 + ) as any);
439 // $FlowFixMe[incompatible-use] found when upgrading Flow
440 return [workInProgressHook.memoizedState, dispatch];
441 }
@@ -630,7 +630,7 @@ function useActionState<S, P>(
630 // track the position of this useActionState hook relative to the other ones in
631 // this component, so we can generate a unique key for each one.
632 const actionStateHookIndex = actionStateCounter++;
633 - const request: Request = (currentlyRenderingRequest: any);
633 + const request: Request = currentlyRenderingRequest as any;
634
635 // $FlowFixMe[prop-missing]
636 const formAction = action.$$FORM_ACTION;
@@ -652,7 +652,7 @@ function useActionState<S, P>(
652 // Otherwise, we'll use the initial state argument. We will emit a comment
653 // marker into the stream that indicates whether the state was reused.
654 let state = initialState;
655 - const componentKeyPath = (currentlyRenderingKeyPath: any);
655 + const componentKeyPath = currentlyRenderingKeyPath as any;
656 const postbackActionState = getFormState(request);
657 // $FlowFixMe[prop-missing]
658 const isSignatureEqual = action.$$IS_SIGNATURE_EQUAL;
@@ -734,7 +734,7 @@ function useActionState<S, P>(
734 }
735
736 function useId(): string {
737 - const task: Task = (currentlyRenderingTask: any);
737 + const task: Task = currentlyRenderingTask as any;
738 const treeId = getTreeId(task.treeContext);
739
740 const resumableState = currentResumableState;
@@ -754,10 +754,10 @@ function use<T>(usable: Usable<T>): T {
754 // $FlowFixMe[method-unbinding]
755 if (typeof usable.then === 'function') {
756 // This is a thenable.
757 - const thenable: Thenable<T> = (usable: any);
757 + const thenable: Thenable<T> = usable as any;
758 return unwrapThenable(thenable);
759 } else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
760 - const context: ReactContext<T> = (usable: any);
760 + const context: ReactContext<T> = usable as any;
761 return readContext(context);
762 }
763 }
@@ -866,7 +866,7 @@ export const HooksDispatcher: Dispatcher = supportsClientAPIs
866 useEffectEvent,
867 };
868
869 -export let currentResumableState: null | ResumableState = (null: any);
869 +export let currentResumableState: null | ResumableState = null as any;
870 export function setCurrentResumableState(
871 resumableState: null | ResumableState,
872 ): void {
packages/react-server/src/ReactFizzLegacyContext.js
+1 -1
@@ -13,7 +13,7 @@ import getComponentNameFromType from 'shared/getComponentNameFromType';
13 let warnedAboutMissingGetChildContext;
14
15 if (__DEV__) {
16 - warnedAboutMissingGetChildContext = ({}: {[string]: boolean});
16 + warnedAboutMissingGetChildContext = {} as {[string]: boolean};
17 }
18
19 export const emptyContextObject: {} = {};
packages/react-server/src/ReactFizzServer.js
+59 -56
@@ -549,9 +549,9 @@ function RequestInstance(
549 this.abortableTasks = abortSet;
550 this.pingedTasks = pingedTasks;
551 this.currentTask = null;
552 - this.clientRenderedBoundaries = ([]: Array<SuspenseBoundary>);
553 - this.completedBoundaries = ([]: Array<SuspenseBoundary>);
554 - this.partialBoundaries = ([]: Array<SuspenseBoundary>);
552 + this.clientRenderedBoundaries = [] as Array<SuspenseBoundary>;
553 + this.completedBoundaries = [] as Array<SuspenseBoundary>;
554 + this.partialBoundaries = [] as Array<SuspenseBoundary>;
555 this.trackedPostpones = null;
556 this.onError = onError === undefined ? defaultErrorHandler : onError;
557 this.onAllReady = onAllReady === undefined ? noop : onAllReady;
@@ -914,7 +914,7 @@ function createRenderTask(
914 if (row !== null) {
915 row.pendingTasks++;
916 }
917 - const task: RenderTask = ({
917 + const task: RenderTask = {
918 replay: null,
919 node,
920 childIndex,
@@ -934,7 +934,7 @@ function createRenderTask(
934 row,
935 componentStack,
936 thenableState,
937 - }: any);
937 + } as any;
938 if (!disableLegacyContext) {
939 task.legacyContext = legacyContext;
940 }
@@ -973,7 +973,7 @@ function createReplayTask(
973 row.pendingTasks++;
974 }
975 replay.pendingTasks++;
976 - const task: ReplayTask = ({
976 + const task: ReplayTask = {
977 replay,
978 node,
979 childIndex,
@@ -993,7 +993,7 @@ function createReplayTask(
993 row,
994 componentStack,
995 thenableState,
996 - }: any);
996 + } as any;
997 if (!disableLegacyContext) {
998 task.legacyContext = legacyContext;
999 }
@@ -1057,7 +1057,7 @@ function pushHaltedAwaitOnComponentStack(
1057 for (let i = debugInfo.length - 1; i >= 0; i--) {
1058 const info = debugInfo[i];
1059 if (info.awaited != null) {
1060 - const asyncInfo: ReactAsyncInfo = (info: any);
1060 + const asyncInfo: ReactAsyncInfo = info as any;
1061 const bestStack =
1062 asyncInfo.debugStack == null ? asyncInfo.awaited : asyncInfo;
1063 if (bestStack.debugStack !== undefined) {
@@ -1067,7 +1067,7 @@ function pushHaltedAwaitOnComponentStack(
1067 owner: bestStack.owner,
1068 stack: bestStack.debugStack,
1069 };
1070 - task.debugTask = (bestStack.debugTask: any);
1070 + task.debugTask = bestStack.debugTask as any;
1071 break;
1072 }
1073 }
@@ -1137,7 +1137,7 @@ function pushSuspendedCallSiteOnComponentStack(
1137 setCaptureSuspendedCallSiteDEV(true);
1138 const restoreThenableState = ensureSuspendableThenableStateDEV(
1139 // refined at the callsite
1140 - ((task.thenableState: any): ThenableState),
1140 + task.thenableState as any as ThenableState,
1141 );
1142 try {
1143 rerenderStalledTask(request, task);
@@ -1177,7 +1177,7 @@ function pushServerComponentStack(
1177 if (debugInfo != null) {
1178 const stack: ReactDebugInfo = debugInfo;
1179 for (let i = 0; i < stack.length; i++) {
1180 - const componentInfo: ReactComponentInfo = (stack[i]: any);
1180 + const componentInfo: ReactComponentInfo = stack[i] as any;
1181 if (typeof componentInfo.name !== 'string') {
1182 continue;
1183 }
@@ -1190,7 +1190,7 @@ function pushServerComponentStack(
1190 owner: componentInfo.owner,
1191 stack: componentInfo.debugStack,
1192 };
1193 - task.debugTask = (componentInfo.debugTask: any);
1193 + task.debugTask = componentInfo.debugTask as any;
1194 }
1195 }
1196 }
@@ -1201,7 +1201,7 @@ function pushComponentStack(task: Task): void {
1201 // It's unfortunate that we need to do this refinement twice. Once for
1202 // the stack frame and then once again while actually
1203 if (typeof node === 'object' && node !== null) {
1204 - switch ((node: any).$$typeof) {
1204 + switch ((node as any).$$typeof) {
1205 case REACT_ELEMENT_TYPE: {
1206 const element: any = node;
1207 const type = element.type;
@@ -1221,7 +1221,7 @@ function pushComponentStack(task: Task): void {
1221 }
1222 case REACT_LAZY_TYPE: {
1223 if (__DEV__) {
1224 - const lazyNode: LazyComponentType<any, any> = (node: any);
1224 + const lazyNode: LazyComponentType<any, any> = node as any;
1225 pushServerComponentStack(task, lazyNode._debugInfo);
1226 }
1227 break;
@@ -1230,7 +1230,7 @@ function pushComponentStack(task: Task): void {
1230 if (__DEV__) {
1231 const maybeUsable: Object = node;
1232 if (typeof maybeUsable.then === 'function') {
1233 - const thenable: Thenable<ReactNodeList> = (maybeUsable: any);
1233 + const thenable: Thenable<ReactNodeList> = maybeUsable as any;
1234 pushServerComponentStack(task, thenable._debugInfo);
1235 }
1236 }
@@ -1488,7 +1488,7 @@ function renderSuspenseBoundary(
1488 const fallbackReplayNode: ReplayNode = [
1489 fallbackKeyPath[1],
1490 fallbackKeyPath[2],
1491 - ([]: Array<ReplayNode>),
1491 + [] as Array<ReplayNode>,
1492 null,
1493 ];
1494 trackedPostpones.workingMap.set(fallbackKeyPath, fallbackReplayNode);
@@ -1987,7 +1987,10 @@ function renderSuspenseListRows(
1987 previousDebugTask = task.debugTask;
1988 // We read debugInfo from task.node.props.children instead of rows because it
1989 // might have been an unwrapped iterable so we read from the original node.
1990 - pushServerComponentStack(task, (task.node: any).props.children._debugInfo);
1990 + pushServerComponentStack(
1991 + task,
1992 + (task.node as any).props.children._debugInfo,
1993 + );
1994 }
1995
1996 task.keyPath = keyPath;
@@ -2052,7 +2055,7 @@ function renderSuspenseListRows(
2055 }
2056 }
2057 } else {
2055 - task = ((task: any): RenderTask); // Refined
2058 + task = task as any as RenderTask; // Refined
2059 if (
2060 revealOrder !== 'backwards' &&
2061 revealOrder !== 'unstable_legacy-backwards'
@@ -2195,14 +2198,14 @@ function renderSuspenseList(
2198 }
2199 if (
2200 enableAsyncIterableChildren &&
2198 - typeof (children: any)[ASYNC_ITERATOR] === 'function'
2201 + typeof (children as any)[ASYNC_ITERATOR] === 'function'
2202 ) {
2200 - const iterator: AsyncIterator<ReactNodeList> = (children: any)[
2203 + const iterator: AsyncIterator<ReactNodeList> = (children as any)[
2204 ASYNC_ITERATOR
2205 ]();
2206 if (iterator) {
2207 if (__DEV__) {
2205 - validateAsyncIterable(task, (children: any), -1, iterator);
2208 + validateAsyncIterable(task, children as any, -1, iterator);
2209 }
2210 // TODO: Update the task.children to be the iterator to avoid asking
2211 // for new iterators, but we currently warn for rendering these
@@ -2365,7 +2368,7 @@ function renderHostElement(
2368 ));
2369 if (isPreambleContext(newContext)) {
2370 // $FlowFixMe[incompatible-type]: Refined
2368 - renderPreamble(request, (task: RenderTask), segment, children);
2371 + renderPreamble(request, task as RenderTask, segment, children);
2372 } else {
2373 // We use the non-destructive form because if something suspends, we still
2374 // need to pop back up and finish this subtree of HTML.
@@ -2431,7 +2434,7 @@ function finishClassComponent(
2434 ): ReactNodeList {
2435 let nextChildren;
2436 if (__DEV__) {
2434 - nextChildren = (callRenderInDEV(instance): any);
2437 + nextChildren = callRenderInDEV(instance) as any;
2438 } else {
2439 nextChildren = instance.render();
2440 }
@@ -2484,7 +2487,7 @@ export function resolveClassComponentProps(
2487
2488 // Remove ref from the props object, if it exists.
2489 if ('ref' in baseProps) {
2487 - newProps = ({}: any);
2490 + newProps = {} as any;
2491 for (const propName in baseProps) {
2492 if (propName !== 'ref') {
2493 newProps[propName] = baseProps[propName];
@@ -2741,7 +2744,7 @@ function renderForwardRef(
2744 // `ref` is just a prop now, but `forwardRef` expects it to not appear in
2745 // the props object. This used to happen in the JSX runtime, but now we do
2746 // it here.
2744 - propsWithoutRef = ({}: {[string]: any});
2747 + propsWithoutRef = {} as {[string]: any};
2748 for (const key in props) {
2749 // Since `ref` should only appear in props via the JSX transform, we can
2750 // assume that this is a plain object. So we don't need a
@@ -3060,7 +3063,7 @@ function renderElement(
3063 }
3064 // $FlowFixMe[invalid-compare]
3065 case REACT_CONSUMER_TYPE: {
3063 - const context: ReactContext<any> = (type: ReactConsumerType<any>)
3066 + const context: ReactContext<any> = (type as ReactConsumerType<any>)
3067 ._context;
3068 renderContextConsumer(request, task, keyPath, context, props);
3069 return;
@@ -3117,7 +3120,7 @@ function resumeNode(
3120 resumedSegment.parentFlushed = true;
3121 try {
3122 // Convert the current ReplayTask to a RenderTask.
3120 - const renderTask: RenderTask = (task: any);
3123 + const renderTask: RenderTask = task as any;
3124 renderTask.replay = null;
3125 renderTask.blockedSegment = resumedSegment;
3126 renderNode(request, task, node, childIndex);
@@ -3164,7 +3167,7 @@ function replayElement(
3167 if (name !== null && name !== node[0]) {
3168 throw new Error(
3169 'Expected the resume to render <' +
3167 - (node[0]: any) +
3170 + (node[0] as any) +
3171 '> in this slot but instead it rendered <' +
3172 name +
3173 '>. ' +
@@ -3292,7 +3295,7 @@ function validateIterable(
3295 }
3296 didWarnAboutGenerators = true;
3297 }
3295 - } else if ((iterable: any).entries === iteratorFn) {
3298 + } else if ((iterable as any).entries === iteratorFn) {
3299 // Warn about using Maps as children
3300 if (!didWarnAboutMaps) {
3301 console.error(
@@ -3405,7 +3408,7 @@ function retryNode(request: Request, task: Task): void {
3408
3409 // Handle object types
3410 if (typeof node === 'object') {
3408 - switch ((node: any).$$typeof) {
3411 + switch ((node as any).$$typeof) {
3412 case REACT_ELEMENT_TYPE: {
3413 const element: any = node;
3414 const type = element.type;
@@ -3486,7 +3489,7 @@ function retryNode(request: Request, task: Task): void {
3489 'Render them conditionally so that they only appear on the client render.',
3490 );
3491 case REACT_LAZY_TYPE: {
3489 - const lazyNode: LazyComponentType<any, any> = (node: any);
3492 + const lazyNode: LazyComponentType<any, any> = node as any;
3493 let resolvedNode;
3494 if (__DEV__) {
3495 resolvedNode = callLazyInitInDEV(lazyNode);
@@ -3537,14 +3540,14 @@ function retryNode(request: Request, task: Task): void {
3540
3541 if (
3542 enableAsyncIterableChildren &&
3540 - typeof (node: any)[ASYNC_ITERATOR] === 'function'
3543 + typeof (node as any)[ASYNC_ITERATOR] === 'function'
3544 ) {
3542 - const iterator: AsyncIterator<ReactNodeList> = (node: any)[
3545 + const iterator: AsyncIterator<ReactNodeList> = (node as any)[
3546 ASYNC_ITERATOR
3547 ]();
3548 if (iterator) {
3549 if (__DEV__) {
3547 - validateAsyncIterable(task, (node: any), childIndex, iterator);
3550 + validateAsyncIterable(task, node as any, childIndex, iterator);
3551 }
3552 // TODO: Update the task.node to be the iterator to avoid asking
3553 // for new iterators, but we currently warn for rendering these
@@ -3606,7 +3609,7 @@ function retryNode(request: Request, task: Task): void {
3609 if (typeof maybeUsable.then === 'function') {
3610 // Clear any previous thenable state that was created by the unwrapping.
3611 task.thenableState = null;
3609 - const thenable: Thenable<ReactNodeList> = (maybeUsable: any);
3612 + const thenable: Thenable<ReactNodeList> = maybeUsable as any;
3613 const result = renderNodeDestructive(
3614 request,
3615 task,
@@ -3617,7 +3620,7 @@ function retryNode(request: Request, task: Task): void {
3620 }
3621
3622 if (maybeUsable.$$typeof === REACT_CONTEXT_TYPE) {
3620 - const context: ReactContext<ReactNodeList> = (maybeUsable: any);
3623 + const context: ReactContext<ReactNodeList> = maybeUsable as any;
3624 return renderNodeDestructive(
3625 request,
3626 task,
@@ -3824,9 +3827,9 @@ function warnForMissingKey(request: Request, task: Task, child: mixed): void {
3827 const previousComponentStack = task.componentStack;
3828 const stackFrame = createComponentStackFromType(
3829 task.componentStack,
3827 - (child: any).type,
3828 - (child: any)._owner,
3829 - (child: any)._debugStack,
3830 + (child as any).type,
3831 + (child as any)._owner,
3832 + (child as any)._debugStack,
3833 );
3834 task.componentStack = stackFrame;
3835 console.error(
@@ -3852,7 +3855,7 @@ function renderChildrenArray(
3855 previousDebugTask = task.debugTask;
3856 // We read debugInfo from task.node instead of children because it might have been an
3857 // unwrapped iterable so we read from the original node.
3855 - pushServerComponentStack(task, (task.node: any)._debugInfo);
3858 + pushServerComponentStack(task, (task.node as any)._debugInfo);
3859 }
3860 if (childIndex !== -1) {
3861 task.keyPath = [task.keyPath, 'Fragment', childIndex];
@@ -3971,7 +3974,7 @@ function trackPostponedBoundary(
3974 return suspenseBoundary;
3975 } else {
3976 // Upgrade to ReplaySuspenseBoundary.
3974 - const suspenseBoundary: ReplaySuspenseBoundary = (boundaryNode: any);
3977 + const suspenseBoundary: ReplaySuspenseBoundary = boundaryNode as any;
3978 suspenseBoundary[4] = fallbackReplayNode;
3979 suspenseBoundary[5] = boundary.rootSegmentID;
3980 return suspenseBoundary;
@@ -4052,7 +4055,7 @@ function trackPostpone(
4055 resumableNode = [
4056 keyPath[1],
4057 keyPath[2],
4055 - ([]: Array<ReplayNode>),
4058 + [] as Array<ReplayNode>,
4059 segment.id,
4060 ];
4061 addToReplayParent(resumableNode, keyPath[0], trackedPostpones);
@@ -4065,7 +4068,7 @@ function trackPostpone(
4068 if (keyPath === null) {
4069 slots = trackedPostpones.rootSlots;
4070 if (slots === null) {
4068 - slots = trackedPostpones.rootSlots = ({}: {[index: number]: number});
4071 + slots = trackedPostpones.rootSlots = {} as {[index: number]: number};
4072 } else if (typeof slots === 'number') {
4073 throw new Error(
4074 'It should not be possible to postpone both at the root of an element ' +
@@ -4076,19 +4079,19 @@ function trackPostpone(
4079 const workingMap = trackedPostpones.workingMap;
4080 let resumableNode = workingMap.get(keyPath);
4081 if (resumableNode === undefined) {
4079 - slots = ({}: {[index: number]: number});
4080 - resumableNode = ([
4082 + slots = {} as {[index: number]: number};
4083 + resumableNode = [
4084 keyPath[1],
4085 keyPath[2],
4083 - ([]: Array<ReplayNode>),
4086 + [] as Array<ReplayNode>,
4087 slots,
4085 - ]: ReplayNode);
4088 + ] as ReplayNode;
4089 workingMap.set(keyPath, resumableNode);
4090 addToReplayParent(resumableNode, keyPath[0], trackedPostpones);
4091 } else {
4092 slots = resumableNode[3];
4093 if (slots === null) {
4091 - slots = resumableNode[3] = ({}: {[index: number]: number});
4094 + slots = resumableNode[3] = {} as {[index: number]: number};
4095 } else if (typeof slots === 'number') {
4096 throw new Error(
4097 'It should not be possible to postpone both at the root of an element ' +
@@ -4225,7 +4228,7 @@ function renderNode(
4228 const segment = task.blockedSegment;
4229 if (segment === null) {
4230 // Replay
4228 - task = ((task: any): ReplayTask); // Refined
4231 + task = task as any as ReplayTask; // Refined
4232 const previousReplaySet: ReplaySet = task.replay;
4233 try {
4234 return renderNodeDestructive(request, task, node, childIndex);
@@ -4248,7 +4251,7 @@ function renderNode(
4251 } else if (typeof x === 'object' && x !== null) {
4252 // $FlowFixMe[method-unbinding]
4253 if (typeof x.then === 'function') {
4251 - const wakeable: Wakeable = (x: any);
4254 + const wakeable: Wakeable = x as any;
4255 const thenableState =
4256 thrownValue === SuspenseException
4257 ? getThenableStateAfterSuspending()
@@ -4350,7 +4353,7 @@ function renderNode(
4353 } else if (typeof x === 'object' && x !== null) {
4354 // $FlowFixMe[method-unbinding]
4355 if (typeof x.then === 'function') {
4353 - const wakeable: Wakeable = (x: any);
4356 + const wakeable: Wakeable = x as any;
4357 const thenableState =
4358 thrownValue === SuspenseException
4359 ? getThenableStateAfterSuspending()
@@ -4645,7 +4648,7 @@ function abortRemainingReplayNodes(
4648 // Empty the set
4649 if (typeof slots === 'object') {
4650 for (const index in slots) {
4648 - delete slots[(index: any)];
4651 + delete slots[index as any];
4652 }
4653 }
4654 }
@@ -5276,7 +5279,7 @@ function retryRenderTask(
5279 : null;
5280 const ping = task.ping;
5281 // We've asserted that x is a thenable above
5279 - (x: any).then(ping.resolve, ping.reject);
5282 + (x as any).then(ping.resolve, ping.reject);
5283 return;
5284 }
5285 }
@@ -6384,12 +6387,12 @@ function addToReplayParent(
6387 const workingMap = trackedPostpones.workingMap;
6388 let parentNode = workingMap.get(parentKeyPath);
6389 if (parentNode === undefined) {
6387 - parentNode = ([
6390 + parentNode = [
6391 parentKeyPath[1],
6392 parentKeyPath[2],
6390 - ([]: Array<ReplayNode>),
6393 + [] as Array<ReplayNode>,
6394 null,
6392 - ]: ReplayNode);
6395 + ] as ReplayNode;
6396 workingMap.set(parentKeyPath, parentNode);
6397 addToReplayParent(parentNode, parentKeyPath[0], trackedPostpones);
6398 }
packages/react-server/src/ReactFizzThenable.js
+9 -9
@@ -103,19 +103,19 @@ export function trackUsedThenable<T>(
103 // happen. Flight lazily parses JSON when the value is actually awaited.
104 thenable.then(noop, noop);
105 } else {
106 - const pendingThenable: PendingThenable<T> = (thenable: any);
106 + const pendingThenable: PendingThenable<T> = thenable as any;
107 pendingThenable.status = 'pending';
108 pendingThenable.then(
109 fulfilledValue => {
110 if (thenable.status === 'pending') {
111 - const fulfilledThenable: FulfilledThenable<T> = (thenable: any);
111 + const fulfilledThenable: FulfilledThenable<T> = thenable as any;
112 fulfilledThenable.status = 'fulfilled';
113 fulfilledThenable.value = fulfilledValue;
114 }
115 },
116 (error: mixed) => {
117 if (thenable.status === 'pending') {
118 - const rejectedThenable: RejectedThenable<T> = (thenable: any);
118 + const rejectedThenable: RejectedThenable<T> = thenable as any;
119 rejectedThenable.status = 'rejected';
120 rejectedThenable.reason = error;
121 }
@@ -124,13 +124,13 @@ export function trackUsedThenable<T>(
124 }
125
126 // Check one more time in case the thenable resolved synchronously
127 - switch ((thenable: Thenable<T>).status) {
127 + switch ((thenable as Thenable<T>).status) {
128 case 'fulfilled': {
129 - const fulfilledThenable: FulfilledThenable<T> = (thenable: any);
129 + const fulfilledThenable: FulfilledThenable<T> = thenable as any;
130 return fulfilledThenable.value;
131 }
132 case 'rejected': {
133 - const rejectedThenable: RejectedThenable<T> = (thenable: any);
133 + const rejectedThenable: RejectedThenable<T> = thenable as any;
134 throw rejectedThenable.reason;
135 }
136 }
@@ -160,7 +160,7 @@ export function readPreviousThenable<T>(
160 return undefined;
161 } else {
162 // We assume this has been resolved already.
163 - return (previous: any).value;
163 + return (previous as any).value;
164 }
165 }
166
@@ -280,7 +280,7 @@ export function ensureSuspendableThenableStateDEV(
280 // $FlowFixMe[method-unbinding] We rebind .then immediately.
281 const previousThenableThen = lastThenable.then.bind(lastThenable);
282 delete lastThenable.value;
283 - delete (lastThenable: any).status;
283 + delete (lastThenable as any).status;
284 // We'll call .then again if we resuspend. Since we potentially corrupted
285 // the internal state of unknown classes, we need to diffuse the potential
286 // crash by replacing the .then method with a noop.
@@ -298,7 +298,7 @@ export function ensureSuspendableThenableStateDEV(
298 // $FlowFixMe[method-unbinding] We rebind .then immediately.
299 const previousThenableThen = lastThenable.then.bind(lastThenable);
300 delete lastThenable.reason;
301 - delete (lastThenable: any).status;
301 + delete (lastThenable as any).status;
302 // We'll call .then again if we resuspend. Since we potentially corrupted
303 // the internal state of unknown classes, we need to diffuse the potential
304 // crash by replacing the .then method with a noop.
packages/react-server/src/ReactFlightActionServer.js
+2 -2
@@ -52,7 +52,7 @@ function loadServerReference<T>(
52 ): Promise<T> {
53 const id: ServerReferenceId = metaData.id;
54 if (typeof id !== 'string') {
55 - return (null: any);
55 + return null as any;
56 }
57 const serverReference: ServerReference<T> =
58 resolveServerReference<$FlowFixMe>(bundlerConfig, id);
@@ -62,7 +62,7 @@ function loadServerReference<T>(
62 const preloadPromise = preloadModule(serverReference);
63 const bound = metaData.bound;
64 if (bound instanceof Promise) {
65 - return Promise.all([(bound: any), preloadPromise]).then(
65 + return Promise.all([bound as any, preloadPromise]).then(
66 ([args]: Array<any>) => bindArgs(requireModule(serverReference), args),
67 );
68 } else if (preloadPromise) {
packages/react-server/src/ReactFlightCallUserSpace.js
+6 -6
@@ -41,8 +41,8 @@ export const callComponentInDEV: <Props, R>(
41 componentDebugInfo: ReactComponentInfo,
42 ) => R = __DEV__
43 ? // We use this technique to trick minifiers to preserve the function name.
44 - (callComponent.react_stack_bottom_frame.bind(callComponent): any)
45 - : (null: any);
44 + (callComponent.react_stack_bottom_frame.bind(callComponent) as any)
45 + : (null as any);
46
47 const callLazyInit = {
48 react_stack_bottom_frame: function (lazy: LazyComponent<any, any>): any {
@@ -54,8 +54,8 @@ const callLazyInit = {
54
55 export const callLazyInitInDEV: (lazy: LazyComponent<any, any>) => any = __DEV__
56 ? // We use this technique to trick minifiers to preserve the function name.
57 - (callLazyInit.react_stack_bottom_frame.bind(callLazyInit): any)
58 - : (null: any);
57 + (callLazyInit.react_stack_bottom_frame.bind(callLazyInit) as any)
58 + : (null as any);
59
60 const callIterator = {
61 react_stack_bottom_frame: function (
@@ -81,5 +81,5 @@ export const callIteratorInDEV: (
81 error: (reason: mixed) => void,
82 ) => void = __DEV__
83 ? // We use this technique to trick minifiers to preserve the function name.
84 - (callIterator.react_stack_bottom_frame.bind(callIterator): any)
85 - : (null: any);
84 + (callIterator.react_stack_bottom_frame.bind(callIterator) as any)
85 + : (null as any);
packages/react-server/src/ReactFlightHooks.js
+19 -19
@@ -50,7 +50,7 @@ export function getThenableStateAfterSuspending(): ThenableState {
50 if (__DEV__) {
51 // This is a hack but we stash the debug info here so that we don't need a completely
52 // different data structure just for this in DEV. Not too happy about it.
53 - (state: any)._componentDebugInfo = currentComponentDebugInfo;
53 + (state as any)._componentDebugInfo = currentComponentDebugInfo;
54 currentComponentDebugInfo = null;
55 }
56 thenableState = null;
@@ -64,32 +64,32 @@ export function getTrackedThenablesAfterRendering(): null | Array<
64 }
65
66 export const HooksDispatcher: Dispatcher = {
67 - readContext: (unsupportedContext: any),
67 + readContext: unsupportedContext as any,
68
69 use,
70 useCallback<T>(callback: T): T {
71 return callback;
72 },
73 - useContext: (unsupportedContext: any),
74 - useEffect: (unsupportedHook: any),
75 - useImperativeHandle: (unsupportedHook: any),
76 - useLayoutEffect: (unsupportedHook: any),
77 - useInsertionEffect: (unsupportedHook: any),
73 + useContext: unsupportedContext as any,
74 + useEffect: unsupportedHook as any,
75 + useImperativeHandle: unsupportedHook as any,
76 + useLayoutEffect: unsupportedHook as any,
77 + useInsertionEffect: unsupportedHook as any,
78 useMemo<T>(nextCreate: () => T): T {
79 return nextCreate();
80 },
81 - useReducer: (unsupportedHook: any),
82 - useRef: (unsupportedHook: any),
83 - useState: (unsupportedHook: any),
81 + useReducer: unsupportedHook as any,
82 + useRef: unsupportedHook as any,
83 + useState: unsupportedHook as any,
84 useDebugValue(): void {},
85 - useDeferredValue: (unsupportedHook: any),
86 - useTransition: (unsupportedHook: any),
87 - useSyncExternalStore: (unsupportedHook: any),
85 + useDeferredValue: unsupportedHook as any,
86 + useTransition: unsupportedHook as any,
87 + useSyncExternalStore: unsupportedHook as any,
88 useId,
89 - useHostTransitionStatus: (unsupportedHook: any),
90 - useFormState: (unsupportedHook: any),
91 - useActionState: (unsupportedHook: any),
92 - useOptimistic: (unsupportedHook: any),
89 + useHostTransitionStatus: unsupportedHook as any,
90 + useFormState: unsupportedHook as any,
91 + useActionState: unsupportedHook as any,
92 + useOptimistic: unsupportedHook as any,
93 useMemoCache(size: number): Array<any> {
94 const data = new Array<any>(size);
95 for (let i = 0; i < size; i++) {
@@ -100,7 +100,7 @@ export const HooksDispatcher: Dispatcher = {
100 useCacheRefresh(): <T>(?() => T, ?T) => void {
101 return unsupportedRefresh;
102 },
103 - useEffectEvent: (unsupportedHook: any),
103 + useEffectEvent: unsupportedHook as any,
104 };
105
106 function unsupportedHook(): void {
@@ -135,7 +135,7 @@ function use<T>(usable: Usable<T>): T {
135 // $FlowFixMe[method-unbinding]
136 if (typeof usable.then === 'function') {
137 // This is a thenable.
138 - const thenable: Thenable<T> = (usable: any);
138 + const thenable: Thenable<T> = usable as any;
139
140 // Track the position of the thenable within this fiber.
141 const index = thenableIndexCounter;
packages/react-server/src/ReactFlightReplyServer.js
+44 -44
@@ -70,7 +70,7 @@ const ERRORED = 'rejected';
70 const __PROTO__ = '__proto__';
71
72 type RESPONSE_SYMBOL_TYPE = 'RESPONSE_SYMBOL'; // Fake symbol type.
73 -const RESPONSE_SYMBOL: RESPONSE_SYMBOL_TYPE = (Symbol(): any);
73 +const RESPONSE_SYMBOL: RESPONSE_SYMBOL_TYPE = Symbol() as any;
74
75 type PendingChunk<T> = {
76 status: 'pending',
@@ -124,7 +124,7 @@ function ReactPromise(status: any, value: any, reason: any) {
124 this.reason = reason;
125 }
126 // We subclass Promise.prototype so that we get other methods like .catch
127 -ReactPromise.prototype = (Object.create(Promise.prototype): any);
127 +ReactPromise.prototype = Object.create(Promise.prototype) as any;
128 // TODO: This doesn't return a new Promise chain unlike the real .then
129 ReactPromise.prototype.then = function <T>(
130 this: SomeChunk<T>,
@@ -178,15 +178,15 @@ ReactPromise.prototype.then = function <T>(
178 case BLOCKED:
179 if (typeof resolve === 'function') {
180 if (chunk.value === null) {
181 - chunk.value = ([]: Array<InitializationReference | (T => mixed)>);
181 + chunk.value = [] as Array<InitializationReference | (T => mixed)>;
182 }
183 chunk.value.push(resolve);
184 }
185 if (typeof reject === 'function') {
186 if (chunk.reason === null) {
187 - chunk.reason = ([]: Array<
187 + chunk.reason = [] as Array<
188 InitializationReference | (mixed => mixed),
189 - >);
189 + >;
190 }
191 chunk.reason.push(reject);
192 }
@@ -216,7 +216,7 @@ export type Response = {
216
217 export function getRoot<T>(response: Response): Thenable<T> {
218 const chunk = getChunk(response, 0);
219 - return (chunk: any);
219 + return chunk as any;
220 }
221
222 function createPendingChunk<T>(response: Response): PendingChunk<T> {
@@ -301,14 +301,14 @@ function triggerErrorOnChunk<T>(
301 if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
302 // If we get more data to an already resolved ID, we assume that it's
303 // a stream chunk since any other row shouldn't have more than one entry.
304 - const streamChunk: InitializedStreamChunk<any> = (chunk: any);
304 + const streamChunk: InitializedStreamChunk<any> = chunk as any;
305 const controller = streamChunk.reason;
306 // $FlowFixMe[incompatible-type]: The error method should accept mixed.
307 controller.error(error);
308 return;
309 }
310 const listeners = chunk.reason;
311 - const erroredChunk: ErroredChunk<T> = (chunk: any);
311 + const erroredChunk: ErroredChunk<T> = chunk as any;
312 erroredChunk.status = ERRORED;
313 erroredChunk.reason = error;
314 if (listeners !== null) {
@@ -345,7 +345,7 @@ function resolveModelChunk<T>(
345 if (chunk.status !== PENDING) {
346 // If we get more data to an already resolved ID, we assume that it's
347 // a stream chunk since any other row shouldn't have more than one entry.
348 - const streamChunk: InitializedStreamChunk<any> = (chunk: any);
348 + const streamChunk: InitializedStreamChunk<any> = chunk as any;
349 const controller = streamChunk.reason;
350 if (value[0] === 'C') {
351 controller.close(value === 'C' ? '"$undefined"' : value.slice(1));
@@ -356,7 +356,7 @@ function resolveModelChunk<T>(
356 }
357 const resolveListeners = chunk.value;
358 const rejectListeners = chunk.reason;
359 - const resolvedChunk: ResolvedModelChunk<T> = (chunk: any);
359 + const resolvedChunk: ResolvedModelChunk<T> = chunk as any;
360 resolvedChunk.status = RESOLVED_MODEL;
361 resolvedChunk.value = value;
362 resolvedChunk.reason = {id, [RESPONSE_SYMBOL]: response};
@@ -421,27 +421,27 @@ function loadServerReference<A: Iterable<any>, T>(
421 ): (...A) => Promise<T> {
422 const id: ServerReferenceId = metaData.id;
423 if (typeof id !== 'string') {
424 - return (null: any);
424 + return null as any;
425 }
426 if (key === 'then') {
427 // This should never happen because we always serialize objects with then-functions
428 // as "thenable" which reduces to ReactPromise with no other fields.
429 - return (null: any);
429 + return null as any;
430 }
431
432 // Check for a cached promise from a previous call with the same metadata.
433 // This handles deduplication when the same server reference appears multiple
434 // times in the payload.
435 - const cachedPromise: SomeChunk<T> | void = (metaData: any).$$promise;
435 + const cachedPromise: SomeChunk<T> | void = (metaData as any).$$promise;
436 if (cachedPromise !== undefined) {
437 if (cachedPromise.status === INITIALIZED) {
438 // The value was already resolved by a previous call.
439 const resolvedValue: T = cachedPromise.value;
440 if (key === __PROTO__) {
441 - return (null: any);
441 + return null as any;
442 }
443 parentObject[key] = resolvedValue;
444 - return (resolvedValue: any);
444 + return resolvedValue as any;
445 }
446
447 // The promise is still blocked. Increment the handler dependency count ...
@@ -465,14 +465,14 @@ function loadServerReference<A: Iterable<any>, T>(
465 );
466
467 // Return a place holder value for now.
468 - return (null: any);
468 + return null as any;
469 }
470
471 // This is the first call for this server reference metadata. Create a cached
472 // promise to be used for subsequent calls.
473 // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
474 const blockedPromise: BlockedChunk<T> = new ReactPromise(BLOCKED, null, null);
475 - (metaData: any).$$promise = blockedPromise;
475 + (metaData as any).$$promise = blockedPromise;
476
477 const serverReference: ServerReference<T> =
478 resolveServerReference<$FlowFixMe>(response._bundlerConfig, id);
@@ -486,9 +486,9 @@ function loadServerReference<A: Iterable<any>, T>(
486 if (bound instanceof ReactPromise) {
487 serverReferencePromise = Promise.resolve(bound);
488 } else {
489 - const resolvedValue = (requireModule(serverReference): any);
489 + const resolvedValue = requireModule(serverReference) as any;
490 // Resolve the cached promise synchronously.
491 - const initializedPromise: InitializedChunk<T> = (blockedPromise: any);
491 + const initializedPromise: InitializedChunk<T> = blockedPromise as any;
492 initializedPromise.status = INITIALIZED;
493 initializedPromise.value = resolvedValue;
494 initializedPromise.reason = null;
@@ -513,11 +513,11 @@ function loadServerReference<A: Iterable<any>, T>(
513 }
514
515 function fulfill(): void {
516 - let resolvedValue = (requireModule(serverReference): any);
516 + let resolvedValue = requireModule(serverReference) as any;
517
518 if (metaData.bound) {
519 // This promise is coming from us and should have initialized by now.
520 - const promiseValue = (metaData.bound: any).value;
520 + const promiseValue = (metaData.bound as any).value;
521 const boundArgs: Array<any> = isArray(promiseValue)
522 ? promiseValue.slice(0)
523 : [];
@@ -539,7 +539,7 @@ function loadServerReference<A: Iterable<any>, T>(
539
540 // Resolve the cached promise so subsequent references can use the value.
541 const resolveListeners = blockedPromise.value;
542 - const initializedPromise: InitializedChunk<T> = (blockedPromise: any);
542 + const initializedPromise: InitializedChunk<T> = blockedPromise as any;
543 initializedPromise.status = INITIALIZED;
544 initializedPromise.value = resolvedValue;
545 initializedPromise.reason = null;
@@ -555,7 +555,7 @@ function loadServerReference<A: Iterable<any>, T>(
555 function reject(error: mixed): void {
556 // Mark the cached promise as errored so subsequent references fail too.
557 const rejectListeners = blockedPromise.reason;
558 - const erroredPromise: ErroredChunk<T> = (blockedPromise: any);
558 + const erroredPromise: ErroredChunk<T> = blockedPromise as any;
559 erroredPromise.status = ERRORED;
560 erroredPromise.value = null;
561 erroredPromise.reason = error;
@@ -571,7 +571,7 @@ function loadServerReference<A: Iterable<any>, T>(
571 serverReferencePromise.then(fulfill, reject);
572
573 // Return a place holder value for now.
574 - return (null: any);
574 + return null as any;
575 }
576
577 function reviveModel(
@@ -608,10 +608,10 @@ function reviveModel(
608 if (isArray(value)) {
609 let childContext: NestedArrayContext;
610 if (arrayRoot === null) {
611 - childContext = ({
611 + childContext = {
612 count: 0,
613 fork: false,
614 - }: NestedArrayContext);
614 + } as NestedArrayContext;
615 response._rootArrayContexts.set(value, childContext);
616 } else {
617 childContext = arrayRoot;
@@ -731,7 +731,7 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
731 // We go to the BLOCKED state until we've fully resolved this.
732 // We do this before parsing in case we try to initialize the same chunk
733 // while parsing the model. Such as in a cyclic reference.
734 - const cyclicChunk: BlockedChunk<T> = (chunk: any);
734 + const cyclicChunk: BlockedChunk<T> = chunk as any;
735 cyclicChunk.status = BLOCKED;
736 cyclicChunk.value = null;
737 cyclicChunk.reason = null;
@@ -783,12 +783,12 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
783 return;
784 }
785 }
786 - const initializedChunk: InitializedChunk<T> = (chunk: any);
786 + const initializedChunk: InitializedChunk<T> = chunk as any;
787 initializedChunk.status = INITIALIZED;
788 initializedChunk.value = value;
789 initializedChunk.reason = arrayRoot;
790 } catch (error) {
791 - const erroredChunk: ErroredChunk<T> = (chunk: any);
791 + const erroredChunk: ErroredChunk<T> = chunk as any;
792 erroredChunk.status = ERRORED;
793 erroredChunk.reason = error;
794 } finally {
@@ -810,7 +810,7 @@ export function reportGlobalError(response: Response, error: Error): void {
810 } else if (chunk.status === INITIALIZED) {
811 const initializedChunk:
812 | InitializedChunk<any>
813 - | InitializedStreamChunk<any> = (chunk: any);
813 + | InitializedStreamChunk<any> = chunk as any;
814 if (initializedChunk.reason !== null) {
815 const maybeController = initializedChunk.reason;
816 // $FlowFixMe[method-unbinding] Just doing a typeof check
@@ -947,7 +947,7 @@ function resolveReference(
947 return;
948 }
949 const resolveListeners = chunk.value;
950 - const initializedChunk: InitializedChunk<any> = (chunk: any);
950 + const initializedChunk: InitializedChunk<any> = chunk as any;
951 initializedChunk.status = INITIALIZED;
952 initializedChunk.value = handler.value;
953 initializedChunk.reason =
@@ -1026,7 +1026,7 @@ function waitForReference<T>(
1026 }
1027
1028 // Return a place holder value for now.
1029 - return (null: any);
1029 + return null as any;
1030 }
1031
1032 function getOutlinedModel<T>(
@@ -1044,7 +1044,7 @@ function getOutlinedModel<T>(
1044 case RESOLVED_MODEL:
1045 initializeModelChunk(chunk);
1046 // $FlowFixMe[incompatible-type] We just initialized this chunk so it can't be a ResolvedModelChunk anymore.
1047 - chunk = (chunk: Exclude<SomeChunk<T>, ResolvedModelChunk<T>>);
1047 + chunk = chunk as Exclude<SomeChunk<T>, ResolvedModelChunk<T>>;
1048 break;
1049 }
1050 // The status might have changed after initialization.
@@ -1081,7 +1081,7 @@ function getOutlinedModel<T>(
1081 arrayRoot =
1082 rootArrayContexts.get(
1083 // $FlowFixMe[incompatible-type] Our `isArray` typing can't narrow `mixed`
1084 - (value: $ReadOnlyArray<mixed>),
1084 + value as $ReadOnlyArray<mixed>,
1085 ) || arrayRoot;
1086 } else {
1087 arrayRoot = null;
@@ -1155,7 +1155,7 @@ function getOutlinedModel<T>(
1155 };
1156 }
1157 // Placeholder
1158 - return (null: any);
1158 + return null as any;
1159 }
1160 }
1161
@@ -1241,7 +1241,7 @@ function parseTypedArray<T: $ArrayBufferView | ArrayBuffer>(
1241
1242 // We should have this backingEntry in the store already because we emitted
1243 // it before referencing it. It should be a Blob.
1244 - const backingEntry: Blob = (getBackingEntry(response._formData, key): any);
1244 + const backingEntry: Blob = getBackingEntry(response._formData, key) as any;
1245
1246 const promise: Promise<ArrayBuffer> = backingEntry.arrayBuffer();
1247
@@ -1270,8 +1270,8 @@ function parseTypedArray<T: $ArrayBufferView | ArrayBuffer>(
1270
1271 const resolvedValue: T =
1272 constructor === ArrayBuffer
1273 - ? (buffer: any)
1274 - : (new constructor(buffer): any);
1273 + ? (buffer as any)
1274 + : (new constructor(buffer) as any);
1275
1276 if (key !== __PROTO__) {
1277 parentObject[parentKey] = resolvedValue;
@@ -1295,7 +1295,7 @@ function parseTypedArray<T: $ArrayBufferView | ArrayBuffer>(
1295 return;
1296 }
1297 const resolveListeners = chunk.value;
1298 - const initializedChunk: InitializedChunk<T> = (chunk: any);
1298 + const initializedChunk: InitializedChunk<T> = chunk as any;
1299 initializedChunk.status = INITIALIZED;
1300 initializedChunk.value = handler.value;
1301 // We don't keep an array count for this since it won't be referenced again.
@@ -1367,7 +1367,7 @@ function parseReadableStream<T>(
1367 throw new Error('Already initialized stream.');
1368 }
1369
1370 - let controller: ReadableStreamController = (null: any);
1370 + let controller: ReadableStreamController = null as any;
1371 let closed = false;
1372 const stream = new ReadableStream({
1373 type: type,
@@ -1443,7 +1443,7 @@ function parseReadableStream<T>(
1443 const blockedChunk = previousBlockedChunk;
1444 // We shouldn't get any more enqueues after this so we can set it back to null.
1445 previousBlockedChunk = null;
1446 - blockedChunk.then(() => controller.error((error: any)));
1446 + blockedChunk.then(() => controller.error(error as any));
1447 }
1448 },
1449 };
@@ -1461,7 +1461,7 @@ function FlightIterator(
1461 // TODO: The iterator could inherit the AsyncIterator prototype which is not exposed as
1462 // a global but exists as a prototype of an AsyncGenerator. However, it's not needed
1463 // to satisfy the iterable protocol.
1464 -FlightIterator.prototype = ({}: any);
1464 +FlightIterator.prototype = {} as any;
1465 FlightIterator.prototype[ASYNC_ITERATOR] = function asyncIterator(
1466 this: $AsyncIterator<any, any, void>,
1467 ) {
@@ -1868,10 +1868,10 @@ function parseModelString(
1868 const blobKey = prefix + id;
1869 // We should have this backingEntry in the store already because we emitted
1870 // it before referencing it. It should be a Blob.
1871 - const backingEntry: Blob = (getBackingEntry(
1871 + const backingEntry: Blob = getBackingEntry(
1872 response._formData,
1873 blobKey,
1874 - ): any);
1874 + ) as any;
1875 if (!(backingEntry instanceof Blob)) {
1876 throw new Error('Referenced Blob is not a Blob.');
1877 }
packages/react-server/src/ReactFlightServer.js
+109 -108
@@ -166,7 +166,7 @@ import {
166 } from './ReactFlightAsyncSequence';
167
168 // DEV-only set containing internal objects that should not be limited and turned into getters.
169 -const doNotLimit: WeakSet<Reference> = __DEV__ ? new WeakSet() : (null: any);
169 +const doNotLimit: WeakSet<Reference> = __DEV__ ? new WeakSet() : (null as any);
170
171 function defaultFilterStackFrame(
172 filename: string,
@@ -287,7 +287,7 @@ function filterStackTrace(
287 if (filterStackFrame(url, functionName, lineNumber, columnNumber)) {
288 // Use a clone because the Flight protocol isn't yet resilient to deduping
289 // objects in the debug info. TODO: Support deduping stacks.
290 - const clone: ReactCallSite = (callsite.slice(0): any);
290 + const clone: ReactCallSite = callsite.slice(0) as any;
291 clone[1] = url;
292 filteredStack.push(clone);
293 }
@@ -712,12 +712,12 @@ function RequestInstance(
712 this.hints = hints;
713 this.abortableTasks = abortSet;
714 this.pingedTasks = pingedTasks;
715 - this.completedImportChunks = ([]: Array<Chunk>);
716 - this.completedHintChunks = ([]: Array<Chunk>);
717 - this.completedRegularChunks = ([]: Array<
715 + this.completedImportChunks = [] as Array<Chunk>;
716 + this.completedHintChunks = [] as Array<Chunk>;
717 + this.completedRegularChunks = [] as Array<
718 Chunk | BinaryChunk | typeof NEXT_TWO_CHUNKS_ARE_ATOMIC,
719 - >);
720 - this.completedErrorChunks = ([]: Array<Chunk>);
719 + >;
720 + this.completedErrorChunks = [] as Array<Chunk>;
721 this.writtenSymbols = new Map();
722 this.writtenClientReferences = new Map();
723 this.writtenServerReferences = new Map();
@@ -732,9 +732,9 @@ function RequestInstance(
732
733 if (__DEV__) {
734 this.pendingDebugChunks = 0;
735 - this.completedDebugChunks = ([]: Array<
735 + this.completedDebugChunks = [] as Array<
736 Chunk | BinaryChunk | typeof NEXT_TWO_CHUNKS_ARE_ATOMIC,
737 - >);
737 + >;
738 this.debugDestination = null;
739 this.environmentName =
740 environmentName === undefined
@@ -960,7 +960,7 @@ function serializeDebugThenable(
960 // safe to defer them. This also ensures that we don't eagerly call .then() on a Promise that
961 // otherwise wouldn't have initialized. It also ensures that we don't "handle" a rejection
962 // that otherwise would have triggered unhandled rejection.
963 - deferredDebugObjects.retained.set(id, (thenable: any));
963 + deferredDebugObjects.retained.set(id, thenable as any);
964 const deferredRef = '$Y@' + id.toString(16);
965 // We can now refer to the deferred object in the future.
966 request.writtenDebugObjects.set(thenable, deferredRef);
@@ -1023,8 +1023,8 @@ function serializeDebugThenable(
1023 emitDebugHaltChunk(request, id);
1024 enqueueFlush(request);
1025 // Clean up the request so we don't leak this forever.
1026 - request = (null: any);
1027 - counter = (null: any);
1026 + request = null as any;
1027 + counter = null as any;
1028 });
1029
1030 return ref;
@@ -1067,7 +1067,7 @@ function serializeThenable(
1067 ): number {
1068 const newTask = createTask(
1069 request,
1070 - (thenable: any), // will be replaced by the value before we retry. used for debug info.
1070 + thenable as any, // will be replaced by the value before we retry. used for debug info.
1071 task.keyPath, // the server component sequence continues through Promise-as-a-child.
1072 task.implicitSlot,
1073 task.formatContext,
@@ -1103,7 +1103,7 @@ function serializeThenable(
1103 haltTask(newTask, request);
1104 finishHaltedTask(newTask, request);
1105 } else {
1106 - const errorId: number = (request.fatalError: any);
1106 + const errorId: number = request.fatalError as any;
1107 abortTask(newTask, request, errorId);
1108 finishAbortedTask(newTask, request, errorId);
1109 }
@@ -1115,19 +1115,19 @@ function serializeThenable(
1115 // some custom userspace implementation. We treat it as "pending".
1116 break;
1117 }
1118 - const pendingThenable: PendingThenable<mixed> = (thenable: any);
1118 + const pendingThenable: PendingThenable<mixed> = thenable as any;
1119 pendingThenable.status = 'pending';
1120 pendingThenable.then(
1121 fulfilledValue => {
1122 if (thenable.status === 'pending') {
1123 - const fulfilledThenable: FulfilledThenable<mixed> = (thenable: any);
1123 + const fulfilledThenable: FulfilledThenable<mixed> = thenable as any;
1124 fulfilledThenable.status = 'fulfilled';
1125 fulfilledThenable.value = fulfilledValue;
1126 }
1127 },
1128 (error: mixed) => {
1129 if (thenable.status === 'pending') {
1130 - const rejectedThenable: RejectedThenable<mixed> = (thenable: any);
1130 + const rejectedThenable: RejectedThenable<mixed> = thenable as any;
1131 rejectedThenable.status = 'rejected';
1132 rejectedThenable.reason = error;
1133 }
@@ -1231,7 +1231,7 @@ function serializeReadableStream(
1231 streamTask.model = entry.value;
1232 if (isByteStream) {
1233 // Chunks of byte streams are always Uint8Array instances.
1234 - const chunk: Uint8Array = (streamTask.model: any);
1234 + const chunk: Uint8Array = streamTask.model as any;
1235 emitTypedArrayChunk(request, streamTask.id, 'b', chunk, false);
1236 } else {
1237 tryStreamTask(request, streamTask);
@@ -1310,7 +1310,7 @@ function serializeAsyncIterable(
1310 );
1311
1312 if (__DEV__) {
1313 - const debugInfo: ?ReactDebugInfo = (iterable: any)._debugInfo;
1313 + const debugInfo: ?ReactDebugInfo = (iterable as any)._debugInfo;
1314 if (debugInfo) {
1315 forwardDebugInfo(request, streamTask, debugInfo);
1316 }
@@ -1383,7 +1383,7 @@ function serializeAsyncIterable(
1383 request.cacheController.signal.removeEventListener('abort', abortIterable);
1384 erroredTask(request, streamTask, reason);
1385 enqueueFlush(request);
1386 - if (typeof (iterator: any).throw === 'function') {
1386 + if (typeof (iterator as any).throw === 'function') {
1387 // The iterator protocol doesn't necessarily include this but a generator do.
1388 // $FlowFixMe[prop-missing] should be able to pass mixed
1389 iterator.throw(reason).then(error, error);
@@ -1405,7 +1405,7 @@ function serializeAsyncIterable(
1405 erroredTask(request, streamTask, signal.reason);
1406 enqueueFlush(request);
1407 }
1408 - if (typeof (iterator: any).throw === 'function') {
1408 + if (typeof (iterator as any).throw === 'function') {
1409 // The iterator protocol doesn't necessarily include this but a generator do.
1410 // $FlowFixMe[prop-missing] should be able to pass mixed
1411 iterator.throw(reason).then(error, error);
@@ -1453,7 +1453,7 @@ function createLazyWrapperAroundWakeable(
1453 ) {
1454 // This is a temporary fork of the `use` implementation until we accept
1455 // promises everywhere.
1456 - const thenable: Thenable<mixed> = (wakeable: any);
1456 + const thenable: Thenable<mixed> = wakeable as any;
1457 switch (thenable.status) {
1458 case 'fulfilled': {
1459 forwardDebugInfoFromThenable(request, task, thenable, null, null);
@@ -1469,13 +1469,13 @@ function createLazyWrapperAroundWakeable(
1469 // some custom userspace implementation. We treat it as "pending".
1470 break;
1471 }
1472 - const pendingThenable: PendingThenable<mixed> = (thenable: any);
1472 + const pendingThenable: PendingThenable<mixed> = thenable as any;
1473 pendingThenable.status = 'pending';
1474 pendingThenable.then(
1475 fulfilledValue => {
1476 forwardDebugInfoFromCurrentContext(request, task, thenable);
1477 if (thenable.status === 'pending') {
1478 - const fulfilledThenable: FulfilledThenable<mixed> = (thenable: any);
1478 + const fulfilledThenable: FulfilledThenable<mixed> = thenable as any;
1479 fulfilledThenable.status = 'fulfilled';
1480 fulfilledThenable.value = fulfilledValue;
1481 }
@@ -1483,7 +1483,7 @@ function createLazyWrapperAroundWakeable(
1483 (error: mixed) => {
1484 forwardDebugInfoFromCurrentContext(request, task, thenable);
1485 if (thenable.status === 'pending') {
1486 - const rejectedThenable: RejectedThenable<mixed> = (thenable: any);
1486 + const rejectedThenable: RejectedThenable<mixed> = thenable as any;
1487 rejectedThenable.status = 'rejected';
1488 rejectedThenable.reason = error;
1489 }
@@ -1581,11 +1581,11 @@ function processServerComponentReturnValue(
1581 }
1582
1583 if (__DEV__) {
1584 - if ((result: any).$$typeof === REACT_ELEMENT_TYPE) {
1584 + if ((result as any).$$typeof === REACT_ELEMENT_TYPE) {
1585 // If the server component renders to an element, then it was in a static position.
1586 // That doesn't need further validation of keys. The Server Component itself would
1587 // have had a key.
1588 - (result: any)._store.validated = 1;
1588 + (result as any)._store.validated = 1;
1589 }
1590 }
1591
@@ -1623,23 +1623,23 @@ function processServerComponentReturnValue(
1623 }
1624 }
1625 }
1626 - return (iterator: any);
1626 + return iterator as any;
1627 },
1628 };
1629 if (__DEV__) {
1630 - (multiShot: any)._debugInfo = iterableChild._debugInfo;
1630 + (multiShot as any)._debugInfo = iterableChild._debugInfo;
1631 }
1632 return multiShot;
1633 }
1634 if (
1635 - typeof (result: any)[ASYNC_ITERATOR] === 'function' &&
1635 + typeof (result as any)[ASYNC_ITERATOR] === 'function' &&
1636 (typeof ReadableStream !== 'function' ||
1637 !(result instanceof ReadableStream))
1638 ) {
1639 const iterableChild = result;
1640 const multishot = {
1641 [ASYNC_ITERATOR]: function () {
1642 - const iterator = (iterableChild: any)[ASYNC_ITERATOR]();
1642 + const iterator = (iterableChild as any)[ASYNC_ITERATOR]();
1643 if (__DEV__) {
1644 // If this was an AsyncIterator but not an AsyncGeneratorFunction we warn because
1645 // it might have been a mistake. Technically you can make this mistake with
@@ -1667,7 +1667,7 @@ function processServerComponentReturnValue(
1667 },
1668 };
1669 if (__DEV__) {
1670 - (multishot: any)._debugInfo = iterableChild._debugInfo;
1670 + (multishot as any)._debugInfo = iterableChild._debugInfo;
1671 }
1672 return multishot;
1673 }
@@ -1700,20 +1700,20 @@ function renderFunctionComponent<Props>(
1700 // This is a replay and we've already emitted the debug info of this component
1701 // in the first pass. We skip emitting a duplicate line.
1702 // As a hack we stashed the previous component debug info on this object in DEV.
1703 - componentDebugInfo = (prevThenableState: any)._componentDebugInfo;
1703 + componentDebugInfo = (prevThenableState as any)._componentDebugInfo;
1704 } else {
1705 // This is a new component in the same task so we can emit more debug info.
1706 const componentDebugID = task.id;
1707 const componentName =
1708 - (Component: any).displayName || Component.name || '';
1708 + (Component as any).displayName || Component.name || '';
1709 const componentEnv = (0, request.environmentName)();
1710 request.pendingChunks++;
1711 - componentDebugInfo = ({
1711 + componentDebugInfo = {
1712 name: componentName,
1713 env: componentEnv,
1714 key: key,
1715 owner: task.debugOwner,
1716 - }: ReactComponentInfo);
1716 + } as ReactComponentInfo;
1717 // $FlowFixMe[cannot-write]
1718 componentDebugInfo.stack =
1719 task.debugStack === null
@@ -1784,7 +1784,7 @@ function renderFunctionComponent<Props>(
1784 }
1785 }
1786 } else {
1787 - componentDebugInfo = (null: any);
1787 + componentDebugInfo = null as any;
1788 prepareToUseHooksForComponent(prevThenableState, null);
1789 // The secondArg is always undefined in Server Components since refs error early.
1790 const secondArg = undefined;
@@ -1815,9 +1815,9 @@ function renderFunctionComponent<Props>(
1815 if (trackedThenables !== null) {
1816 const stacks: Array<Error> =
1817 __DEV__ && enableAsyncDebugInfo
1818 - ? (trackedThenables: any)._stacks ||
1819 - ((trackedThenables: any)._stacks = [])
1820 - : (null: any);
1818 + ? (trackedThenables as any)._stacks ||
1819 + ((trackedThenables as any)._stacks = [])
1820 + : (null as any);
1821 for (let i = 0; i < trackedThenables.length; i++) {
1822 const stack = __DEV__ && enableAsyncDebugInfo ? stacks[i] : null;
1823 forwardDebugInfoFromThenable(
@@ -1949,7 +1949,7 @@ function renderFragment(
1949 typeof child === 'object' &&
1950 child.$$typeof === REACT_ELEMENT_TYPE
1951 ) {
1952 - const element: ReactElement = (child: any);
1952 + const element: ReactElement = child as any;
1953 if (element.key === null && !element._store.validated) {
1954 element._store.validated = 2;
1955 }
@@ -1994,7 +1994,7 @@ function renderFragment(
1994 // be recursive serialization, we need to reset the keyPath and implicitSlot,
1995 // before recursing here.
1996 if (__DEV__) {
1997 - const debugInfo: ?ReactDebugInfo = (children: any)._debugInfo;
1997 + const debugInfo: ?ReactDebugInfo = (children as any)._debugInfo;
1998 if (debugInfo) {
1999 // If this came from Flight, forward any debug info into this new row.
2000 if (!canEmitDebugInfo) {
@@ -2595,7 +2595,7 @@ function visitAsyncNodeImpl(
2595 // Then emit a reference to us awaiting it in the current task.
2596 request.pendingChunks++;
2597 emitDebugChunk(request, task.id, {
2598 - awaited: ((ioNode: any): ReactIOInfo), // This is deduped by this reference.
2598 + awaited: ioNode as any as ReactIOInfo, // This is deduped by this reference.
2599 env: env,
2600 owner: node.owner,
2601 stack:
@@ -2665,7 +2665,7 @@ function emitAsyncSequence(
2665 // If we don't have any thing awaited, the time we started awaiting was internal
2666 // when we yielded after rendering. The current task time is basically that.
2667 const debugInfo: ReactAsyncInfo = {
2668 - awaited: ((awaitedNode: any): ReactIOInfo), // This is deduped by this reference.
2668 + awaited: awaitedNode as any as ReactIOInfo, // This is deduped by this reference.
2669 env: env,
2670 };
2671 if (__DEV__) {
@@ -2753,7 +2753,7 @@ function createTask(
2753 request.writtenObjects.set(model, serializeByValueID(id));
2754 }
2755 }
2756 - const task: Task = (({
2756 + const task: Task = {
2757 id,
2758 status: PENDING,
2759 model,
@@ -2811,7 +2811,7 @@ function createTask(
2811 return renderModel(request, task, parent, parentPropertyName, value);
2812 },
2813 thenableState: null,
2814 - }: Omit<
2814 + } as Omit<
2815 Task,
2816 | 'timed'
2817 | 'time'
@@ -2819,7 +2819,7 @@ function createTask(
2819 | 'debugOwner'
2820 | 'debugStack'
2821 | 'debugTask',
2822 - >): any);
2822 + > as any;
2823 if (
2824 enableProfilerTimer &&
2825 (enableComponentPerformanceTrack || enableAsyncDebugInfo)
@@ -3153,7 +3153,7 @@ function serializeMap(
3153
3154 function serializeFormData(request: Request, formData: FormData): string {
3155 const entries = Array.from(formData.entries());
3156 - const id = outlineModel(request, (entries: any));
3156 + const id = outlineModel(request, entries as any);
3157 return '$K' + id.toString(16);
3158 }
3159
@@ -3162,7 +3162,7 @@ function serializeDebugFormData(request: Request, formData: FormData): string {
3162 const id = outlineDebugModel(
3163 request,
3164 {objectLimit: entries.length * 2 + 1},
3165 - (entries: any),
3165 + entries as any,
3166 );
3167 return '$K' + id.toString(16);
3168 }
@@ -3400,8 +3400,8 @@ function renderModel(
3400 const wasReactNode =
3401 typeof model === 'object' &&
3402 model !== null &&
3403 - ((model: any).$$typeof === REACT_ELEMENT_TYPE ||
3404 - (model: any).$$typeof === REACT_LAZY_TYPE);
3403 + ((model as any).$$typeof === REACT_ELEMENT_TYPE ||
3404 + (model as any).$$typeof === REACT_LAZY_TYPE);
3405
3406 if (request.status === ABORTING) {
3407 task.status = ABORTED;
@@ -3410,7 +3410,7 @@ function renderModel(
3410 // the new task won't be retried because we are aborting
3411 return outlineHaltedTask(request, task, wasReactNode);
3412 }
3413 - const errorId = (request.fatalError: any);
3413 + const errorId = request.fatalError as any;
3414 if (wasReactNode) {
3415 return serializeLazyID(errorId);
3416 }
@@ -3448,7 +3448,7 @@ function renderModel(
3448 __DEV__ ? task.debugTask : null,
3449 );
3450 const ping = newTask.ping;
3451 - (x: any).then(ping, ping);
3451 + (x as any).then(ping, ping);
3452 newTask.thenableState = getThenableStateAfterSuspending();
3453
3454 // Restore the context. We assume that this will be restored by the inner
@@ -3524,7 +3524,7 @@ function renderModelDestructive(
3524 }
3525
3526 if (typeof value === 'object') {
3527 - switch ((value: any).$$typeof) {
3527 + switch ((value as any).$$typeof) {
3528 case REACT_ELEMENT_TYPE: {
3529 let elementReference = null;
3530 const writtenObjects = request.writtenObjects;
@@ -3561,14 +3561,14 @@ function renderModelDestructive(
3561 }
3562 }
3563
3564 - const element: ReactElement = (value: any);
3564 + const element: ReactElement = value as any;
3565
3566 if (serializedSize > MAX_ROW_SIZE) {
3567 return deferTask(request, task);
3568 }
3569
3570 if (__DEV__) {
3571 - const debugInfo: ?ReactDebugInfo = (value: any)._debugInfo;
3571 + const debugInfo: ?ReactDebugInfo = (value as any)._debugInfo;
3572 if (debugInfo) {
3573 // If this came from Flight, forward any debug info into this new row.
3574 if (!canEmitDebugInfo) {
@@ -3654,7 +3654,7 @@ function renderModelDestructive(
3654 // from suspending the lazy before.
3655 task.thenableState = null;
3656
3657 - const lazy: LazyComponent<any, any> = (value: any);
3657 + const lazy: LazyComponent<any, any> = value as any;
3658 let resolvedModel;
3659 if (__DEV__) {
3660 resolvedModel = callLazyInitInDEV(lazy);
@@ -3710,7 +3710,7 @@ function renderModelDestructive(
3710 request,
3711 parent,
3712 parentPropertyName,
3713 - (value: any),
3713 + value as any,
3714 );
3715 }
3716
@@ -3740,7 +3740,7 @@ function renderModelDestructive(
3740 // If we're in some kind of context we can't reuse the result of this render or
3741 // previous renders of this element. We only reuse Promises if they're not wrapped
3742 // by another Server Component.
3743 - const promiseId = serializeThenable(request, task, (value: any));
3743 + const promiseId = serializeThenable(request, task, value as any);
3744 return serializePromiseID(promiseId);
3745 } else if (modelRoot === value) {
3746 // This is the ID we're currently emitting so we need to write it
@@ -3753,7 +3753,7 @@ function renderModelDestructive(
3753 }
3754 // We assume that any object with a .then property is a "Thenable" type,
3755 // or a Promise type. Either of which can be represented by a Promise.
3756 - const promiseId = serializeThenable(request, task, (value: any));
3756 + const promiseId = serializeThenable(request, task, value as any);
3757 const promiseReference = serializePromiseID(promiseId);
3758 writtenObjects.set(value, promiseReference);
3759 return promiseReference;
@@ -3883,9 +3883,9 @@ function renderModelDestructive(
3883 const iterator = iteratorFn.call(value);
3884 if (iterator === value) {
3885 // Iterator, not Iterable
3886 - return serializeIterator(request, (iterator: any));
3886 + return serializeIterator(request, iterator as any);
3887 }
3888 - return renderFragment(request, task, Array.from((iterator: any)));
3888 + return renderFragment(request, task, Array.from(iterator as any));
3889 }
3890
3891 // TODO: Blob is not available in old Node. Remove the typeof check later.
@@ -3895,11 +3895,12 @@ function renderModelDestructive(
3895 ) {
3896 return serializeReadableStream(request, task, value);
3897 }
3898 - const getAsyncIterator: void | (() => $AsyncIterator<any, any, any>) =
3899 - (value: any)[ASYNC_ITERATOR];
3898 + const getAsyncIterator: void | (() => $AsyncIterator<any, any, any>) = (
3899 + value as any
3900 + )[ASYNC_ITERATOR];
3901 if (typeof getAsyncIterator === 'function') {
3902 // We treat AsyncIterables as a Fragment and as such we might need to key them.
3902 - return renderAsyncFragment(request, task, (value: any), getAsyncIterator);
3903 + return renderAsyncFragment(request, task, value as any, getAsyncIterator);
3904 }
3905
3906 // We put the Date check low b/c most of the time Date's will already have been serialized
@@ -4004,11 +4005,11 @@ function renderModelDestructive(
4005 request,
4006 parent,
4007 parentPropertyName,
4007 - (value: any),
4008 + value as any,
4009 );
4010 }
4011 if (isServerReference(value)) {
4011 - return serializeServerReference(request, (value: any));
4012 + return serializeServerReference(request, value as any);
4013 }
4014 if (request.temporaryReferences !== undefined) {
4015 const tempRef = resolveTemporaryReference(
@@ -4187,7 +4188,7 @@ function serializeErrorValue(request: Request, error: Error): string {
4188 // eslint-disable-next-line react-internal/safe-string-coercion
4189 message = String(error.message);
4190 stack = filterStackTrace(request, parseStackTrace(error, 0));
4190 - const errorEnv = (error: any).environmentName;
4191 + const errorEnv = (error as any).environmentName;
4192 if (typeof errorEnv === 'string') {
4193 // This probably came from another FlightClient as a pass through.
4194 // Keep the environment name.
@@ -4199,7 +4200,7 @@ function serializeErrorValue(request: Request, error: Error): string {
4200 }
4201 const errorInfo: ReactErrorInfoDev = {name, message, stack, env};
4202 if ('cause' in error) {
4202 - const cause: ReactClientValue = (error.cause: any);
4203 + const cause: ReactClientValue = error.cause as any;
4204 const causeId = outlineModel(request, cause);
4205 errorInfo.cause = serializeByValueID(causeId);
4206 }
@@ -4207,7 +4208,7 @@ function serializeErrorValue(request: Request, error: Error): string {
4208 typeof AggregateError !== 'undefined' &&
4209 error instanceof AggregateError
4210 ) {
4210 - const errors: ReactClientValue = (error.errors: any);
4211 + const errors: ReactClientValue = error.errors as any;
4212 const errorsId = outlineModel(request, errors);
4213 errorInfo.errors = serializeByValueID(errorsId);
4214 }
@@ -4236,7 +4237,7 @@ function serializeDebugErrorValue(
4237 // eslint-disable-next-line react-internal/safe-string-coercion
4238 message = String(error.message);
4239 stack = filterStackTrace(request, parseStackTrace(error, 0));
4239 - const errorEnv = (error: any).environmentName;
4240 + const errorEnv = (error as any).environmentName;
4241 if (typeof errorEnv === 'string') {
4242 // This probably came from another FlightClient as a pass through.
4243 // Keep the environment name.
@@ -4249,7 +4250,7 @@ function serializeDebugErrorValue(
4250 const errorInfo: ReactErrorInfoDev = {name, message, stack, env};
4251 if ('cause' in error) {
4252 counter.objectLimit--;
4252 - const cause: ReactClientValue = (error.cause: any);
4253 + const cause: ReactClientValue = error.cause as any;
4254 const causeId = outlineDebugModel(request, counter, cause);
4255 errorInfo.cause = serializeByValueID(causeId);
4256 }
@@ -4258,7 +4259,7 @@ function serializeDebugErrorValue(
4259 error instanceof AggregateError
4260 ) {
4261 counter.objectLimit--;
4261 - const errors: ReactClientValue = (error.errors: any);
4262 + const errors: ReactClientValue = error.errors as any;
4263 const errorsId = outlineDebugModel(request, counter, errors);
4264 errorInfo.errors = serializeByValueID(errorsId);
4265 }
@@ -4298,14 +4299,14 @@ function emitErrorChunk(
4299 // eslint-disable-next-line react-internal/safe-string-coercion
4300 message = String(error.message);
4301 stack = filterStackTrace(request, parseStackTrace(error, 0));
4301 - const errorEnv = (error: any).environmentName;
4302 + const errorEnv = (error as any).environmentName;
4303 if (typeof errorEnv === 'string') {
4304 // This probably came from another FlightClient as a pass through.
4305 // Keep the environment name.
4306 env = errorEnv;
4307 }
4308 if ('cause' in error) {
4308 - const cause: ReactClientValue = (error.cause: any);
4309 + const cause: ReactClientValue = error.cause as any;
4310 const causeId = debug
4311 ? outlineDebugModel(request, {objectLimit: 5}, cause)
4312 : outlineModel(request, cause);
@@ -4315,7 +4316,7 @@ function emitErrorChunk(
4316 typeof AggregateError !== 'undefined' &&
4317 error instanceof AggregateError
4318 ) {
4318 - const errors: ReactClientValue = (error.errors: any);
4319 + const errors: ReactClientValue = error.errors as any;
4320 const errorsId = debug
4321 ? outlineDebugModel(request, {objectLimit: 5}, errors)
4322 : outlineModel(request, errors);
@@ -4337,10 +4338,10 @@ function emitErrorChunk(
4338 owner == null ? null : outlineComponentInfo(request, owner);
4339 errorInfo = {digest, name, message, stack, env, owner: ownerRef};
4340 if (causeReference !== null) {
4340 - (errorInfo: ReactErrorInfoDev).cause = causeReference;
4341 + (errorInfo as ReactErrorInfoDev).cause = causeReference;
4342 }
4343 if (errorsReference !== null) {
4343 - (errorInfo: ReactErrorInfoDev).errors = errorsReference;
4344 + (errorInfo as ReactErrorInfoDev).errors = errorsReference;
4345 }
4346 } else {
4347 errorInfo = {digest};
@@ -4796,7 +4797,7 @@ function serializeEval(source: string): string {
4797 return '$E' + source;
4798 }
4799
4799 -const CONSTRUCTOR_MARKER: symbol = __DEV__ ? Symbol() : (null: any);
4800 +const CONSTRUCTOR_MARKER: symbol = __DEV__ ? Symbol() : (null as any);
4801
4802 let debugModelRoot: mixed = null;
4803 let debugNoOutline: mixed = null;
@@ -4830,11 +4831,11 @@ function renderDebugModel(
4831 request,
4832 parent,
4833 parentPropertyName,
4833 - (value: any),
4834 + value as any,
4835 );
4836 }
4837 if (value.$$typeof === CONSTRUCTOR_MARKER) {
4837 - const constructor: Function = (value: any).constructor;
4838 + const constructor: Function = (value as any).constructor;
4839 let ref = request.writtenDebugObjects.get(constructor);
4840 if (ref === undefined) {
4841 const id = outlineDebugModel(request, counter, constructor);
@@ -4903,7 +4904,7 @@ function renderDebugModel(
4904 // $FlowFixMe[method-unbinding]
4905 if (typeof value.then === 'function') {
4906 // If this is a Promise we're going to assign it an external ID anyway which can be deduped.
4906 - const thenable: Thenable<any> = (value: any);
4907 + const thenable: Thenable<any> = value as any;
4908 return serializeDebugThenable(request, counter, thenable);
4909 } else {
4910 const outlinedId = outlineDebugModel(request, counter, value);
@@ -4941,9 +4942,9 @@ function renderDebugModel(
4942 }
4943 }
4944
4944 - switch ((value: any).$$typeof) {
4945 + switch ((value as any).$$typeof) {
4946 case REACT_ELEMENT_TYPE: {
4946 - const element: ReactElement = (value: any);
4947 + const element: ReactElement = value as any;
4948
4949 if (element._owner != null) {
4950 outlineComponentInfo(request, element._owner);
@@ -4988,7 +4989,7 @@ function renderDebugModel(
4989 // some assumptions about the structure of the payload even though
4990 // that's not really part of the contract. In practice, this is really
4991 // just coming from React.lazy helper or Flight.
4991 - const lazy: LazyComponent<any, any> = (value: any);
4992 + const lazy: LazyComponent<any, any> = value as any;
4993 const payload = lazy._payload;
4994
4995 if (payload !== null && typeof payload === 'object') {
@@ -5051,7 +5052,7 @@ function renderDebugModel(
5052
5053 // $FlowFixMe[method-unbinding]
5054 if (typeof value.then === 'function') {
5054 - const thenable: Thenable<any> = (value: any);
5055 + const thenable: Thenable<any> = value as any;
5056 return serializeDebugThenable(request, counter, thenable);
5057 }
5058
@@ -5138,7 +5139,7 @@ function renderDebugModel(
5139
5140 const iteratorFn = getIteratorFn(value);
5141 if (iteratorFn) {
5141 - return Array.from((value: any));
5142 + return Array.from(value as any);
5143 }
5144
5145 const proto = getPrototypeOf(value);
@@ -5219,7 +5220,7 @@ function renderDebugModel(
5220 request,
5221 parent,
5222 parentPropertyName,
5222 - (value: any),
5223 + value as any,
5224 );
5225 }
5226 if (request.temporaryReferences !== undefined) {
@@ -5322,12 +5323,12 @@ function serializeDebugModel(
5323 try {
5324 // $FlowFixMe[incompatible-cast] stringify can return null
5325 // $FlowFixMe[incompatible-type]
5325 - return (stringify(model, replacer): string);
5326 + return stringify(model, replacer) as string;
5327 } catch (x) {
5328 // $FlowFixMe[incompatible-cast] stringify can return null
5328 - return (stringify(
5329 + return stringify(
5330 'Unknown Value: React could not send it from the server.\n' + x.message,
5330 - ): string);
5331 + ) as string;
5332 } finally {
5333 debugNoOutline = prevNoOutline;
5334 }
@@ -5386,12 +5387,12 @@ function emitOutlinedDebugModelChunk(
5387 let json: string;
5388 try {
5389 // $FlowFixMe[incompatible-type] stringify can return null
5389 - json = (stringify(model, replacer): string);
5390 + json = stringify(model, replacer) as string;
5391 } catch (x) {
5392 // $FlowFixMe[incompatible-type] stringify can return null
5392 - json = (stringify(
5393 + json = stringify(
5394 'Unknown Value: React could not send it from the server.\n' + x.message,
5394 - ): string);
5395 + ) as string;
5396 } finally {
5397 debugModelRoot = prevModelRoot;
5398 }
@@ -5494,7 +5495,7 @@ function forwardDebugInfo(
5495 // We outline this model eagerly so that we can refer to by reference as an owner.
5496 // If we had a smarter way to dedupe we might not have to do this if there ends up
5497 // being no references to this as an owner.
5497 - outlineComponentInfo(request, (info: any));
5498 + outlineComponentInfo(request, info as any);
5499 // Emit a reference to the outlined one.
5500 request.pendingChunks++;
5501 emitDebugChunk(request, id, info);
@@ -5619,7 +5620,7 @@ function forwardDebugInfoFromAbortedTask(request: Request, task: Task): void {
5620 if (enableProfilerTimer && enableAsyncDebugInfo) {
5621 let thenable: null | Thenable<any> = null;
5622 if (typeof model.then === 'function') {
5622 - thenable = (model: any);
5623 + thenable = model as any;
5624 } else if (model.$$typeof === REACT_LAZY_TYPE) {
5625 const payload = model._payload;
5626 if (typeof payload.then === 'function') {
@@ -5643,7 +5644,7 @@ function forwardDebugInfoFromAbortedTask(request: Request, task: Task): void {
5644 request.pendingChunks++;
5645 const env = (0, request.environmentName)();
5646 const asyncInfo: ReactAsyncInfo = {
5646 - awaited: ((node: any): ReactIOInfo), // This is deduped by this reference.
5647 + awaited: node as any as ReactIOInfo, // This is deduped by this reference.
5648 env: env,
5649 };
5650 // We don't have a start time for this await but in case there was no start time emitted
@@ -5942,7 +5943,7 @@ function retryTask(request: Request, task: Task): void {
5943 finishHaltedTask(task, request);
5944 } else {
5945 // Otherwise we emit an error chunk into the task slot.
5945 - const errorId: number = (request.fatalError: any);
5946 + const errorId: number = request.fatalError as any;
5947 abortTask(task, request, errorId);
5948 finishAbortedTask(task, request, errorId);
5949 }
@@ -6097,16 +6098,16 @@ function flushCompletedChunks(request: Request): void {
6098 request.pendingDebugChunks -= 2;
6099 writeChunk(
6100 debugDestination,
6100 - ((debugChunks[i + 1]: any): Chunk | BinaryChunk),
6101 + debugChunks[i + 1] as any as Chunk | BinaryChunk,
6102 );
6103 writeChunk(
6104 debugDestination,
6104 - ((debugChunks[i + 2]: any): Chunk | BinaryChunk),
6105 + debugChunks[i + 2] as any as Chunk | BinaryChunk,
6106 );
6107 i += 2;
6108 } else {
6109 request.pendingDebugChunks--;
6109 - writeChunk(debugDestination, ((item: any): Chunk | BinaryChunk));
6110 + writeChunk(debugDestination, item as any as Chunk | BinaryChunk);
6111 }
6112 }
6113 debugChunks.splice(0, i);
@@ -6166,18 +6167,18 @@ function flushCompletedChunks(request: Request): void {
6167 request.pendingDebugChunks -= 2;
6168 writeChunk(
6169 destination,
6169 - ((debugChunks[i + 1]: any): Chunk | BinaryChunk),
6170 + debugChunks[i + 1] as any as Chunk | BinaryChunk,
6171 );
6172 keepWriting = writeChunkAndReturn(
6173 destination,
6173 - ((debugChunks[i + 2]: any): Chunk | BinaryChunk),
6174 + debugChunks[i + 2] as any as Chunk | BinaryChunk,
6175 );
6176 i += 2;
6177 } else {
6178 request.pendingDebugChunks--;
6179 keepWriting = writeChunkAndReturn(
6180 destination,
6180 - ((item: any): Chunk | BinaryChunk),
6181 + item as any as Chunk | BinaryChunk,
6182 );
6183 }
6184 if (!keepWriting) {
@@ -6204,18 +6205,18 @@ function flushCompletedChunks(request: Request): void {
6205 request.pendingChunks -= 2;
6206 writeChunk(
6207 destination,
6207 - ((regularChunks[i + 1]: any): Chunk | BinaryChunk),
6208 + regularChunks[i + 1] as any as Chunk | BinaryChunk,
6209 );
6210 keepWriting = writeChunkAndReturn(
6211 destination,
6211 - ((regularChunks[i + 2]: any): Chunk | BinaryChunk),
6212 + regularChunks[i + 2] as any as Chunk | BinaryChunk,
6213 );
6214 i += 2;
6215 } else {
6216 request.pendingChunks--;
6217 keepWriting = writeChunkAndReturn(
6218 destination,
6218 - ((item: any): Chunk | BinaryChunk),
6219 + item as any as Chunk | BinaryChunk,
6220 );
6221 }
6222 if (!keepWriting) {
@@ -6544,7 +6545,7 @@ export function resolveDebugMessage(request: Request, message: string): void {
6545 request,
6546 id,
6547 counter,
6547 - (retainedValue: any),
6548 + retainedValue as any,
6549 );
6550 }
6551 }
packages/react-server/src/ReactFlightServerConfigDebugNode.js
+17 -17
@@ -35,7 +35,7 @@ import {parseStackTracePrivate} from './ReactFlightServerConfig';
35 const getAsyncId = AsyncResource.prototype.asyncId;
36
37 const pendingOperations: Map<number, AsyncSequence> =
38 - __DEV__ && enableAsyncDebugInfo ? new Map() : (null: any);
38 + __DEV__ && enableAsyncDebugInfo ? new Map() : (null as any);
39
40 // Keep the last resolved await as a workaround for async functions missing data.
41 let lastRanAwait: null | AwaitNode = null;
@@ -44,10 +44,10 @@ function resolvePromiseOrAwaitNode(
44 unresolvedNode: UnresolvedAwaitNode | UnresolvedPromiseNode,
45 endTime: number,
46 ): AwaitNode | PromiseNode {
47 - const resolvedNode: AwaitNode | PromiseNode = (unresolvedNode: any);
48 - resolvedNode.tag = ((unresolvedNode.tag === UNRESOLVED_PROMISE_NODE
49 - ? PROMISE_NODE
50 - : AWAIT_NODE): any);
47 + const resolvedNode: AwaitNode | PromiseNode = unresolvedNode as any;
48 + resolvedNode.tag = (
49 + unresolvedNode.tag === UNRESOLVED_PROMISE_NODE ? PROMISE_NODE : AWAIT_NODE
50 + ) as any;
51 resolvedNode.end = endTime;
52 return resolvedNode;
53 }
@@ -93,13 +93,13 @@ export function initAsyncDebugInfo(): void {
93 stack = emptyStack;
94 if (resource._debugInfo !== undefined) {
95 // We may need to forward this debug info at the end so we need to retain this promise.
96 - promiseRef = new WeakRef((resource: Promise<any>));
96 + promiseRef = new WeakRef(resource as Promise<any>);
97 } else {
98 // Otherwise, we can just refer to the inner one since that's the one we'll log anyway.
99 promiseRef = trigger.promise;
100 }
101 } else {
102 - promiseRef = new WeakRef((resource: Promise<any>));
102 + promiseRef = new WeakRef(resource as Promise<any>);
103 const request = resolveRequest();
104 if (request === null) {
105 // We don't collect stacks for awaits that weren't in the scope of a specific render.
@@ -114,7 +114,7 @@ export function initAsyncDebugInfo(): void {
114 }
115 }
116 const current = pendingOperations.get(currentAsyncId);
117 - node = ({
117 + node = {
118 tag: UNRESOLVED_AWAIT_NODE,
119 owner: resolveOwner(),
120 stack: stack,
@@ -123,23 +123,23 @@ export function initAsyncDebugInfo(): void {
123 promise: promiseRef,
124 awaited: trigger, // The thing we're awaiting on. Might get overrriden when we resolve.
125 previous: current === undefined ? null : current, // The path that led us here.
126 - }: UnresolvedAwaitNode);
126 + } as UnresolvedAwaitNode;
127 } else {
128 const owner = resolveOwner();
129 - node = ({
129 + node = {
130 tag: UNRESOLVED_PROMISE_NODE,
131 owner: owner,
132 stack:
133 owner === null ? null : parseStackTracePrivate(new Error(), 5),
134 start: performance.now(),
135 end: -1.1, // Set when we resolve.
136 - promise: new WeakRef((resource: Promise<any>)),
136 + promise: new WeakRef(resource as Promise<any>),
137 awaited:
138 trigger === undefined
139 ? null // It might get overridden when we resolve.
140 : trigger,
141 previous: null,
142 - }: UnresolvedPromiseNode);
142 + } as UnresolvedPromiseNode;
143 }
144 } else if (
145 // bound-anonymous-fn is the default name for snapshots and .bind() without a name.
@@ -167,7 +167,7 @@ export function initAsyncDebugInfo(): void {
167 if (trigger === undefined) {
168 // We have begun a new I/O sequence.
169 const owner = resolveOwner();
170 - node = ({
170 + node = {
171 tag: IO_NODE,
172 owner: owner,
173 stack:
@@ -177,14 +177,14 @@ export function initAsyncDebugInfo(): void {
177 promise: null,
178 awaited: null,
179 previous: null,
180 - }: IONode);
180 + } as IONode;
181 } else if (
182 trigger.tag === AWAIT_NODE ||
183 trigger.tag === UNRESOLVED_AWAIT_NODE
184 ) {
185 // We have begun a new I/O sequence after the await.
186 const owner = resolveOwner();
187 - node = ({
187 + node = {
188 tag: IO_NODE,
189 owner: owner,
190 stack:
@@ -194,7 +194,7 @@ export function initAsyncDebugInfo(): void {
194 promise: null,
195 awaited: null,
196 previous: trigger,
197 - }: IONode);
197 + } as IONode;
198 } else {
199 // Otherwise, this is just a continuation of the same I/O sequence.
200 node = trigger;
@@ -209,7 +209,7 @@ export function initAsyncDebugInfo(): void {
209 case IO_NODE: {
210 lastRanAwait = null;
211 // Log the end time when we resolved the I/O.
212 - const ioNode: IONode = (node: any);
212 + const ioNode: IONode = node as any;
213 if (ioNode.end < 0) {
214 ioNode.end = performance.now();
215 } else {
packages/react-server/src/ReactFlightServerTemporaryReferences.js
+2 -2
@@ -96,13 +96,13 @@ export function createTemporaryReference<T>(
96 id: string,
97 ): TemporaryReference<T> {
98 const reference: TemporaryReference<any> = Object.defineProperties(
99 - (function () {
99 + function () {
100 throw new Error(
101 `Attempted to call a temporary Client Reference from the server but it is on the client. ` +
102 `It's not possible to invoke a client function from the server, it can ` +
103 `only be rendered as a Component or passed to props of a Client Component.`,
104 );
105 - }: any),
105 + } as any,
106 {
107 $$typeof: {value: TEMPORARY_REFERENCE_TAG},
108 },
packages/react-server/src/ReactFlightStackConfigV8.js
+3 -3
@@ -93,12 +93,12 @@ function collectStackTracePrivate(
93 const enclosingLine: number =
94 // $FlowFixMe[prop-missing]
95 typeof callSite.getEnclosingLineNumber === 'function'
96 - ? (callSite: any).getEnclosingLineNumber() || 0
96 + ? (callSite as any).getEnclosingLineNumber() || 0
97 : 0;
98 const enclosingCol: number =
99 // $FlowFixMe[prop-missing]
100 typeof callSite.getEnclosingColumnNumber === 'function'
101 - ? (callSite: any).getEnclosingColumnNumber() || 0
101 + ? (callSite as any).getEnclosingColumnNumber() || 0
102 : 0;
103 // $FlowFixMe[prop-missing]
104 const isAsync = callSite.isAsync();
@@ -149,7 +149,7 @@ const frameRegExp =
149 // DEV-only cache of parsed and filtered stack frames.
150 const stackTraceCache: WeakMap<Error, ReactStackTrace> = __DEV__
151 ? new WeakMap()
152 - : (null: any);
152 + : (null as any);
153
154 // This version is only used when React fully owns the Error object and there's no risk of it having
155 // been already initialized and no risky that anyone else will initialize it later.
packages/react-server/src/ReactFlightThenable.js
+7 -7
@@ -54,7 +54,7 @@ export function trackUsedThenable<T>(
54 thenableState.push(thenable);
55 if (__DEV__ && enableAsyncDebugInfo) {
56 const stacks: Array<Error> =
57 - (thenableState: any)._stacks || ((thenableState: any)._stacks = []);
57 + (thenableState as any)._stacks || ((thenableState as any)._stacks = []);
58 stacks.push(new Error());
59 }
60 } else {
@@ -111,19 +111,19 @@ export function trackUsedThenable<T>(
111 // happen. Flight lazily parses JSON when the value is actually awaited.
112 thenable.then(noop, noop);
113 } else {
114 - const pendingThenable: PendingThenable<T> = (thenable: any);
114 + const pendingThenable: PendingThenable<T> = thenable as any;
115 pendingThenable.status = 'pending';
116 pendingThenable.then(
117 fulfilledValue => {
118 if (thenable.status === 'pending') {
119 - const fulfilledThenable: FulfilledThenable<T> = (thenable: any);
119 + const fulfilledThenable: FulfilledThenable<T> = thenable as any;
120 fulfilledThenable.status = 'fulfilled';
121 fulfilledThenable.value = fulfilledValue;
122 }
123 },
124 (error: mixed) => {
125 if (thenable.status === 'pending') {
126 - const rejectedThenable: RejectedThenable<T> = (thenable: any);
126 + const rejectedThenable: RejectedThenable<T> = thenable as any;
127 rejectedThenable.status = 'rejected';
128 rejectedThenable.reason = error;
129 }
@@ -132,13 +132,13 @@ export function trackUsedThenable<T>(
132 }
133
134 // Check one more time in case the thenable resolved synchronously
135 - switch ((thenable: Thenable<T>).status) {
135 + switch ((thenable as Thenable<T>).status) {
136 case 'fulfilled': {
137 - const fulfilledThenable: FulfilledThenable<T> = (thenable: any);
137 + const fulfilledThenable: FulfilledThenable<T> = thenable as any;
138 return fulfilledThenable.value;
139 }
140 case 'rejected': {
141 - const rejectedThenable: RejectedThenable<T> = (thenable: any);
141 + const rejectedThenable: RejectedThenable<T> = thenable as any;
142 throw rejectedThenable.reason;
143 }
144 }
packages/react-server/src/ReactServerStreamConfigBrowser.js
+5 -4
@@ -71,7 +71,7 @@ export function writeChunk(
71 if (writtenBytes > 0) {
72 destination.enqueue(
73 new Uint8Array(
74 - ((currentView: any): Uint8Array).buffer,
74 + (currentView as any as Uint8Array).buffer,
75 0,
76 writtenBytes,
77 ),
@@ -84,7 +84,8 @@ export function writeChunk(
84 }
85
86 let bytesToWrite = chunk;
87 - const allowableBytes = ((currentView: any): Uint8Array).length - writtenBytes;
87 + const allowableBytes =
88 + (currentView as any as Uint8Array).length - writtenBytes;
89 if (allowableBytes < bytesToWrite.byteLength) {
90 // this chunk would overflow the current view. We enqueue a full view
91 // and start a new view with the remaining chunk
@@ -94,7 +95,7 @@ export function writeChunk(
95 } else {
96 // fill up the current view and apply the remaining chunk bytes
97 // to a new view.
97 - ((currentView: any): Uint8Array).set(
98 + (currentView as any as Uint8Array).set(
99 bytesToWrite.subarray(0, allowableBytes),
100 writtenBytes,
101 );
@@ -105,7 +106,7 @@ export function writeChunk(
106 currentView = new Uint8Array(VIEW_SIZE);
107 writtenBytes = 0;
108 }
108 - ((currentView: any): Uint8Array).set(bytesToWrite, writtenBytes);
109 + (currentView as any as Uint8Array).set(bytesToWrite, writtenBytes);
110 writtenBytes += bytesToWrite.byteLength;
111 }
112
packages/react-server/src/ReactServerStreamConfigEdge.js
+5 -4
@@ -65,7 +65,7 @@ export function writeChunk(
65 if (writtenBytes > 0) {
66 destination.enqueue(
67 new Uint8Array(
68 - ((currentView: any): Uint8Array).buffer,
68 + (currentView as any as Uint8Array).buffer,
69 0,
70 writtenBytes,
71 ),
@@ -78,7 +78,8 @@ export function writeChunk(
78 }
79
80 let bytesToWrite = chunk;
81 - const allowableBytes = ((currentView: any): Uint8Array).length - writtenBytes;
81 + const allowableBytes =
82 + (currentView as any as Uint8Array).length - writtenBytes;
83 if (allowableBytes < bytesToWrite.byteLength) {
84 // this chunk would overflow the current view. We enqueue a full view
85 // and start a new view with the remaining chunk
@@ -88,7 +89,7 @@ export function writeChunk(
89 } else {
90 // fill up the current view and apply the remaining chunk bytes
91 // to a new view.
91 - ((currentView: any): Uint8Array).set(
92 + (currentView as any as Uint8Array).set(
93 bytesToWrite.subarray(0, allowableBytes),
94 writtenBytes,
95 );
@@ -99,7 +100,7 @@ export function writeChunk(
100 currentView = new Uint8Array(VIEW_SIZE);
101 writtenBytes = 0;
102 }
102 - ((currentView: any): Uint8Array).set(bytesToWrite, writtenBytes);
103 + (currentView as any as Uint8Array).set(bytesToWrite, writtenBytes);
104 writtenBytes += bytesToWrite.byteLength;
105 }
106
packages/react-server/src/ReactServerStreamConfigFB.js
+1 -1
@@ -33,7 +33,7 @@ export function scheduleWork(callback: () => void) {
33 export function flushBuffered(destination: Destination) {}
34
35 export const supportsRequestStorage = false;
36 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
36 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
37
38 export function beginWriting(destination: Destination) {}
39
packages/react-server/src/ReactServerStreamConfigNode.js
+15 -14
@@ -62,7 +62,7 @@ function writeStringChunk(destination: Destination, stringChunk: string) {
62 if (writtenBytes > 0) {
63 writeToDestination(
64 destination,
65 - ((currentView: any): Uint8Array).subarray(0, writtenBytes),
65 + (currentView as any as Uint8Array).subarray(0, writtenBytes),
66 );
67 currentView = new Uint8Array(VIEW_SIZE);
68 writtenBytes = 0;
@@ -72,9 +72,9 @@ function writeStringChunk(destination: Destination, stringChunk: string) {
72 return;
73 }
74
75 - let target: Uint8Array = (currentView: any);
75 + let target: Uint8Array = currentView as any;
76 if (writtenBytes > 0) {
77 - target = ((currentView: any): Uint8Array).subarray(writtenBytes);
77 + target = (currentView as any as Uint8Array).subarray(writtenBytes);
78 }
79 const {read, written} = textEncoder.encodeInto(stringChunk, target);
80 writtenBytes += written;
@@ -82,17 +82,17 @@ function writeStringChunk(destination: Destination, stringChunk: string) {
82 if (read < stringChunk.length) {
83 writeToDestination(
84 destination,
85 - (currentView: any).subarray(0, writtenBytes),
85 + (currentView as any).subarray(0, writtenBytes),
86 );
87 currentView = new Uint8Array(VIEW_SIZE);
88 writtenBytes = textEncoder.encodeInto(
89 stringChunk.slice(read),
90 - (currentView: any),
90 + currentView as any,
91 ).written;
92 }
93
94 if (writtenBytes === VIEW_SIZE) {
95 - writeToDestination(destination, (currentView: any));
95 + writeToDestination(destination, currentView as any);
96 currentView = new Uint8Array(VIEW_SIZE);
97 writtenBytes = 0;
98 }
@@ -112,7 +112,7 @@ function writeViewChunk(
112 if (writtenBytes > 0) {
113 writeToDestination(
114 destination,
115 - ((currentView: any): Uint8Array).subarray(0, writtenBytes),
115 + (currentView as any as Uint8Array).subarray(0, writtenBytes),
116 );
117 currentView = new Uint8Array(VIEW_SIZE);
118 writtenBytes = 0;
@@ -122,32 +122,33 @@ function writeViewChunk(
122 }
123
124 let bytesToWrite = chunk;
125 - const allowableBytes = ((currentView: any): Uint8Array).length - writtenBytes;
125 + const allowableBytes =
126 + (currentView as any as Uint8Array).length - writtenBytes;
127 if (allowableBytes < bytesToWrite.byteLength) {
128 // this chunk would overflow the current view. We enqueue a full view
129 // and start a new view with the remaining chunk
130 if (allowableBytes === 0) {
131 // the current view is already full, send it
131 - writeToDestination(destination, (currentView: any));
132 + writeToDestination(destination, currentView as any);
133 } else {
134 // fill up the current view and apply the remaining chunk bytes
135 // to a new view.
135 - ((currentView: any): Uint8Array).set(
136 + (currentView as any as Uint8Array).set(
137 bytesToWrite.subarray(0, allowableBytes),
138 writtenBytes,
139 );
140 writtenBytes += allowableBytes;
140 - writeToDestination(destination, (currentView: any));
141 + writeToDestination(destination, currentView as any);
142 bytesToWrite = bytesToWrite.subarray(allowableBytes);
143 }
144 currentView = new Uint8Array(VIEW_SIZE);
145 writtenBytes = 0;
146 }
146 - ((currentView: any): Uint8Array).set(bytesToWrite, writtenBytes);
147 + (currentView as any as Uint8Array).set(bytesToWrite, writtenBytes);
148 writtenBytes += bytesToWrite.byteLength;
149
150 if (writtenBytes === VIEW_SIZE) {
150 - writeToDestination(destination, (currentView: any));
151 + writeToDestination(destination, currentView as any);
152 currentView = new Uint8Array(VIEW_SIZE);
153 writtenBytes = 0;
154 }
@@ -160,7 +161,7 @@ export function writeChunk(
161 if (typeof chunk === 'string') {
162 writeStringChunk(destination, chunk);
163 } else {
163 - writeViewChunk(destination, ((chunk: any): PrecomputedChunk | BinaryChunk));
164 + writeViewChunk(destination, chunk as any as PrecomputedChunk | BinaryChunk);
165 }
166 }
167
packages/react-server/src/flight/ReactFlightAsyncDispatcher.js
+3 -3
@@ -20,10 +20,10 @@ function resolveCache(): Map<Function, mixed> {
20 return new Map();
21 }
22
23 -export const DefaultAsyncDispatcher: AsyncDispatcher = ({
23 +export const DefaultAsyncDispatcher: AsyncDispatcher = {
24 getCacheForType<T>(resourceType: () => T): T {
25 const cache = resolveCache();
26 - let entry: T | void = (cache.get(resourceType): any);
26 + let entry: T | void = cache.get(resourceType) as any;
27 if (entry === undefined) {
28 entry = resourceType();
29 // TODO: Warn if undefined?
@@ -38,7 +38,7 @@ export const DefaultAsyncDispatcher: AsyncDispatcher = ({
38 }
39 return null;
40 },
41 -}: any);
41 +} as any;
42
43 if (__DEV__) {
44 DefaultAsyncDispatcher.getOwner = resolveOwner;
packages/react-server/src/forks/ReactFizzConfig.custom.js
+1 -1
@@ -43,7 +43,7 @@ export const supportsClientAPIs = true;
43 export const isWorkLoopExternallyDriven =
44 $$$config.isWorkLoopExternallyDriven === true;
45 export const supportsRequestStorage = false;
46 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
46 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
47
48 export const bindToConsole = $$$config.bindToConsole;
49
packages/react-server/src/forks/ReactFizzConfig.dom-edge.js
+1 -1
@@ -17,4 +17,4 @@ export const isWorkLoopExternallyDriven = false;
17 // For now, we get this from the global scope, but this will likely move to a module.
18 export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
19 export const requestStorage: AsyncLocalStorage<Request | void> =
20 - supportsRequestStorage ? new AsyncLocalStorage() : (null: any);
20 + supportsRequestStorage ? new AsyncLocalStorage() : (null as any);
packages/react-server/src/forks/ReactFizzConfig.dom-fb.js
+1 -1
@@ -17,4 +17,4 @@ export * from 'react-client/src/ReactClientConsoleConfigBrowser';
17 export const isWorkLoopExternallyDriven = true;
18
19 export const supportsRequestStorage = false;
20 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
20 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
packages/react-server/src/forks/ReactFizzConfig.dom-legacy.js
+1 -1
@@ -14,4 +14,4 @@ export * from 'react-client/src/ReactClientConsoleConfigPlain';
14
15 export const isWorkLoopExternallyDriven = false;
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
packages/react-server/src/forks/ReactFizzConfig.dom.js
+1 -1
@@ -14,4 +14,4 @@ export * from 'react-client/src/ReactClientConsoleConfigBrowser';
14
15 export const isWorkLoopExternallyDriven = false;
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
packages/react-server/src/forks/ReactFizzConfig.markup.js
+1 -1
@@ -14,4 +14,4 @@ export * from 'react-client/src/ReactClientConsoleConfigPlain';
14
15 export const isWorkLoopExternallyDriven = false;
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
packages/react-server/src/forks/ReactFizzConfig.noop.js
+1 -1
@@ -43,7 +43,7 @@ export const supportsClientAPIs = true;
43 export const isWorkLoopExternallyDriven =
44 $$$config.isWorkLoopExternallyDriven === true;
45 export const supportsRequestStorage = false;
46 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
46 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
47
48 export const bindToConsole = $$$config.bindToConsole;
49
packages/react-server/src/forks/ReactFlightServerConfig.custom.js
+2 -2
@@ -23,11 +23,11 @@ export type HintCode = any;
23 export type HintModel<T: any> = any;
24
25 export const supportsRequestStorage = false;
26 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
26 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
27
28 export const supportsComponentStorage = false;
29 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
30 - (null: any);
30 + null as any;
31
32 export function createHints(): any {
33 return null;
packages/react-server/src/forks/ReactFlightServerConfig.dom-browser-esm.js
+2 -2
@@ -14,11 +14,11 @@ export * from 'react-server-dom-esm/src/server/ReactFlightServerConfigESMBundler
14 export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
15
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
18
19 export const supportsComponentStorage = false;
20 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
21 - (null: any);
21 + null as any;
22
23 export * from '../ReactFlightServerConfigDebugNoop';
24
packages/react-server/src/forks/ReactFlightServerConfig.dom-browser-fb.js
+2 -2
@@ -14,11 +14,11 @@ export * from 'react-flight-server-fb/src/server/ReactFlightServerConfigFBBundle
14 export * from 'react-flight-server-fb/src/server/ReactFlightServerConfigDOMFB';
15
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
18
19 export const supportsComponentStorage = false;
20 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
21 - (null: any);
21 + null as any;
22
23 export * from '../ReactFlightServerConfigDebugNoop';
24
packages/react-server/src/forks/ReactFlightServerConfig.dom-browser-parcel.js
+2 -2
@@ -14,11 +14,11 @@ export * from 'react-server-dom-parcel/src/server/ReactFlightServerConfigParcelB
14 export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
15
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
18
19 export const supportsComponentStorage = false;
20 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
21 - (null: any);
21 + null as any;
22
23 export * from '../ReactFlightServerConfigDebugNoop';
24
packages/react-server/src/forks/ReactFlightServerConfig.dom-browser-turbopack.js
+2 -2
@@ -14,11 +14,11 @@ export * from 'react-server-dom-turbopack/src/server/ReactFlightServerConfigTurb
14 export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
15
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
18
19 export const supportsComponentStorage = false;
20 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
21 - (null: any);
21 + null as any;
22
23 export * from '../ReactFlightServerConfigDebugNoop';
24
packages/react-server/src/forks/ReactFlightServerConfig.dom-browser.js
+2 -2
@@ -14,11 +14,11 @@ export * from 'react-server-dom-webpack/src/server/ReactFlightServerConfigWebpac
14 export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
15
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
18
19 export const supportsComponentStorage = false;
20 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
21 - (null: any);
21 + null as any;
22
23 export * from '../ReactFlightServerConfigDebugNoop';
24
packages/react-server/src/forks/ReactFlightServerConfig.dom-bun.js
+2 -2
@@ -14,11 +14,11 @@ export * from '../ReactFlightServerConfigBundlerCustom';
14 export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
15
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
18
19 export const supportsComponentStorage = false;
20 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
21 - (null: any);
21 + null as any;
22
23 export * from '../ReactFlightServerConfigDebugNoop';
24
packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-parcel.js
+2 -2
@@ -15,12 +15,12 @@ export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
15 // For now, we get this from the global scope, but this will likely move to a module.
16 export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
17 export const requestStorage: AsyncLocalStorage<Request | void> =
18 - supportsRequestStorage ? new AsyncLocalStorage() : (null: any);
18 + supportsRequestStorage ? new AsyncLocalStorage() : (null as any);
19
20 export const supportsComponentStorage: boolean =
21 __DEV__ && supportsRequestStorage;
22 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
23 - supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
23 + supportsComponentStorage ? new AsyncLocalStorage() : (null as any);
24
25 export * from '../ReactFlightServerConfigDebugNoop';
26
packages/react-server/src/forks/ReactFlightServerConfig.dom-edge-turbopack.js
+2 -2
@@ -15,12 +15,12 @@ export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
15 // For now, we get this from the global scope, but this will likely move to a module.
16 export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
17 export const requestStorage: AsyncLocalStorage<Request | void> =
18 - supportsRequestStorage ? new AsyncLocalStorage() : (null: any);
18 + supportsRequestStorage ? new AsyncLocalStorage() : (null as any);
19
20 export const supportsComponentStorage: boolean =
21 __DEV__ && supportsRequestStorage;
22 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
23 - supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
23 + supportsComponentStorage ? new AsyncLocalStorage() : (null as any);
24
25 export * from '../ReactFlightServerConfigDebugNoop';
26
packages/react-server/src/forks/ReactFlightServerConfig.dom-edge.js
+2 -2
@@ -16,12 +16,12 @@ export * from 'react-dom-bindings/src/server/ReactFlightServerConfigDOM';
16 // For now, we get this from the global scope, but this will likely move to a module.
17 export const supportsRequestStorage = typeof AsyncLocalStorage === 'function';
18 export const requestStorage: AsyncLocalStorage<Request | void> =
19 - supportsRequestStorage ? new AsyncLocalStorage() : (null: any);
19 + supportsRequestStorage ? new AsyncLocalStorage() : (null as any);
20
21 export const supportsComponentStorage: boolean =
22 __DEV__ && supportsRequestStorage;
23 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
24 - supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
24 + supportsComponentStorage ? new AsyncLocalStorage() : (null as any);
25
26 export * from '../ReactFlightServerConfigDebugNoop';
27
packages/react-server/src/forks/ReactFlightServerConfig.dom-legacy.js
+2 -2
@@ -23,11 +23,11 @@ export type HintCode = any;
23 export type HintModel<T: any> = any;
24
25 export const supportsRequestStorage = false;
26 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
26 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
27
28 export const supportsComponentStorage = false;
29 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
30 - (null: any);
30 + null as any;
31
32 export function createHints(): any {
33 return null;
packages/react-server/src/forks/ReactFlightServerConfig.dom-node-esm.js
+1 -1
@@ -21,7 +21,7 @@ export const requestStorage: AsyncLocalStorage<Request | void> =
21
22 export const supportsComponentStorage = __DEV__;
23 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
24 - supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
24 + supportsComponentStorage ? new AsyncLocalStorage() : (null as any);
25
26 export * from '../ReactFlightServerConfigDebugNode';
27
packages/react-server/src/forks/ReactFlightServerConfig.dom-node-fb.js
+2 -2
@@ -14,11 +14,11 @@ export * from 'react-flight-server-fb/src/server/ReactFlightServerConfigFBBundle
14 export * from 'react-flight-server-fb/src/server/ReactFlightServerConfigDOMFB';
15
16 export const supportsRequestStorage = false;
17 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
17 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
18
19 export const supportsComponentStorage = false;
20 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
21 - (null: any);
21 + null as any;
22
23 export * from '../ReactFlightServerConfigDebugNoop';
24
packages/react-server/src/forks/ReactFlightServerConfig.dom-node-parcel.js
+1 -1
@@ -21,7 +21,7 @@ export const requestStorage: AsyncLocalStorage<Request | void> =
21
22 export const supportsComponentStorage = __DEV__;
23 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
24 - supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
24 + supportsComponentStorage ? new AsyncLocalStorage() : (null as any);
25
26 export * from '../ReactFlightServerConfigDebugNode';
27
packages/react-server/src/forks/ReactFlightServerConfig.dom-node-turbopack.js
+1 -1
@@ -21,7 +21,7 @@ export const requestStorage: AsyncLocalStorage<Request | void> =
21
22 export const supportsComponentStorage = __DEV__;
23 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
24 - supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
24 + supportsComponentStorage ? new AsyncLocalStorage() : (null as any);
25
26 export * from '../ReactFlightServerConfigDebugNode';
27
packages/react-server/src/forks/ReactFlightServerConfig.dom-node-unbundled.js
+1 -1
@@ -21,7 +21,7 @@ export const requestStorage: AsyncLocalStorage<Request | void> =
21
22 export const supportsComponentStorage = __DEV__;
23 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
24 - supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
24 + supportsComponentStorage ? new AsyncLocalStorage() : (null as any);
25
26 export * from '../ReactFlightServerConfigDebugNode';
27
packages/react-server/src/forks/ReactFlightServerConfig.dom-node.js
+1 -1
@@ -21,7 +21,7 @@ export const requestStorage: AsyncLocalStorage<Request | void> =
21
22 export const supportsComponentStorage = __DEV__;
23 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
24 - supportsComponentStorage ? new AsyncLocalStorage() : (null: any);
24 + supportsComponentStorage ? new AsyncLocalStorage() : (null as any);
25
26 export * from '../ReactFlightServerConfigDebugNode';
27
packages/react-server/src/forks/ReactFlightServerConfig.markup.js
+2 -2
@@ -34,11 +34,11 @@ export function getChildFormatContext(
34 }
35
36 export const supportsRequestStorage = false;
37 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
37 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
38
39 export const supportsComponentStorage = false;
40 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
41 - (null: any);
41 + null as any;
42
43 export * from '../ReactFlightServerConfigDebugNoop';
44
packages/react-server/src/forks/ReactFlightServerConfig.noop.js
+2 -2
@@ -22,11 +22,11 @@ export type HintCode = string;
22 export type HintModel<T: HintCode> = null; // eslint-disable-line no-unused-vars
23
24 export const supportsRequestStorage = false;
25 -export const requestStorage: AsyncLocalStorage<Request | void> = (null: any);
25 +export const requestStorage: AsyncLocalStorage<Request | void> = null as any;
26
27 export const supportsComponentStorage = false;
28 export const componentStorage: AsyncLocalStorage<ReactComponentInfo | void> =
29 - (null: any);
29 + null as any;
30
31 export function createHints(): Hints {
32 return null;
packages/react-suspense-test-utils/src/ReactSuspenseTestUtils.js
+1 -1
@@ -14,7 +14,7 @@ export function waitForSuspense<T>(fn: () => T): Promise<T> {
14 const cache: Map<Function, mixed> = new Map();
15 const testDispatcher: AsyncDispatcher = {
16 getCacheForType<R>(resourceType: () => R): R {
17 - let entry: R | void = (cache.get(resourceType): any);
17 + let entry: R | void = cache.get(resourceType) as any;
18 if (entry === undefined) {
19 entry = resourceType();
20 // TODO: Warn if undefined?
packages/react-test-renderer/src/ReactFiberConfigTestHost.js
+2 -2
@@ -612,8 +612,8 @@ export function getSuspendedCommitReason(
612 export const NotPendingTransition: TransitionStatus = null;
613 export const HostTransitionContext: ReactContext<TransitionStatus> = {
614 $$typeof: REACT_CONTEXT_TYPE,
615 - Provider: (null: any),
616 - Consumer: (null: any),
615 + Provider: null as any,
616 + Consumer: null as any,
617 _currentValue: NotPendingTransition,
618 _currentValue2: NotPendingTransition,
619 _threadCount: 0,
packages/react-test-renderer/src/ReactTestRenderer.js
+25 -29
@@ -288,10 +288,10 @@ function getChildren(parent: Fiber) {
288 if (node.return === startingNode) {
289 break outer;
290 }
291 - node = (node.return: any);
291 + node = node.return as any;
292 }
293 - (node.sibling: any).return = node.return;
294 - node = (node.sibling: any);
293 + (node.sibling as any).return = node.return;
294 + node = node.sibling as any;
295 }
296 return children;
297 }
@@ -509,7 +509,7 @@ function create(
509 }
510 }
511 let container: Container = {
512 - children: ([]: Array<Instance | TextInstance>),
512 + children: [] as Array<Instance | TextInstance>,
513 createNodeMock,
514 tag: 'CONTAINER',
515 };
@@ -605,31 +605,27 @@ function create(
605 unstable_flushSync: flushSyncFromReconciler,
606 };
607
608 - Object.defineProperty(
609 - entry,
610 - 'root',
611 - ({
612 - configurable: true,
613 - enumerable: true,
614 - get: function () {
615 - if (root === null) {
616 - throw new Error("Can't access .root on unmounted test renderer");
617 - }
618 - const children = getChildren(root.current);
619 - if (children.length === 0) {
620 - throw new Error("Can't access .root on unmounted test renderer");
621 - } else if (children.length === 1) {
622 - // Normally, we skip the root and just give you the child.
623 - return children[0];
624 - } else {
625 - // However, we give you the root if there's more than one root child.
626 - // We could make this the behavior for all cases but it would be a breaking change.
627 - // $FlowFixMe[incompatible-use] found when upgrading Flow
628 - return wrapFiber(root.current);
629 - }
630 - },
631 - }: Object),
632 - );
608 + Object.defineProperty(entry, 'root', {
609 + configurable: true,
610 + enumerable: true,
611 + get: function () {
612 + if (root === null) {
613 + throw new Error("Can't access .root on unmounted test renderer");
614 + }
615 + const children = getChildren(root.current);
616 + if (children.length === 0) {
617 + throw new Error("Can't access .root on unmounted test renderer");
618 + } else if (children.length === 1) {
619 + // Normally, we skip the root and just give you the child.
620 + return children[0];
621 + } else {
622 + // However, we give you the root if there's more than one root child.
623 + // We could make this the behavior for all cases but it would be a breaking change.
624 + // $FlowFixMe[incompatible-use] found when upgrading Flow
625 + return wrapFiber(root.current);
626 + }
627 + },
628 + } as Object);
629
630 return entry;
631 }
packages/react/src/ReactAct.js
+2 -2
@@ -114,7 +114,7 @@ export function act<T>(callback: () => T | Thenable<T>): Thenable<T> {
114 // If `act` were implemented as an async function, this whole block could
115 // be a single `await` call. That's really the only difference between
116 // this branch and the next one.
117 - const thenable = ((result: any): Thenable<T>);
117 + const thenable = result as any as Thenable<T>;
118
119 // Warn if the an `act` call with an async scope is not awaited. In a
120 // future release, consider making this an error.
@@ -178,7 +178,7 @@ export function act<T>(callback: () => T | Thenable<T>): Thenable<T> {
178 },
179 };
180 } else {
181 - const returnValue: T = (result: any);
181 + const returnValue: T = result as any;
182 // The callback is not an async function. Exit the current
183 // scope immediately.
184 popActScope(prevActQueue, prevActScopeDepth);
packages/react/src/ReactCacheImpl.js
+2 -2
@@ -114,13 +114,13 @@ export function cache<A: Iterable<mixed>, T>(fn: (...A) => T): (...A) => T {
114 try {
115 // $FlowFixMe[incompatible-type]: We don't want to use rest arguments since we transpile the code.
116 const result = fn.apply(null, arguments);
117 - const terminatedNode: TerminatedCacheNode<T> = (cacheNode: any);
117 + const terminatedNode: TerminatedCacheNode<T> = cacheNode as any;
118 terminatedNode.s = TERMINATED;
119 terminatedNode.v = result;
120 return result;
121 } catch (error) {
122 // We store the first error that's thrown and rethrow it.
123 - const erroredNode: ErroredCacheNode<T> = (cacheNode: any);
123 + const erroredNode: ErroredCacheNode<T> = cacheNode as any;
124 erroredNode.s = ERRORED;
125 erroredNode.v = error;
126 throw error;
packages/react/src/ReactChildren.js
+14 -14
@@ -115,19 +115,19 @@ function resolveThenable<T>(thenable: Thenable<T>): T {
115
116 // TODO: Detect infinite ping loops caused by uncached promises.
117
118 - const pendingThenable: PendingThenable<T> = (thenable: any);
118 + const pendingThenable: PendingThenable<T> = thenable as any;
119 pendingThenable.status = 'pending';
120 pendingThenable.then(
121 fulfilledValue => {
122 if (thenable.status === 'pending') {
123 - const fulfilledThenable: FulfilledThenable<T> = (thenable: any);
123 + const fulfilledThenable: FulfilledThenable<T> = thenable as any;
124 fulfilledThenable.status = 'fulfilled';
125 fulfilledThenable.value = fulfilledValue;
126 }
127 },
128 (error: mixed) => {
129 if (thenable.status === 'pending') {
130 - const rejectedThenable: RejectedThenable<T> = (thenable: any);
130 + const rejectedThenable: RejectedThenable<T> = thenable as any;
131 rejectedThenable.status = 'rejected';
132 rejectedThenable.reason = error;
133 }
@@ -136,13 +136,13 @@ function resolveThenable<T>(thenable: Thenable<T>): T {
136 }
137
138 // Check one more time in case the thenable resolved synchronously.
139 - switch ((thenable: Thenable<T>).status) {
139 + switch ((thenable as Thenable<T>).status) {
140 case 'fulfilled': {
141 - const fulfilledThenable: FulfilledThenable<T> = (thenable: any);
141 + const fulfilledThenable: FulfilledThenable<T> = thenable as any;
142 return fulfilledThenable.value;
143 }
144 case 'rejected': {
145 - const rejectedThenable: RejectedThenable<T> = (thenable: any);
145 + const rejectedThenable: RejectedThenable<T> = thenable as any;
146 const rejectedError = rejectedThenable.reason;
147 throw rejectedError;
148 }
@@ -178,14 +178,14 @@ function mapIntoArray(
178 invokeCallback = true;
179 break;
180 case 'object':
181 - switch ((children: any).$$typeof) {
181 + switch ((children as any).$$typeof) {
182 case REACT_ELEMENT_TYPE:
183 case REACT_PORTAL_TYPE:
184 invokeCallback = true;
185 break;
186 case REACT_LAZY_TYPE:
187 - const payload = (children: any)._payload;
188 - const init = (children: any)._init;
187 + const payload = (children as any)._payload;
188 + const init = (children as any)._init;
189 return mapIntoArray(
190 init(payload),
191 array,
@@ -287,7 +287,7 @@ function mapIntoArray(
287 if (typeof iteratorFn === 'function') {
288 const iterableChildren: Iterable<React$Node> & {
289 entries: any,
290 - } = (children: any);
290 + } = children as any;
291
292 if (__DEV__) {
293 // Warn about using Maps as children
@@ -318,9 +318,9 @@ function mapIntoArray(
318 );
319 }
320 } else if (type === 'object') {
321 - if (typeof (children: any).then === 'function') {
321 + if (typeof (children as any).then === 'function') {
322 return mapIntoArray(
323 - resolveThenable((children: any)),
323 + resolveThenable(children as any),
324 array,
325 escapedPrefix,
326 nameSoFar,
@@ -329,13 +329,13 @@ function mapIntoArray(
329 }
330
331 // eslint-disable-next-line react-internal/safe-string-coercion
332 - const childrenString = String((children: any));
332 + const childrenString = String(children as any);
333
334 throw new Error(
335 `Objects are not valid as a React child (found: ${
336 childrenString === '[object Object]'
337 ? 'object with keys {' +
338 - Object.keys((children: any)).join(', ') +
338 + Object.keys(children as any).join(', ') +
339 '}'
340 : childrenString
341 }). ` +
packages/react/src/ReactContext.js
+2 -2
@@ -28,8 +28,8 @@ export function createContext<T>(defaultValue: T): ReactContext<T> {
28 // supports within in a single renderer. Such as parallel server rendering.
29 _threadCount: 0,
30 // These are circular
31 - Provider: (null: any),
32 - Consumer: (null: any),
31 + Provider: null as any,
32 + Consumer: null as any,
33 };
34
35 context.Provider = context;
packages/react/src/ReactHooks.js
+1 -1
@@ -38,7 +38,7 @@ function resolveDispatcher() {
38 // Will result in a null access error if accessed outside render phase. We
39 // intentionally don't throw our own error because this is in a hot path.
40 // Also helps ensure this is inlined.
41 - return ((dispatcher: any): Dispatcher);
41 + return dispatcher as any as Dispatcher;
42 }
43
44 export function getCacheForType<T>(resourceType: () => T): T {
packages/react/src/ReactLazy.js
+9 -9
@@ -69,8 +69,8 @@ export type LazyComponent<T, P> = {
69
70 function lazyInitializer<T>(payload: Payload<T>): T {
71 if (payload._status === Uninitialized) {
72 - let resolveDebugValue: (void | T) => void = (null: any);
73 - let rejectDebugValue: mixed => void = (null: any);
72 + let resolveDebugValue: (void | T) => void = null as any;
73 + let rejectDebugValue: mixed => void = null as any;
74 if (__DEV__ && enableAsyncDebugInfo) {
75 const ioInfo = payload._ioInfo;
76 if (ioInfo != null) {
@@ -95,11 +95,11 @@ function lazyInitializer<T>(payload: Payload<T>): T {
95 thenable.then(
96 moduleObject => {
97 if (
98 - (payload: Payload<T>)._status === Pending ||
98 + (payload as Payload<T>)._status === Pending ||
99 payload._status === Uninitialized
100 ) {
101 // Transition to the next state.
102 - const resolved: ResolvedPayload<T> = (payload: any);
102 + const resolved: ResolvedPayload<T> = payload as any;
103 resolved._status = Resolved;
104 resolved._result = moduleObject;
105 if (__DEV__ && enableAsyncDebugInfo) {
@@ -125,7 +125,7 @@ function lazyInitializer<T>(payload: Payload<T>): T {
125 // impl or make suspendedThenable be able to be a lazy itself
126 if (thenable.status === undefined) {
127 const fulfilledThenable: FulfilledThenable<{default: T, ...}> =
128 - (thenable: any);
128 + thenable as any;
129 fulfilledThenable.status = 'fulfilled';
130 fulfilledThenable.value = moduleObject;
131 }
@@ -133,11 +133,11 @@ function lazyInitializer<T>(payload: Payload<T>): T {
133 },
134 error => {
135 if (
136 - (payload: Payload<T>)._status === Pending ||
136 + (payload as Payload<T>)._status === Pending ||
137 payload._status === Uninitialized
138 ) {
139 // Transition to the next state.
140 - const rejected: RejectedPayload = (payload: any);
140 + const rejected: RejectedPayload = payload as any;
141 rejected._status = Rejected;
142 rejected._result = error;
143 if (__DEV__ && enableAsyncDebugInfo) {
@@ -163,7 +163,7 @@ function lazyInitializer<T>(payload: Payload<T>): T {
163 // impl or make suspendedThenable be able to be a lazy itself
164 if (thenable.status === undefined) {
165 const rejectedThenable: RejectedThenable<{default: T, ...}> =
166 - (thenable: any);
166 + thenable as any;
167 rejectedThenable.status = 'rejected';
168 rejectedThenable.reason = error;
169 }
@@ -183,7 +183,7 @@ function lazyInitializer<T>(payload: Payload<T>): T {
183 if (payload._status === Uninitialized) {
184 // In case, we're still uninitialized, then we're waiting for the thenable
185 // to resolve. Set it as pending in the meantime.
186 - const pending: PendingPayload = (payload: any);
186 + const pending: PendingPayload = payload as any;
187 pending._status = Pending;
188 pending._result = thenable;
189 }
packages/react/src/ReactSharedInternalsClient.js
+3 -3
@@ -57,12 +57,12 @@ export type SharedStateClient = {
57
58 export type RendererTask = boolean => RendererTask | null;
59
60 -const ReactSharedInternals: SharedStateClient = ({
60 +const ReactSharedInternals: SharedStateClient = {
61 H: null,
62 A: null,
63 T: null,
64 S: null,
65 -}: any);
65 +} as any;
66 if (enableGestureTransition) {
67 ReactSharedInternals.G = null;
68 }
@@ -75,7 +75,7 @@ if (__DEV__) {
75 ReactSharedInternals.didUsePromise = false;
76 ReactSharedInternals.thrownErrors = [];
77 // Stack implementation injected by the current renderer.
78 - ReactSharedInternals.getCurrentStack = (null: null | (() => string));
78 + ReactSharedInternals.getCurrentStack = null as null | (() => string);
79 ReactSharedInternals.recentlyCreatedOwnerStacks = 0;
80 }
81
packages/react/src/ReactSharedInternalsServer.js
+3 -3
@@ -46,10 +46,10 @@ export type SharedStateServer = {
46
47 export type RendererTask = boolean => RendererTask | null;
48
49 -const ReactSharedInternals: SharedStateServer = ({
49 +const ReactSharedInternals: SharedStateServer = {
50 H: null,
51 A: null,
52 -}: any);
52 +} as any;
53
54 if (enableTaint) {
55 ReactSharedInternals.TaintRegistryObjects = TaintRegistryObjects;
@@ -61,7 +61,7 @@ if (enableTaint) {
61
62 if (__DEV__) {
63 // Stack implementation injected by the current renderer.
64 - ReactSharedInternals.getCurrentStack = (null: null | (() => string));
64 + ReactSharedInternals.getCurrentStack = null as null | (() => string);
65 ReactSharedInternals.recentlyCreatedOwnerStacks = 0;
66 }
67
packages/react/src/ReactStartTransition.js
+2 -2
@@ -47,7 +47,7 @@ export function startTransition(
47 options?: StartTransitionOptions,
48 ): void {
49 const prevTransition = ReactSharedInternals.T;
50 - const currentTransition: Transition = ({}: any);
50 + const currentTransition: Transition = {} as any;
51 if (enableViewTransition) {
52 currentTransition.types =
53 prevTransition !== null
@@ -137,7 +137,7 @@ export function startGestureTransition(
137 );
138 }
139 const prevTransition = ReactSharedInternals.T;
140 - const currentTransition: Transition = ({}: any);
140 + const currentTransition: Transition = {} as any;
141 if (enableViewTransition) {
142 currentTransition.types = null;
143 }
packages/scheduler/src/forks/Scheduler.js
+2 -2
@@ -447,7 +447,7 @@ function unstable_getCurrentPriorityLevel(): PriorityLevel {
447 }
448
449 let isMessageLoopRunning = false;
450 -let taskTimeoutID: TimeoutID = (-1: any);
450 +let taskTimeoutID: TimeoutID = -1 as any;
451
452 // Scheduler periodically yields in case there is other work on the main
453 // thread, like user events. By default, it yields multiple times per frame.
@@ -580,7 +580,7 @@ function requestHostTimeout(
580 function cancelHostTimeout() {
581 // $FlowFixMe[not-a-function] nullable value
582 localClearTimeout(taskTimeoutID);
583 - taskTimeoutID = ((-1: any): TimeoutID);
583 + taskTimeoutID = -1 as any as TimeoutID;
584 }
585
586 export {
packages/scheduler/src/forks/SchedulerNative.js
+1 -1
@@ -107,4 +107,4 @@ function throwNotImplemented() {
107
108 // Flow magic to verify the exports of this file match the original version.
109 export type {Callback, Task};
110 -((((null: any): SchedulerExportsType): SchedulerNativeExportsType): SchedulerExportsType);
110 +null as any as SchedulerExportsType as SchedulerNativeExportsType as SchedulerExportsType;
packages/scheduler/src/forks/SchedulerPostTask.js
+1 -1
@@ -128,7 +128,7 @@ function runTask<T>(
128 const result = callback(didTimeout_DEPRECATED);
129 if (typeof result === 'function') {
130 // Assume this is a continuation
131 - const continuation: SchedulerCallback<T> = (result: any);
131 + const continuation: SchedulerCallback<T> = result as any;
132 const continuationOptions = {
133 signal: node._controller.signal,
134 };
packages/shared/CheckStringCoercion.js
+3 -3
@@ -23,8 +23,8 @@ function typeName(value: mixed): string {
23 // toStringTag is needed for namespaced types like Temporal.Instant
24 const hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
25 const type =
26 - (hasToStringTag && (value: any)[Symbol.toStringTag]) ||
27 - (value: any).constructor.name ||
26 + (hasToStringTag && (value as any)[Symbol.toStringTag]) ||
27 + (value as any).constructor.name ||
28 'Object';
29 // $FlowFixMe[incompatible-type]
30 return type;
@@ -68,7 +68,7 @@ function testStringCoercion(value: mixed) {
68 // ancestor components where the exception happened.
69 //
70 // eslint-disable-next-line react-internal/safe-string-coercion
71 - return '' + (value: any);
71 + return '' + (value as any);
72 }
73
74 export function checkAttributeStringCoercion(
packages/shared/DefaultPrepareStackTrace.js
+1 -1
@@ -9,4 +9,4 @@
9
10 // This is forked in server builds where the default stack frame may be source mapped.
11
12 -export default ((undefined: any): (Error, CallSite[]) => string);
12 +export default undefined as any as (Error, Array<CallSite>) => string;
packages/shared/ReactPerformanceTrackProperties.js
+1 -1
@@ -166,7 +166,7 @@ export function addValueToProperties(
166 const objectToString = Object.prototype.toString.call(value);
167 let objectName = objectToString.slice(8, objectToString.length - 1);
168 if (objectName === 'Array') {
169 - const array: Array<any> = (value: any);
169 + const array: Array<any> = value as any;
170 const didTruncate = array.length > OBJECT_WIDTH_LIMIT;
171 const kind = getArrayKind(array);
172 if (kind === PRIMITIVE_ARRAY || kind === EMPTY_ARRAY) {
packages/shared/ReactSerializationErrors.js
+3 -3
@@ -122,10 +122,10 @@ export function describeValueForErrorMessage(value: mixed): string {
122 return name;
123 }
124 case 'function': {
125 - if ((value: any).$$typeof === CLIENT_REFERENCE_TAG) {
125 + if ((value as any).$$typeof === CLIENT_REFERENCE_TAG) {
126 return describeClientReference(value);
127 }
128 - const name = (value: any).displayName || value.name;
128 + const name = (value as any).displayName || value.name;
129 return name ? 'function ' + name : 'function';
130 }
131 default:
@@ -155,7 +155,7 @@ function describeElementType(type: any): string {
155 case REACT_MEMO_TYPE:
156 return describeElementType(type.type);
157 case REACT_LAZY_TYPE: {
158 - const lazyComponent: LazyComponent<any, any> = (type: any);
158 + const lazyComponent: LazyComponent<any, any> = type as any;
159 const payload = lazyComponent._payload;
160 const init = lazyComponent._init;
161 try {
packages/shared/ReactSymbols.js
+2 -2
@@ -64,9 +64,9 @@ export function getIteratorFn(maybeIterable: ?any): ?() => ?Iterator<any> {
64
65 export const ASYNC_ITERATOR = Symbol.asyncIterator;
66
67 -export const REACT_OPTIMISTIC_KEY: ReactOptimisticKey = (Symbol.for(
67 +export const REACT_OPTIMISTIC_KEY: ReactOptimisticKey = Symbol.for(
68 'react.optimistic_key',
69 -): any);
69 +) as any;
70
71 // This is actually a symbol but Flow doesn't support comparison of symbols to refine.
72 // We use a boolean since in our code we often expect string (key) or number (index),
packages/shared/forks/ReactFeatureFlags.native-fb.js
+2 -2
@@ -14,7 +14,7 @@ import typeof * as DynamicExportsType from './ReactFeatureFlags.native-fb-dynami
14 // Re-export dynamic flags from the internal module.
15 // Intentionally using * because this import is compiled to a `require` call.
16 import * as dynamicFlagsUntyped from 'ReactNativeInternalFeatureFlags';
17 -const dynamicFlags: DynamicExportsType = (dynamicFlagsUntyped: any);
17 +const dynamicFlags: DynamicExportsType = dynamicFlagsUntyped as any;
18
19 // We destructure each value before re-exporting to avoid a dynamic look-up on
20 // the exports object every time a flag is read.
@@ -95,4 +95,4 @@ export const eprh_enableExhaustiveEffectDependenciesCompilerLint:
95 | 'missing-only' = 'off';
96
97 // Flow magic to verify the exports of this file match the original version.
98 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
98 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/shared/forks/ReactFeatureFlags.native-oss.js
+1 -1
@@ -95,4 +95,4 @@ export const eprh_enableExhaustiveEffectDependenciesCompilerLint:
95 | 'missing-only' = 'off';
96
97 // Flow magic to verify the exports of this file match the original version.
98 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
98 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+1 -1
@@ -104,4 +104,4 @@ export const eprh_enableExhaustiveEffectDependenciesCompilerLint:
104 | 'missing-only' = 'off';
105
106 // Flow magic to verify the exports of this file match the original version.
107 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
107 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
+1 -1
@@ -81,4 +81,4 @@ export const eprh_enableExhaustiveEffectDependenciesCompilerLint:
81 | 'missing-only' = 'off';
82
83 // Flow magic to verify the exports of this file match the original version.
84 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
84 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1 -1
@@ -96,4 +96,4 @@ export const eprh_enableExhaustiveEffectDependenciesCompilerLint:
96 | 'missing-only' = 'off';
97
98 // Flow magic to verify the exports of this file match the original version.
99 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
99 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/shared/forks/ReactFeatureFlags.www.js
+1 -1
@@ -127,4 +127,4 @@ export const eprh_enableExhaustiveEffectDependenciesCompilerLint:
127 | 'missing-only' = 'off';
128
129 // Flow magic to verify the exports of this file match the original version.
130 -((((null: any): ExportsType): FeatureFlagsType): ExportsType);
130 +null as any as ExportsType as FeatureFlagsType as ExportsType;
packages/shared/getComponentNameFromType.js
+8 -8
@@ -38,7 +38,7 @@ function getWrappedName(
38 innerType: any,
39 wrapperName: string,
40 ): string {
41 - const displayName = (outerType: any).displayName;
41 + const displayName = (outerType as any).displayName;
42 if (displayName) {
43 return displayName;
44 }
@@ -60,11 +60,11 @@ export default function getComponentNameFromType(type: mixed): string | null {
60 return null;
61 }
62 if (typeof type === 'function') {
63 - if ((type: any).$$typeof === REACT_CLIENT_REFERENCE) {
63 + if ((type as any).$$typeof === REACT_CLIENT_REFERENCE) {
64 // TODO: Create a convention for naming client references with debug info.
65 return null;
66 }
67 - return (type: any).displayName || type.name || null;
67 + return (type as any).displayName || type.name || null;
68 }
69 if (typeof type === 'string') {
70 return type;
@@ -94,7 +94,7 @@ export default function getComponentNameFromType(type: mixed): string | null {
94 }
95 if (typeof type === 'object') {
96 if (__DEV__) {
97 - if (typeof (type: any).tag === 'number') {
97 + if (typeof (type as any).tag === 'number') {
98 console.error(
99 'Received an unexpected object in getComponentNameFromType(). ' +
100 'This is likely a bug in React. Please file an issue.',
@@ -105,21 +105,21 @@ export default function getComponentNameFromType(type: mixed): string | null {
105 case REACT_PORTAL_TYPE:
106 return 'Portal';
107 case REACT_CONTEXT_TYPE:
108 - const context: ReactContext<any> = (type: any);
108 + const context: ReactContext<any> = type as any;
109 return getContextName(context);
110 case REACT_CONSUMER_TYPE:
111 - const consumer: ReactConsumerType<any> = (type: any);
111 + const consumer: ReactConsumerType<any> = type as any;
112 return getContextName(consumer._context) + '.Consumer';
113 case REACT_FORWARD_REF_TYPE:
114 return getWrappedName(type, type.render, 'ForwardRef');
115 case REACT_MEMO_TYPE:
116 - const outerName = (type: any).displayName || null;
116 + const outerName = (type as any).displayName || null;
117 if (outerName !== null) {
118 return outerName;
119 }
120 return getComponentNameFromType(type.type) || 'Memo';
121 case REACT_LAZY_TYPE: {
122 - const lazyComponent: LazyComponent<any, any> = (type: any);
122 + const lazyComponent: LazyComponent<any, any> = type as any;
123 const payload = lazyComponent._payload;
124 const init = lazyComponent._init;
125 try {
packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js
+2 -2
@@ -77,8 +77,8 @@ export function useSyncExternalStoreWithSelector<Snapshot, Selection>(
77 }
78
79 // We may be able to reuse the previous invocation's result.
80 - const prevSnapshot: Snapshot = (memoizedSnapshot: any);
81 - const prevSelection: Selection = (memoizedSelection: any);
80 + const prevSnapshot: Snapshot = memoizedSnapshot as any;
81 + const prevSelection: Selection = memoizedSelection as any;
82
83 if (is(prevSnapshot, nextSnapshot)) {
84 // The snapshot is the same as last time. Reuse the previous selection.
scripts/flags/flags.js
+12 -3
@@ -12,7 +12,10 @@ const Module = require('module');
12 const path = require('path');
13 const fs = require('fs');
14 babel({
15 - plugins: ['@babel/plugin-transform-modules-commonjs'],
15 + plugins: [
16 + 'babel-plugin-syntax-hermes-parser',
17 + '@babel/plugin-transform-modules-commonjs',
18 + ],
19 });
20
21 const yargs = require('yargs');
@@ -90,7 +93,10 @@ function getReactFeatureFlagsMajor() {
93 'const __NEXT_MAJOR__ = "next";'
94 ),
95 {
93 - plugins: ['@babel/plugin-transform-modules-commonjs'],
96 + plugins: [
97 + 'babel-plugin-syntax-hermes-parser',
98 + '@babel/plugin-transform-modules-commonjs',
99 + ],
100 }
101 ).code;
102
@@ -125,7 +131,10 @@ function getReactNativeFeatureFlagsMajor() {
131 'const __TODO_NEXT_RN_MAJOR__ = "next-todo";'
132 ),
133 {
128 - plugins: ['@babel/plugin-transform-modules-commonjs'],
134 + plugins: [
135 + 'babel-plugin-syntax-hermes-parser',
136 + '@babel/plugin-transform-modules-commonjs',
137 + ],
138 }
139 ).code;
140
scripts/flow/environment.js
+14 -26
@@ -197,56 +197,44 @@ declare module 'busboy' {
197 addListener<Event: $Keys<BusboyEvents>>(
198 event: Event,
199 listener: BusboyEvents[Event],
200 - ): Busboy;
201 - addListener(
202 - event: string | symbol,
203 - listener: (...args: any[]) => void,
204 - ): Busboy;
200 + ): this;
201 + addListener(event: string, listener: Function): this;
202
203 on<Event: $Keys<BusboyEvents>>(
204 event: Event,
205 listener: BusboyEvents[Event],
209 - ): Busboy;
210 - on(event: string | symbol, listener: (...args: any[]) => void): Busboy;
206 + ): this;
207 + on(event: string, listener: Function): this;
208
209 once<Event: $Keys<BusboyEvents>>(
210 event: Event,
211 listener: BusboyEvents[Event],
215 - ): Busboy;
216 - once(event: string | symbol, listener: (...args: any[]) => void): Busboy;
212 + ): this;
213 + once(event: string, listener: Function): this;
214
215 removeListener<Event: $Keys<BusboyEvents>>(
216 event: Event,
217 listener: BusboyEvents[Event],
221 - ): Busboy;
222 - removeListener(
223 - event: string | symbol,
224 - listener: (...args: any[]) => void,
225 - ): Busboy;
218 + ): this;
219 + removeListener(event: string, listener: Function): this;
220
221 off<Event: $Keys<BusboyEvents>>(
222 event: Event,
223 listener: BusboyEvents[Event],
230 - ): Busboy;
231 - off(event: string | symbol, listener: (...args: any[]) => void): Busboy;
224 + ): this;
225 + off(event: string, listener: Function): this;
226
227 prependListener<Event: $Keys<BusboyEvents>>(
228 event: Event,
229 listener: BusboyEvents[Event],
236 - ): Busboy;
237 - prependListener(
238 - event: string | symbol,
239 - listener: (...args: any[]) => void,
240 - ): Busboy;
230 + ): this;
231 + prependListener(event: string, listener: Function): this;
232
233 prependOnceListener<Event: $Keys<BusboyEvents>>(
234 event: Event,
235 listener: BusboyEvents[Event],
245 - ): Busboy;
246 - prependOnceListener(
247 - event: string | symbol,
248 - listener: (...args: any[]) => void,
249 - ): Busboy;
236 + ): this;
237 + prependOnceListener(event: string, listener: Function): this;
238 }
239 }
240
yarn.lock
+18 -18
@@ -9247,17 +9247,17 @@ flatted@^3.2.9:
9247 resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a"
9248 integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==
9249
9250 -flow-bin@^0.307.1:
9251 - version "0.307.1"
9252 - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.307.1.tgz#6ca6ec271a67b8fc23ab6194c26f143d1ddb6a9a"
9253 - integrity sha512-0AglecFYaFu5ooF1IJmm4SBUZO7sopMU0jTr/Bburm/XxkJUtql+MDpwqKBFe1DTd2I/3kBzqOIFgwsZ8gS7tw==
9250 +flow-bin@^0.317.0:
9251 + version "0.317.0"
9252 + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.317.0.tgz#91f640a26a61c984cf8197d083d0bbfd144fb3be"
9253 + integrity sha512-3BoVN4+oqRPKNnJ6LTOLMRmJGrB0iW1fkVJ1Pu6E3lMH0F2JwN53I83IqLdrvg+5cpgQkeATmZRL/zHvSNAMiA==
9254
9255 -flow-remove-types@^2.307.1:
9256 - version "2.307.1"
9257 - resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.307.1.tgz#d5a011d47aefdfdbccbd9d8ef3b84a1fd39160cd"
9258 - integrity sha512-PdOUe0ijQQYN8aKADulTCLNL7l0Rdkmodo7/aXTr97m18uUTrGDxCAhE0kYx6JiA0EG9X/QmJUbzdoUcgNGvag==
9255 +flow-remove-types@^2.317.0:
9256 + version "2.317.0"
9257 + resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.317.0.tgz#5ad5e628ed59770f54888995eb7b7d866bf32550"
9258 + integrity sha512-XWjTvwcW2atcCT5vJSDMjq7J0GhIhHLHjuhkb3zotwjaS0/D2XlYNXb52wPluJQmqo6gNzUUqcpBnXycI1iUtw==
9259 dependencies:
9260 - hermes-parser "0.34.0"
9260 + hermes-parser "0.36.1"
9261 pirates "^3.0.2"
9262 vlq "^0.2.1"
9263
@@ -10144,10 +10144,10 @@ hermes-estree@0.32.0:
10144 resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.32.0.tgz#bb7da6613ab8e67e334a1854ea1e209f487d307b"
10145 integrity sha512-KWn3BqnlDOl97Xe1Yviur6NbgIZ+IP+UVSpshlZWkq+EtoHg6/cwiDj/osP9PCEgFE15KBm1O55JRwbMEm5ejQ==
10146
10147 -hermes-estree@0.34.0:
10148 - version "0.34.0"
10149 - resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.34.0.tgz#a6e1aa55d0ef06136158991869b97166ce62d328"
10150 - integrity sha512-6qLylexjmuKa/YYhMiNn/3VejBsdzwmYUGmNpc693/pJzymmbufhkRW/2K6GqFgu0ApRWoqF0NbM6u82jFcOXA==
10147 +hermes-estree@0.36.1:
10148 + version "0.36.1"
10149 + resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.36.1.tgz#71368d9e78238728e11ef1f458a8921d0564a572"
10150 + integrity sha512-guv1nQ6IJ7S83NRFPWc3SA7IBZrdNC9kapwOq6uXvF4wP+sDCgjzQbKPCoyYmoyZRzztF/n/c36l/rccCZSiCw==
10151
10152 hermes-parser@0.32.0, hermes-parser@^0.32.0:
10153 version "0.32.0"
@@ -10156,12 +10156,12 @@ hermes-parser@0.32.0, hermes-parser@^0.32.0:
10156 dependencies:
10157 hermes-estree "0.32.0"
10158
10159 -hermes-parser@0.34.0:
10160 - version "0.34.0"
10161 - resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.34.0.tgz#f6050c7b1a5e978af551be9faf19bc7d7c050a82"
10162 - integrity sha512-tcgan5UNZvu3WwmR3jDAlmwEAR2CMv8cwQVMe5j0NrLQkstf0l3ULbYPuTZWbXxbPa0PyZPiq5LYEcFVmhM9LQ==
10159 +hermes-parser@0.36.1:
10160 + version "0.36.1"
10161 + resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.36.1.tgz#f619b9f99bf34e80fb6f7024b1c62944d2beb14a"
10162 + integrity sha512-GApNk4zLHi2UWoWZZkx7LNCOSzLSc5lB55pZ/PhK7ycFeg7u5LcF88p/WbpIi1XUDtE0MpHE3uRR3u3KB7TjSQ==
10163 dependencies:
10164 - hermes-estree "0.34.0"
10164 + hermes-estree "0.36.1"
10165
10166 hermes-parser@^0.25.1:
10167 version "0.25.1"