Skip to content

Commit 82bffce

Browse files
SamChou19815meta-codesync[bot]
authored andcommitted
Cleanup legacy flow types in react-native (facebook#56300)
Summary: Pull Request resolved: facebook#56300 Changelog: [Internal] Reviewed By: marcoww6 Differential Revision: D99004126 fbshipit-source-id: dfedc13c867cb768777e2ba65256a2c40ffb1d08
1 parent 8e202de commit 82bffce

File tree

44 files changed

+106
-105
lines changed

Some content is hidden

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

44 files changed

+106
-105
lines changed

jest.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = {
4343
'<rootDir>/packages/react-native/Libraries/Renderer',
4444
'<rootDir>/packages/react-native/sdks/hermes/',
4545
...PODS_LOCATIONS,
46-
] /*:: as $ReadOnlyArray<string> */,
46+
] /*:: as ReadonlyArray<string> */,
4747
transformIgnorePatterns: ['node_modules/(?!@react-native/)'],
4848
haste: {
4949
defaultPlatform: 'ios',
@@ -52,12 +52,12 @@ module.exports = {
5252
moduleFileExtensions: [
5353
'fb.js',
5454
...defaults.moduleFileExtensions,
55-
] /*:: as $ReadOnlyArray<string> */,
55+
] /*:: as ReadonlyArray<string> */,
5656
modulePathIgnorePatterns: [
5757
'scripts/.*/__fixtures__/',
5858
'<rootDir>/packages/react-native/sdks/hermes/',
5959
...PODS_LOCATIONS,
60-
] /*:: as $ReadOnlyArray<string> */,
60+
] /*:: as ReadonlyArray<string> */,
6161
unmockedModulePathPatterns: [
6262
'node_modules/react/',
6363
'packages/react-native/Libraries/Renderer',

packages/dev-middleware/src/__tests__/InspectorProxyCdpTransport-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,9 @@ describe.each(['HTTP', 'HTTPS'])(
522522

523523
// Collect all connect events
524524
const connectEvents: Array<
525-
$ReadOnly<{
525+
Readonly<{
526526
event: string,
527-
payload: $ReadOnly<{pageId: string, sessionId?: string}>,
527+
payload: Readonly<{pageId: string, sessionId?: string}>,
528528
}>,
529529
> = [];
530530
device.connect.mockImplementation(message => {

packages/dev-middleware/src/types/ReadonlyURL.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface ReadonlyURLSearchParams {
2525
value: string,
2626
name: string,
2727
params: URLSearchParams,
28-
) => mixed,
28+
) => unknown,
2929
thisArg: This,
3030
): void;
3131
toString(): string;

packages/react-native-babel-preset/src/__tests__/__fixtures__/kitchen-sink-input.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function* asyncNumberGenerator(
5959
}
6060

6161
// Async/await patterns
62-
async function fetchData(url: string): Promise<{data: mixed}> {
62+
async function fetchData(url: string): Promise<{data: unknown}> {
6363
const response = await fetch(url);
6464
const data = await response.json();
6565
return {data};
@@ -159,7 +159,7 @@ function parseDate(
159159
}
160160

161161
// Try-catch with optional binding
162-
function safeJsonParse(input: string): mixed {
162+
function safeJsonParse(input: string): unknown {
163163
try {
164164
return JSON.parse(input);
165165
} catch {
@@ -182,7 +182,7 @@ const MyClass = class {
182182
};
183183

184184
// Dynamic import (syntax only)
185-
async function loadModule(): Promise<mixed> {
185+
async function loadModule(): Promise<unknown> {
186186
// $FlowExpectedError[cannot-resolve-module] - Testing dynamic import syntax
187187
const module = await import('./some-module');
188188
return module.default;

packages/react-native-babel-preset/src/__tests__/transform-snapshot-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const testConfigs = [
133133

134134
function transformCode(
135135
code: string,
136-
options: {[string]: mixed},
136+
options: {[string]: unknown},
137137
): string | null {
138138
const result = babel.transformSync(code, {
139139
babelrc: false,
@@ -156,7 +156,7 @@ function ensureDirectoryExists(dir: string): void {
156156
}
157157
}
158158

159-
function makeHeader(description: string, options: {[string]: mixed}): string {
159+
function makeHeader(description: string, options: {[string]: unknown}): string {
160160
return `/**
161161
* Copyright (c) Meta Platforms, Inc. and affiliates.
162162
*

packages/react-native-codegen/src/parsers/consistency/compareSnaps.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
'use strict';
1212

1313
function compareSnaps(
14-
flowFixtures /*: $ReadOnly<{[string]: string}> */,
15-
flowSnaps /*: $ReadOnly<{[string]: string}> */,
16-
flowExtraCases /*: $ReadOnlyArray<string> */,
17-
tsFixtures /*: $ReadOnly<{[string]: string}> */,
18-
tsSnaps /*: $ReadOnly<{[string]: string}> */,
19-
tsExtraCases /*: $ReadOnlyArray<string> */,
20-
ignoredCases /*: $ReadOnlyArray<string> */,
14+
flowFixtures /*: Readonly<{[string]: string}> */,
15+
flowSnaps /*: Readonly<{[string]: string}> */,
16+
flowExtraCases /*: ReadonlyArray<string> */,
17+
tsFixtures /*: Readonly<{[string]: string}> */,
18+
tsSnaps /*: Readonly<{[string]: string}> */,
19+
tsExtraCases /*: ReadonlyArray<string> */,
20+
ignoredCases /*: ReadonlyArray<string> */,
2121
) {
2222
const flowCases = Object.keys(flowFixtures).sort();
2323
const tsCases = Object.keys(tsFixtures).sort();
@@ -68,8 +68,8 @@ function compareSnaps(
6868
}
6969

7070
function compareTsArraySnaps(
71-
tsSnaps /*: $ReadOnly<{[string]: string}> */,
72-
tsExtraCases /*: $ReadOnlyArray<string> */,
71+
tsSnaps /*: Readonly<{[string]: string}> */,
72+
tsExtraCases /*: ReadonlyArray<string> */,
7373
) {
7474
for (const array2Case of tsExtraCases.filter(
7575
name => name.indexOf('ARRAY2') !== -1,

packages/react-native-compatibility-check/src/ErrorFormatting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function formatTypeAnnotation(annotation: CompleteTypeAnnotation): string {
199199
let validUnionType;
200200
try {
201201
validUnionType = parseValidUnionType(annotation);
202-
} catch (_e: mixed) {
202+
} catch (_e: unknown) {
203203
// parseValidUnionType throws for unsupported union types
204204
return 'Union<mixed>';
205205
}

packages/react-native/Libraries/Components/AccessibilityInfo/__tests__/AccessibilityInfo-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('AccessibilityInfo', () => {
105105
mockNativeAccessibilityManagerDefault.getCurrentPrefersCrossFadeTransitionsState =
106106
null;
107107

108-
const result: mixed =
108+
const result: unknown =
109109
await AccessibilityInfo.prefersCrossFadeTransitions().catch(e => e);
110110

111111
invariant(
@@ -151,7 +151,7 @@ describe('AccessibilityInfo', () => {
151151
mockNativeAccessibilityManagerDefault.getCurrentDarkerSystemColorsState =
152152
null;
153153

154-
const result: mixed =
154+
const result: unknown =
155155
await AccessibilityInfo.isDarkerSystemColorsEnabled().catch(e => e);
156156

157157
invariant(
@@ -184,7 +184,7 @@ describe('AccessibilityInfo', () => {
184184

185185
mockNativeAccessibilityInfo.isHighTextContrastEnabled = null;
186186

187-
const result: mixed =
187+
const result: unknown =
188188
await AccessibilityInfo.isHighTextContrastEnabled().catch(e => e);
189189

190190
invariant(

packages/react-native/Libraries/Core/Devtools/__tests__/loadBundleFromServer-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ test('loadBundleFromServer will throw for JSON responses', async () => {
9595
mockDataResponse = JSON.stringify({message: 'Error thrown from Metro'});
9696
mockRequestError = null;
9797

98-
const error: mixed = await loadBundleFromServer(
98+
const error: unknown = await loadBundleFromServer(
9999
'/Fail.bundle?platform=ios',
100100
).catch(e => e);
101101

@@ -112,7 +112,7 @@ test('loadBundleFromServer will throw LoadBundleFromServerError for request erro
112112
mockDataResponse = '';
113113
mockRequestError = 'Some error';
114114

115-
const error: mixed = await loadBundleFromServer(
115+
const error: unknown = await loadBundleFromServer(
116116
'/Fail.bundle?platform=ios',
117117
).catch(e => e);
118118

packages/react-native/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function isMissingCliDependency(error /*: Error */) {
4747
);
4848
}
4949

50-
let cli /*: $ReadOnly<{
50+
let cli /*: Readonly<{
5151
bin: string,
5252
loadConfig: $FlowFixMe,
5353
run: () => void

0 commit comments

Comments
 (0)