Skip to content

Commit

Permalink
Flow: remove explicit object syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
kassens committed Sep 9, 2022
1 parent 492c6e2 commit 67a0d40
Show file tree
Hide file tree
Showing 259 changed files with 1,439 additions and 1,444 deletions.
4 changes: 2 additions & 2 deletions packages/react-cache/src/LRU.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const {
unstable_IdlePriority: IdlePriority,
} = Scheduler;

type Entry<T> = {|
type Entry<T> = {
value: T,
onDelete: () => mixed,
previous: Entry<T>,
next: Entry<T>,
|};
};

export function createLRU<T>(limit: number) {
let LIMIT = limit;
Expand Down
12 changes: 6 additions & 6 deletions packages/react-cache/src/ReactCacheOld.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ import {createLRU} from './LRU';

type Suspender = {then(resolve: () => mixed, reject: () => mixed): mixed, ...};

type PendingResult = {|
type PendingResult = {
status: 0,
value: Suspender,
|};
};

type ResolvedResult<V> = {|
type ResolvedResult<V> = {
status: 1,
value: V,
|};
};

type RejectedResult = {|
type RejectedResult = {
status: 2,
value: mixed,
|};
};

type Result<V> = PendingResult | ResolvedResult<V> | RejectedResult;

Expand Down
24 changes: 12 additions & 12 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type JSONValue =
| null
| boolean
| string
| {|+[key: string]: JSONValue|}
| {+[key: string]: JSONValue}
| $ReadOnlyArray<JSONValue>;

const PENDING = 0;
Expand All @@ -43,36 +43,36 @@ const RESOLVED_MODULE = 2;
const INITIALIZED = 3;
const ERRORED = 4;

type PendingChunk = {|
type PendingChunk = {
_status: 0,
_value: null | Array<() => mixed>,
_response: Response,
then(resolve: () => mixed): void,
|};
type ResolvedModelChunk = {|
};
type ResolvedModelChunk = {
_status: 1,
_value: UninitializedModel,
_response: Response,
then(resolve: () => mixed): void,
|};
type ResolvedModuleChunk<T> = {|
};
type ResolvedModuleChunk<T> = {
_status: 2,
_value: ModuleReference<T>,
_response: Response,
then(resolve: () => mixed): void,
|};
type InitializedChunk<T> = {|
};
type InitializedChunk<T> = {
_status: 3,
_value: T,
_response: Response,
then(resolve: () => mixed): void,
|};
type ErroredChunk = {|
};
type ErroredChunk = {
_status: 4,
_value: Error,
_response: Response,
then(resolve: () => mixed): void,
|};
};
type SomeChunk<T> =
| PendingChunk
| ResolvedModelChunk
Expand Down Expand Up @@ -338,7 +338,7 @@ export function parseModelString(

export function parseModelTuple(
response: Response,
value: {|+[key: string]: JSONValue|} | $ReadOnlyArray<JSONValue>,
value: {+[key: string]: JSONValue} | $ReadOnlyArray<JSONValue>,
): any {
const tuple: [mixed, mixed, mixed, mixed] = (value: any);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import type {ResponseBase} from './ReactFlightClient';
import type {StringDecoder} from './ReactFlightClientHostConfig';

export type Response = ResponseBase & {|
export type Response = ResponseBase & {
_partialRow: string,
_fromJSON: (key: string, value: JSONValue) => any,
_stringDecoder: StringDecoder,
|};
};

export type UninitializedModel = string;

Expand Down
12 changes: 6 additions & 6 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ type Dispatch<A> = A => void;

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

type Hook = {|
type Hook = {
memoizedState: any,
next: Hook | null,
|};
};

function getPrimitiveStackCache(): Map<string, Array<any>> {
// This initializes a cache of all primitive hooks so that the top
Expand Down Expand Up @@ -154,7 +154,7 @@ function useReducer<S, I, A>(
return [state, (action: A) => {}];
}

function useRef<T>(initialValue: T): {|current: T|} {
function useRef<T>(initialValue: T): {current: T} {
const hook = nextHook();
const ref = hook !== null ? hook.memoizedState : {current: initialValue};
hookLog.push({
Expand Down Expand Up @@ -208,7 +208,7 @@ function useEffect(
}

function useImperativeHandle<T>(
ref: {|current: T | null|} | ((inst: T | null) => mixed) | null | void,
ref: {current: T | null} | ((inst: T | null) => mixed) | null | void,
create: () => T,
inputs: Array<mixed> | void | null,
): void {
Expand Down Expand Up @@ -371,12 +371,12 @@ const DispatcherProxy = new Proxy(Dispatcher, DispatcherProxyHandler);

// Inspect

export type HookSource = {|
export type HookSource = {
lineNumber: number | null,
columnNumber: number | null,
fileName: string | null,
functionName: string | null,
|};
};

export type HooksNode = {
id: number | null,
Expand Down
8 changes: 4 additions & 4 deletions packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ function connectToSocket(socket: WebSocket) {
};
}

type ServerOptions = {|
type ServerOptions = {
key?: string,
cert?: string,
|};
};

type LoggerOptions = {|
type LoggerOptions = {
surface?: ?string,
|};
};

function startServer(
port?: number = 8097,
Expand Down
10 changes: 5 additions & 5 deletions packages/react-devtools-extensions/flow-typed/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ type EnzymeMatchersType = {
toIncludeText(text: string): void,
toMatchElement(
element: React$Element<any>,
options?: {|ignoreProps?: boolean, verbose?: boolean|}
options?: {ignoreProps?: boolean, verbose?: boolean}
): void,
toMatchSelector(selector: string): void,
// 7.x
Expand Down Expand Up @@ -1095,7 +1095,7 @@ type JestPrettyFormatPrint = any => string;
// eslint-disable-next-line no-unused-vars
type JestPrettyFormatStringOrNull = string | null;

type JestPrettyFormatOptions = {|
type JestPrettyFormatOptions = {
callToJSON: boolean,
edgeSpacing: string,
escapeRegex: boolean,
Expand All @@ -1107,14 +1107,14 @@ type JestPrettyFormatOptions = {|
plugins: JestPrettyFormatPlugins,
printFunctionName: boolean,
spacing: string,
theme: {|
theme: {
comment: string,
content: string,
prop: string,
tag: string,
value: string,
|},
|};
},
};

type JestPrettyFormatPlugin = {
print: (
Expand Down
4 changes: 2 additions & 2 deletions packages/react-devtools-inline/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export function activate(
contentWindow: window,
{
bridge,
}: {|
}: {
bridge?: BackendBridge,
|} = {},
} = {},
): void {
if (bridge == null) {
bridge = createBridge(contentWindow);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-devtools-inline/src/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import type {Wall} from 'react-devtools-shared/src/types';
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type {Props} from 'react-devtools-shared/src/devtools/views/DevTools';

type Config = {|
type Config = {
checkBridgeProtocolCompatibility?: boolean,
supportsNativeInspection?: boolean,
supportsProfiling?: boolean,
|};
};

export function createStore(bridge: FrontendBridge, config?: Config): Store {
return new Store(bridge, {
Expand Down Expand Up @@ -62,10 +62,10 @@ export function initialize(
{
bridge,
store,
}: {|
}: {
bridge?: FrontendBridge,
store?: Store,
|} = {},
} = {},
): React.AbstractComponent<Props, mixed> {
if (bridge == null) {
bridge = createBridge(contentWindow);
Expand Down
52 changes: 26 additions & 26 deletions packages/react-devtools-shared/src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,57 @@
import {enableLogger} from 'react-devtools-feature-flags';

export type LoggerEvent =
| {|
| {
+event_name: 'loaded-dev-tools',
|}
| {|
}
| {
+event_name: 'error',
+error_message: string | null,
+error_stack: string | null,
+error_component_stack: string | null,
|}
| {|
}
| {
+event_name: 'selected-components-tab',
|}
| {|
}
| {
+event_name: 'selected-profiler-tab',
|}
| {|
}
| {
+event_name: 'load-hook-names',
+event_status: 'success' | 'error' | 'timeout' | 'unknown',
+duration_ms: number,
+inspected_element_display_name: string | null,
+inspected_element_number_of_hooks: number | null,
|}
| {|
}
| {
+event_name: 'select-element',
+metadata: {|
+metadata: {
+source: string,
|},
|}
| {|
},
}
| {
+event_name: 'inspect-element-button-clicked',
|}
| {|
}
| {
+event_name: 'profiling-start',
+metadata: {|
+metadata: {
+current_tab: string,
|},
|}
| {|
},
}
| {
+event_name: 'profiler-tab-changed',
+metadata: {|
+metadata: {
+tabId: string,
|},
|}
| {|
},
}
| {
+event_name: 'settings-changed',
+metadata: {
+key: string,
+value: any,
...
},
|};
};

export type LogFunction = LoggerEvent => void | Promise<void>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,7 @@ describe('ProfilingCache', () => {

const ModernContext = React.createContext(0);

class LegacyContextProvider extends React.Component<
any,
{|count: number|},
> {
class LegacyContextProvider extends React.Component<any, {count: number}> {
static childContextTypes = {
count: PropTypes.number,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('profiling charts', () => {
describe('flamegraph chart', () => {
// @reactVersion >= 16.9
it('should contain valid data', () => {
const Parent = (_: {||}) => {
const Parent = (_: {}) => {
Scheduler.unstable_advanceTime(10);
return (
<React.Fragment>
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('profiling charts', () => {
describe('ranked chart', () => {
// @reactVersion >= 16.9
it('should contain valid data', () => {
const Parent = (_: {||}) => {
const Parent = (_: {}) => {
Scheduler.unstable_advanceTime(10);
return (
<React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Store component filters', () => {

// @reactVersion >= 16.0
it('should support filtering by element type', () => {
class ClassComponent extends React.Component<{|children: React$Node|}> {
class ClassComponent extends React.Component<{children: React$Node}> {
render() {
return <div>{this.props.children}</div>;
}
Expand Down
Loading

0 comments on commit 67a0d40

Please sign in to comment.