Skip to content

Commit 9be0974

Browse files
kassenssammy-SC
authored andcommitted
Flow: implicit-inexact-object=error (#25210)
* implicit-inexact-object=error * default everything ambiguous to exact object * inexact where exact causes errors
1 parent ef8e393 commit 9be0974

File tree

83 files changed

+323
-292
lines changed

Some content is hidden

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

83 files changed

+323
-292
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type JSONValue =
3434
| null
3535
| boolean
3636
| string
37-
| {+[key: string]: JSONValue}
37+
| {|+[key: string]: JSONValue|}
3838
| $ReadOnlyArray<JSONValue>;
3939

4040
const PENDING = 0;
@@ -43,36 +43,36 @@ const RESOLVED_MODULE = 2;
4343
const INITIALIZED = 3;
4444
const ERRORED = 4;
4545

46-
type PendingChunk = {
46+
type PendingChunk = {|
4747
_status: 0,
4848
_value: null | Array<() => mixed>,
4949
_response: Response,
5050
then(resolve: () => mixed): void,
51-
};
52-
type ResolvedModelChunk = {
51+
|};
52+
type ResolvedModelChunk = {|
5353
_status: 1,
5454
_value: UninitializedModel,
5555
_response: Response,
5656
then(resolve: () => mixed): void,
57-
};
58-
type ResolvedModuleChunk<T> = {
57+
|};
58+
type ResolvedModuleChunk<T> = {|
5959
_status: 2,
6060
_value: ModuleReference<T>,
6161
_response: Response,
6262
then(resolve: () => mixed): void,
63-
};
64-
type InitializedChunk<T> = {
63+
|};
64+
type InitializedChunk<T> = {|
6565
_status: 3,
6666
_value: T,
6767
_response: Response,
6868
then(resolve: () => mixed): void,
69-
};
70-
type ErroredChunk = {
69+
|};
70+
type ErroredChunk = {|
7171
_status: 4,
7272
_value: Error,
7373
_response: Response,
7474
then(resolve: () => mixed): void,
75-
};
75+
|};
7676
type SomeChunk<T> =
7777
| PendingChunk
7878
| ResolvedModelChunk
@@ -129,17 +129,20 @@ function readRoot<T>(): T {
129129
}
130130

131131
function createPendingChunk(response: Response): PendingChunk {
132+
// $FlowFixMe Flow doesn't support functions as constructors
132133
return new Chunk(PENDING, null, response);
133134
}
134135

135136
function createErrorChunk(response: Response, error: Error): ErroredChunk {
137+
// $FlowFixMe Flow doesn't support functions as constructors
136138
return new Chunk(ERRORED, error, response);
137139
}
138140

139141
function createInitializedChunk<T>(
140142
response: Response,
141143
value: T,
142144
): InitializedChunk<T> {
145+
// $FlowFixMe Flow doesn't support functions as constructors
143146
return new Chunk(INITIALIZED, value, response);
144147
}
145148

@@ -168,13 +171,15 @@ function createResolvedModelChunk(
168171
response: Response,
169172
value: UninitializedModel,
170173
): ResolvedModelChunk {
174+
// $FlowFixMe Flow doesn't support functions as constructors
171175
return new Chunk(RESOLVED_MODEL, value, response);
172176
}
173177

174178
function createResolvedModuleChunk<T>(
175179
response: Response,
176180
value: ModuleReference<T>,
177181
): ResolvedModuleChunk<T> {
182+
// $FlowFixMe Flow doesn't support functions as constructors
178183
return new Chunk(RESOLVED_MODULE, value, response);
179184
}
180185

@@ -333,7 +338,7 @@ export function parseModelString(
333338

334339
export function parseModelTuple(
335340
response: Response,
336-
value: {+[key: string]: JSONValue} | $ReadOnlyArray<JSONValue>,
341+
value: {|+[key: string]: JSONValue|} | $ReadOnlyArray<JSONValue>,
337342
): any {
338343
const tuple: [mixed, mixed, mixed, mixed] = (value: any);
339344

packages/react-client/src/ReactFlightClientHostConfigStream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import type {ResponseBase} from './ReactFlightClient';
1111
import type {StringDecoder} from './ReactFlightClientHostConfig';
1212

13-
export type Response = ResponseBase & {
13+
export type Response = ResponseBase & {|
1414
_partialRow: string,
1515
_fromJSON: (key: string, value: JSONValue) => any,
1616
_stringDecoder: StringDecoder,
17-
};
17+
|};
1818

1919
export type UninitializedModel = string;
2020

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ type Dispatch<A> = A => void;
5151

5252
let primitiveStackCache: null | Map<string, Array<any>> = null;
5353

54-
type Hook = {
54+
type Hook = {|
5555
memoizedState: any,
5656
next: Hook | null,
57-
};
57+
|};
5858

5959
function getPrimitiveStackCache(): Map<string, Array<any>> {
6060
// This initializes a cache of all primitive hooks so that the top
@@ -371,12 +371,12 @@ const DispatcherProxy = new Proxy(Dispatcher, DispatcherProxyHandler);
371371

372372
// Inspect
373373

374-
export type HookSource = {
374+
export type HookSource = {|
375375
lineNumber: number | null,
376376
columnNumber: number | null,
377377
fileName: string | null,
378378
functionName: string | null,
379-
};
379+
|};
380380

381381
export type HooksNode = {
382382
id: number | null,

packages/react-devtools-shared/src/Logger.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ export type LoggerEvent =
3434
|}
3535
| {|
3636
+event_name: 'select-element',
37-
+metadata: {
37+
+metadata: {|
3838
+source: string,
39-
},
39+
|},
4040
|}
4141
| {|
4242
+event_name: 'inspect-element-button-clicked',
4343
|}
4444
| {|
4545
+event_name: 'profiling-start',
46-
+metadata: {
46+
+metadata: {|
4747
+current_tab: string,
48-
},
48+
|},
4949
|}
5050
| {|
5151
+event_name: 'profiler-tab-changed',
52-
+metadata: {
52+
+metadata: {|
5353
+tabId: string,
54-
},
54+
|},
5555
|}
5656
| {|
5757
+event_name: 'settings-changed',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ export function patch({
151151
showInlineWarningsAndErrors,
152152
hideConsoleLogsInStrictMode,
153153
browserTheme,
154-
}: {
154+
}: {|
155155
appendComponentStack: boolean,
156156
breakOnConsoleErrors: boolean,
157157
showInlineWarningsAndErrors: boolean,
158158
hideConsoleLogsInStrictMode: boolean,
159159
browserTheme: BrowserTheme,
160-
}): void {
160+
|}): void {
161161
// Settings may change after we've patched the console.
162162
// Using a shared ref allows the patch function to read the latest values.
163163
consoleSettingsRef.appendComponentStack = appendComponentStack;

packages/react-devtools-shared/src/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ import type {
7979
DisplayDensity,
8080
} from './devtools/views/Settings/SettingsContext';
8181

82-
export const THEME_STYLES: {[style: Theme | DisplayDensity]: any} = {
82+
export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = {
8383
light: {
8484
'--color-attribute-name': '#ef6632',
8585
'--color-attribute-name-not-editable': '#23272f',

packages/react-devtools-shared/src/devtools/ContextMenu/useContextMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function useContextMenu({
2222
data: Object,
2323
id: string,
2424
onChange?: OnChangeFn,
25-
ref: {current: ElementRef<*> | null},
25+
ref: {|current: ElementRef<*> | null|},
2626
|}) {
2727
const {showMenu} = useContext<RegistryContextType>(RegistryContext);
2828

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorsAndWarningsTree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ type TreeProps = {|
119119
badgeClassName: string,
120120
actions: React$Node,
121121
className: string,
122-
clearMessages: () => {},
122+
clearMessages: () => void,
123123
entries: Array<[string, number]>,
124124
isTransitionPending: boolean,
125125
label: string,

packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export type TooltipFiberData = {|
2323
name: string,
2424
|};
2525

26-
export type Props = {
26+
export type Props = {|
2727
fiberData: ChartNode,
28-
};
28+
|};
2929

3030
export default function HoveredFiberInfo({fiberData}: Props) {
3131
const {profilerStore} = useContext(StoreContext);

packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ type ListProps = {|
8282
width: number,
8383
|};
8484

85-
type DragState = {
85+
type DragState = {|
8686
commitIndex: number,
8787
left: number,
8888
sizeIncrement: number,
89-
};
89+
|};
9090

9191
function List({
9292
commitData,

0 commit comments

Comments
 (0)