Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,11 @@ module.exports = {
mixin$Animatable: 'readonly',
MouseEventHandler: 'readonly',
NavigateEvent: 'readonly',
PerformanceMeasureOptions: 'readonly',
PropagationPhases: 'readonly',
PropertyDescriptor: 'readonly',
PropertyDescriptorMap: 'readonly',
Proxy$traps: 'readonly',
React$Component: 'readonly',
React$Config: 'readonly',
React$Context: 'readonly',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
"fbjs-scripts": "^3.0.1",
"filesize": "^6.0.1",
"flow-bin": "^0.274",
"flow-remove-types": "^2.274",
"flow-bin": "^0.279.0",
"flow-remove-types": "^2.279.0",
"flow-typed": "^4.1.1",
"glob": "^7.1.6",
"glob-stream": "^6.1.0",
"google-closure-compiler": "^20230206.0.0",
"gzip-size": "^5.1.1",
"hermes-eslint": "^0.25.1",
"hermes-parser": "^0.25.1",
"hermes-eslint": "^0.32.0",
"hermes-parser": "^0.32.0",
"jest": "^29.4.2",
"jest-cli": "^29.4.2",
"jest-diff": "^29.4.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-client/src/ReactFlightPerformanceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export function logComponentAborted(
const entryName =
isPrimaryEnv || env === undefined ? name : name + ' [' + env + ']';
if (__DEV__) {
const properties = [
const properties: Array<[string, string]> = [
[
'Aborted',
'The stream was aborted before this Component finished rendering.',
Expand Down Expand Up @@ -215,7 +215,7 @@ export function logComponentErrored(
String(error.message)
: // eslint-disable-next-line react-internal/safe-string-coercion
String(error);
const properties = [['Error', message]];
const properties: Array<[string, string]> = [['Error', message]];
if (componentInfo.key != null) {
addValueToProperties('key', componentInfo.key, properties, 0, '');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ const Dispatcher: DispatcherType = {

// create a proxy to throw a custom error
// in case future versions of React adds more hooks
const DispatcherProxyHandler = {
const DispatcherProxyHandler: Proxy$traps<DispatcherType> = {
get(target: DispatcherType, prop: string) {
if (target.hasOwnProperty(prop)) {
// $FlowFixMe[invalid-computed-prop]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,7 @@ export function attach(
}
if (typeof instance.getClientRects === 'function') {
// DOM
const result = [];
const result: Array<Rect> = [];
const doc = instance.ownerDocument;
const win = doc && doc.defaultView;
const scrollX = win ? win.scrollX : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ function HookView({
const hookDisplayName = hookName ? (
<>
{name}
{!!hookName && <span className={styles.HookName}>({hookName})</span>}
{
// $FlowFixMe[constant-condition]
!!hookName && <span className={styles.HookName}>({hookName})</span>
}
</>
) : (
name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function dialogReducer(state: State, action: Action) {
content: action.content,
id: action.id,
title: action.title || null,
},
} as Dialog,
],
};
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function getTooltipPosition(
mouseY: number,
width: number,
},
) {
): {left: string, top: string} {
const {height, mouseX, mouseY, width} = mousePosition;
let top: number | string = 0;
let left: number | string = 0;
Expand Down Expand Up @@ -108,7 +108,13 @@ function getMousePosition(
}
}

const {height, left, top, width} = targetContainer.getBoundingClientRect();
const {height, left, top, width} =
targetContainer.getBoundingClientRect() as {
height: number,
left: number,
top: number,
width: number,
};

const mouseX = mouseEvent.clientX - left;
const mouseY = mouseEvent.clientY - top;
Expand Down
12 changes: 10 additions & 2 deletions packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,21 @@ type Section = {
};

function IndexedSourceMapConsumer(sourceMapJSON: IndexSourceMap) {
let lastOffset = {
let lastOffset: {
line: number,
column: number,
...
} = {
line: -1,
column: 0,
};

const sections: Array<Section> = sourceMapJSON.sections.map(section => {
const offset = section.offset;
const offset: {
line: number,
column: number,
...
} = section.offset;
const offsetLine = offset.line;
const offsetColumn = offset.column;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const contextData = {
bool: true,
func: someNamedFunction,
number: 123,
object: {outer: {inner: {}}},
object: {outer: {inner: {} as {...}}},
string: 'abc',
symbol: Symbol.for('symbol'),
null: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type {
TimelineData,
SchedulingEvent,
SuspenseEvent,
Snapshot,
} from '../types';
import {
REACT_TOTAL_NUM_LANES,
Expand Down Expand Up @@ -350,7 +351,7 @@ function processScreenshot(
) {
const encodedSnapshot = event.args.snapshot; // Base 64 encoded

const snapshot = {
const snapshot: Snapshot = {
height: 0,
image: null,
imageSource: `data:image/png;base64,${encodedSnapshot}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import type {Layouter} from '../layouter';
import type {LayoutInfo, Layouter} from '../layouter';

/**
* Assumes {@param layout} will only contain 2 views.
Expand All @@ -25,7 +25,7 @@ export const withVerticalScrollbarLayout: Layouter = (
? scrollbarLayoutInfo.view.desiredSize().width
: 0;

const laidOutContentLayoutInfo = {
const laidOutContentLayoutInfo: LayoutInfo = {
...contentLayoutInfo,
frame: {
origin: contentLayoutInfo.view.frame.origin,
Expand All @@ -35,7 +35,7 @@ export const withVerticalScrollbarLayout: Layouter = (
},
},
};
const laidOutScrollbarLayoutInfo = {
const laidOutScrollbarLayoutInfo: LayoutInfo = {
...scrollbarLayoutInfo,
frame: {
origin: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,7 @@ function mergeTranslate(translateA: ?string, translateB: ?string): string {
return translateB || '';
}
if (!translateB || translateB === 'none') {
// $FlowFixMe[constant-condition]
return translateA || '';
}
const partsA = translateA.split(' ');
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactCapturedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function createCapturedValueAtFiber<T>(
if (existing !== undefined) {
return existing;
}
const captured = {
const captured: CapturedValue<T> = {
value,
source,
stack: getStackByFiberInDevAndProd(source),
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberPerformanceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const reusableComponentDevToolDetails = {
track: COMPONENTS_TRACK,
};

const reusableComponentOptions = {
const reusableComponentOptions: PerformanceMeasureOptions = {
start: -0,
end: -0,
detail: {
Expand Down Expand Up @@ -351,7 +351,7 @@ export function logComponentErrored(
// error boundary itself.
debugTask = fiber._debugTask;
}
const options = {
const options: PerformanceMeasureOptions = {
start: startTime,
end: endTime,
detail: {
Expand Down Expand Up @@ -992,7 +992,7 @@ export function logRecoveredRenderPhase(
String(error);
properties.push(['Recoverable Error', message]);
}
const options = {
const options: PerformanceMeasureOptions = {
start: startTime,
end: endTime,
detail: {
Expand Down Expand Up @@ -1199,7 +1199,7 @@ export function logCommitErrored(
String(error);
properties.push(['Error', message]);
}
const options = {
const options: PerformanceMeasureOptions = {
start: startTime,
end: endTime,
detail: {
Expand Down
8 changes: 4 additions & 4 deletions packages/react-server-dom-esm/src/ReactFlightESMReferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function bind(this: ServerReference<any>): any {
const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
return Object.defineProperties(
(newFn: any),
__DEV__
(__DEV__
? {
$$typeof,
$$id,
Expand All @@ -82,7 +82,7 @@ function bind(this: ServerReference<any>): any {
$$id,
$$bound,
bind: {value: bind, configurable: true},
},
}) as PropertyDescriptorMap,
);
}
return newFn;
Expand All @@ -101,7 +101,7 @@ export function registerServerReference<T: Function>(
const $$bound = {value: null, configurable: true};
return Object.defineProperties(
(reference: any),
__DEV__
(__DEV__
? {
$$typeof,
$$id,
Expand All @@ -117,6 +117,6 @@ export function registerServerReference<T: Function>(
$$id,
$$bound,
bind: {value: bind, configurable: true},
},
}) as PropertyDescriptorMap,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function bind(this: ServerReference<any>): any {
const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
return Object.defineProperties(
(newFn: any),
__DEV__
(__DEV__
? {
$$typeof,
$$id,
Expand All @@ -89,7 +89,7 @@ function bind(this: ServerReference<any>): any {
$$id,
$$bound,
bind: {value: bind, configurable: true},
},
}) as PropertyDescriptorMap,
);
}
return newFn;
Expand All @@ -108,7 +108,7 @@ export function registerServerReference<T>(
const $$bound = {value: null, configurable: true};
return Object.defineProperties(
(reference: any),
__DEV__
(__DEV__
? {
$$typeof,
$$id,
Expand All @@ -124,6 +124,6 @@ export function registerServerReference<T>(
$$id,
$$bound,
bind: {value: bind, configurable: true},
},
}) as PropertyDescriptorMap,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export function prerender(
});
}

let serverManifest = {};
let serverManifest: ServerManifest = {};
export function registerServerActions(manifest: ServerManifest) {
// This function is called by the bundler to register the manifest.
serverManifest = manifest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function prerender(
});
}

let serverManifest = {};
let serverManifest: ServerManifest = {};
export function registerServerActions(manifest: ServerManifest) {
// This function is called by the bundler to register the manifest.
serverManifest = manifest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ export function prerender(
});
}

let serverManifest = {};
let serverManifest: ServerManifest = {};
export function registerServerActions(manifest: ServerManifest) {
// This function is called by the bundler to register the manifest.
serverManifest = manifest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function bind(this: ServerReference<any>): any {
const $$bound = {value: this.$$bound ? this.$$bound.concat(args) : args};
return Object.defineProperties(
(newFn: any),
__DEV__
(__DEV__
? {
$$typeof,
$$id,
Expand All @@ -96,7 +96,7 @@ function bind(this: ServerReference<any>): any {
$$id,
$$bound,
bind: {value: bind, configurable: true},
},
}) as PropertyDescriptorMap,
);
}
return newFn;
Expand All @@ -115,7 +115,7 @@ export function registerServerReference<T: Function>(
const $$bound = {value: null, configurable: true};
return Object.defineProperties(
(reference: any),
__DEV__
(__DEV__
? {
$$typeof,
$$id,
Expand All @@ -131,13 +131,13 @@ export function registerServerReference<T: Function>(
$$id,
$$bound,
bind: {value: bind, configurable: true},
},
}) as PropertyDescriptorMap,
);
}

const PROMISE_PROTOTYPE = Promise.prototype;

const deepProxyHandlers = {
const deepProxyHandlers: Proxy$traps<mixed> = {
get: function (
target: Function,
name: string | symbol,
Expand Down
Loading