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,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ export function installHook(target: any): DevToolsHook | null {
224224
function patchConsoleForInitialRenderInStrictMode({
225225
hideConsoleLogsInStrictMode,
226226
browserTheme,
227-
}: {
227+
}: {|
228228
hideConsoleLogsInStrictMode: boolean,
229229
browserTheme: BrowserTheme,
230-
}) {
230+
|}) {
231231
const overrideConsoleMethods = [
232232
'error',
233233
'group',

packages/react-devtools-shared/src/hooks/astUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export type Position = {|
1818
column: number,
1919
|};
2020

21-
export type SourceFileASTWithHookDetails = {
21+
export type SourceFileASTWithHookDetails = {|
2222
sourceFileAST: File,
2323
line: number,
2424
source: string,
25-
};
25+
|};
2626

2727
export const NO_HOOK_NAME = '<no-hook>';
2828

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ export function checkForUpdate({
168168
element,
169169
refresh,
170170
store,
171-
}: {
171+
}: {|
172172
bridge: FrontendBridge,
173173
element: Element,
174174
refresh: RefreshFunction,
175175
store: Store,
176-
}): void {
176+
|}): void {
177177
const {id} = element;
178178
const rendererID = store.getRendererIDForElement(id);
179179
if (rendererID != null) {

packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeGrid.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeList.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-devtools-timeline/src/CanvasPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function CanvasPage({profilerData, viewState}: Props) {
8080
className={styles.CanvasPage}
8181
style={{backgroundColor: COLORS.BACKGROUND}}>
8282
<AutoSizer>
83-
{({height, width}: {height: number, width: number}) => (
83+
{({height, width}: {|height: number, width: number|}) => (
8484
<AutoSizedCanvas
8585
data={profilerData}
8686
height={height}

packages/react-devtools-timeline/src/types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export type Return<T> = Return_<*, T>;
1717

1818
// Project types
1919

20-
export type ErrorStackFrame = {
20+
export type ErrorStackFrame = {|
2121
fileName: string,
2222
lineNumber: number,
2323
columnNumber: number,
24-
};
24+
|};
2525

2626
export type Milliseconds = number;
2727

packages/react-devtools-timeline/src/utils/useSmartTooltip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export default function useSmartTooltip({
1616
canvasRef,
1717
mouseX,
1818
mouseY,
19-
}: {
19+
}: {|
2020
canvasRef: {|current: HTMLCanvasElement | null|},
2121
mouseX: number,
2222
mouseY: number,
23-
}) {
23+
|}) {
2424
const ref = useRef<HTMLElement | null>(null);
2525

2626
// HACK: Browser extension reports window.innerHeight of 0,

packages/react-devtools-timeline/src/view-base/resizable/ResizableView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const HIDDEN_RECT = {
4747
};
4848

4949
export class ResizableView extends View {
50-
_canvasRef: {current: HTMLCanvasElement | null};
50+
_canvasRef: {|current: HTMLCanvasElement | null|};
5151
_layoutState: LayoutState;
5252
_mutableViewStateKey: string;
5353
_resizeBar: ResizeBarView;
@@ -60,7 +60,7 @@ export class ResizableView extends View {
6060
frame: Rect,
6161
subview: View,
6262
viewState: ViewState,
63-
canvasRef: {current: HTMLCanvasElement | null},
63+
canvasRef: {|current: HTMLCanvasElement | null|},
6464
label: string,
6565
) {
6666
super(surface, frame, noopLayout);

0 commit comments

Comments
 (0)