Skip to content

Commit

Permalink
[flow] enable enforce_local_inference_annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
kassens committed Jan 5, 2023
1 parent 2353823 commit 9362bda
Show file tree
Hide file tree
Showing 60 changed files with 121 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/react-cache/src/ReactCacheOld.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function readContext(Context: ReactContext<mixed>) {
return dispatcher.readContext(Context);
}

// $FlowFixMe[missing-local-annot]
function identityHashFn(input) {
if (__DEV__) {
if (
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ function onDisconnected() {
disconnectedCallback();
}

// $FlowFixMe[missing-local-annot]
function onError({code, message}) {
safeUnmount();

Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-extensions/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

let welcomeHasInitialized = false;

// $FlowFixMe[missing-local-annot]
function welcome(event) {
if (
event.source !== window ||
Expand Down Expand Up @@ -55,6 +56,7 @@ function setup(hook: any) {

const bridge = new Bridge({
listen(fn) {
// $FlowFixMe[missing-local-annot]
const listener = event => {
if (
event.source !== window ||
Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-inline/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {BackendBridge} from 'react-devtools-shared/src/bridge';
import type {Wall} from 'react-devtools-shared/src/types';

function startActivation(contentWindow: any, bridge: BackendBridge) {
// $FlowFixMe[missing-local-annot]
const onSavedPreferences = data => {
// This is the only message we're listening for,
// so it's safe to cleanup after we've received it.
Expand Down Expand Up @@ -96,6 +97,7 @@ export function createBridge(contentWindow: any, wall?: Wall): BackendBridge {
if (wall == null) {
wall = {
listen(fn) {
// $FlowFixMe[missing-local-annot]
const onMessage = ({data}) => {
fn(data);
};
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-inline/src/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function createBridge(contentWindow: any, wall?: Wall): FrontendBridge {
if (wall == null) {
wall = {
listen(fn) {
// $FlowFixMe[missing-local-annot]
const onMessage = ({data}) => {
fn(data);
};
Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-shared/src/backend/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export function patch({
? targetConsole[method].__REACT_DEVTOOLS_ORIGINAL_METHOD__
: targetConsole[method]);

// $FlowFixMe[missing-local-annot]
const overrideMethod = (...args) => {
let shouldAppendWarningStack = false;
if (method !== 'log') {
Expand Down Expand Up @@ -335,6 +336,7 @@ export function patchForStrictMode() {
? targetConsole[method].__REACT_DEVTOOLS_STRICT_MODE_ORIGINAL_METHOD__
: targetConsole[method]);

// $FlowFixMe[missing-local-annot]
const overrideMethod = (...args) => {
if (!consoleSettingsRef.hideConsoleLogsInStrictMode) {
// Dim the text color of the double logs if we're not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default function ContextMenu({children, id}: Props): React.Node {
const menu = ((menuRef.current: any): HTMLElement);
const container = containerRef.current;
if (container !== null) {
// $FlowFixMe[missing-local-annot]
const hideUnlessContains = event => {
if (!menu.contains(event.target)) {
hideMenu();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function Components(_: {}) {
onResizeEnd = () =>
dispatch({type: 'ACTION_SET_IS_RESIZING', payload: false});

// $FlowFixMe[missing-local-annot]
onResize = event => {
const resizeElement = resizeElementRef.current;
const wrapperElement = wrapperElementRef.current;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ export default function EditableValue({
externalValue: value,
});

// $FlowFixMe[missing-local-annot]
const handleChange = ({target}) =>
dispatch({
type: 'UPDATE',
editableValue: target.value,
externalValue: value,
});

// $FlowFixMe[missing-local-annot]
const handleCheckBoxToggle = ({target}) => {
dispatch({
type: 'UPDATE',
Expand All @@ -58,6 +60,7 @@ export default function EditableValue({
overrideValue(path, target.checked);
};

// $FlowFixMe[missing-local-annot]
const handleKeyDown = event => {
// Prevent keydown events from e.g. change selected element in the tree
event.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default function Element({data, index, style}: Props): React.Node {
}
};

// $FlowFixMe[missing-local-annot]
const handleClick = ({metaKey}) => {
if (id !== null) {
logEvent({
Expand All @@ -99,6 +100,7 @@ export default function Element({data, index, style}: Props): React.Node {
setIsHovered(false);
};

// $FlowFixMe[missing-local-annot]
const handleKeyDoubleClick = event => {
// Double clicks on key value are used for text selection (if the text has been truncated).
// They should not enter the owners tree view.
Expand Down Expand Up @@ -220,6 +222,7 @@ export default function Element({data, index, style}: Props): React.Node {
}

// Prevent double clicks on toggle from drilling into the owner list.
// $FlowFixMe[missing-local-annot]
const swallowDoubleClick = event => {
event.preventDefault();
event.stopPropagation();
Expand All @@ -233,13 +236,15 @@ type ExpandCollapseToggleProps = {
function ExpandCollapseToggle({element, store}: ExpandCollapseToggleProps) {
const {children, id, isCollapsed} = element;

// $FlowFixMe[missing-local-annot]
const toggleCollapsed = event => {
event.preventDefault();
event.stopPropagation();

store.toggleIsCollapsed(id, !isCollapsed);
};

// $FlowFixMe[missing-local-annot]
const stopPropagation = event => {
// Prevent the row from selecting
event.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function InspectedElementContextTree({
// We add an object with a "value" key as a wrapper around Context data
// so that we can use the shared <KeyValue> component to display it.
// This wrapper object can't be renamed.
// $FlowFixMe[missing-local-annot]
const canRenamePathsAtDepth = depth => depth > 1;

if (isEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ function HookView({

// Certain hooks are not editable at all (as identified by react-debug-tools).
// Primitive hook names (e.g. the "State" name for useState) are also never editable.
// $FlowFixMe[missing-local-annot]
const canRenamePathsAtDepth = depth => isStateEditable && depth > 1;

const isCustomHook = subHooks.length > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,9 @@ export default function KeyValue({
return children;
}

// $FlowFixMe[missing-local-annot]
function DeleteToggle({deletePath, name, path}) {
// $FlowFixMe[missing-local-annot]
const handleClick = event => {
event.stopPropagation();
deletePath(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function AutoSizeInput({
value,
...rest
}: Props): React.Node {
// $FlowFixMe[missing-local-annot]
const onFocusWrapper = event => {
const input = event.target;
if (input !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ function Row({
const [isAttributeValid, setIsAttributeValid] = useState(true);
const [isValueValid, setIsValueValid] = useState(true);

// $FlowFixMe[missing-local-annot]
const validateAndSetLocalAttribute = newAttribute => {
const isValid =
newAttribute === '' ||
Expand All @@ -183,6 +184,7 @@ function Row({
});
};

// $FlowFixMe[missing-local-annot]
const validateAndSetLocalValue = newValue => {
let isValid = false;
try {
Expand Down Expand Up @@ -262,6 +264,7 @@ function Field({
placeholder,
value,
}: FieldProps) {
// $FlowFixMe[missing-local-annot]
const onKeyDown = event => {
switch (event.key) {
case 'Enter':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function NewArrayValue({

// This is a bit of an unusual usage of the EditableName component,
// but otherwise it acts the way we want for a new Array entry.
// $FlowFixMe[missing-local-annot]
const overrideName = (oldPath: any, newPath) => {
const value = newPath[newPath.length - 1];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function NewKeyValue({
const [newPropKey, setNewPropKey] = useState<number>(0);
const [newPropName, setNewPropName] = useState<string>('');

// $FlowFixMe[missing-local-annot]
const overrideNewEntryName = (oldPath: any, newPath) => {
setNewPropName(newPath[newPath.length - 1]);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ function updateIndentationSizeVar(
list.style.setProperty('--indentation-size', `${maxIndentationSize}px`);
}

// $FlowFixMe[missing-local-annot]
function InnerElementType({children, style, ...rest}) {
const {ownerID} = useContext(TreeStateContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function SidebarSelectedFiberInfo(_: Props): React.Node {
rootID: ((rootID: any): number),
});

// $FlowFixMe[missing-local-annot]
const handleKeyDown = event => {
switch (event.key) {
case 'ArrowUp':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default function SnapshotSelector(_: Props): React.Node {

let label = null;
if (numFilteredCommits > 0) {
// $FlowFixMe[missing-local-annot]
const handleCommitInputChange = event => {
const value = parseInt(event.currentTarget.value, 10);
if (!isNaN(value)) {
Expand All @@ -100,10 +101,12 @@ export default function SnapshotSelector(_: Props): React.Node {
}
};

// $FlowFixMe[missing-local-annot]
const handleClick = event => {
event.currentTarget.select();
};

// $FlowFixMe[missing-local-annot]
const handleKeyDown = event => {
switch (event.key) {
case 'ArrowDown':
Expand Down Expand Up @@ -159,6 +162,7 @@ export default function SnapshotSelector(_: Props): React.Node {
selectCommitIndex(filteredCommitIndices[nextCommitIndex]);
};

// $FlowFixMe[missing-local-annot]
const handleKeyDown = event => {
switch (event.key) {
case 'ArrowLeft':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ export default function SearchInput({

const resetSearch = () => search('');

// $FlowFixMe[missing-local-annot]
const handleChange = ({currentTarget}) => {
search(currentTarget.value);
};
// $FlowFixMe[missing-local-annot]
const handleKeyPress = ({key, shiftKey}) => {
if (key === 'Enter') {
if (shiftKey) {
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-shared/src/devtools/views/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export function useLocalStorage<T>(
// Listen for changes to this local storage value made from other windows.
// This enables the e.g. "⚛️ Elements" tab to update in response to changes from "⚛️ Settings".
useLayoutEffect(() => {
// $FlowFixMe[missing-local-annot]
const onStorage = event => {
const newValue = getValueFromLocalStorage();
if (key === event.key && storedValue !== newValue) {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-shell/src/app/EditableProps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {

const initialData = {foo: 'FOO', bar: 'BAR'};

// $FlowFixMe[missing-local-annot]
function reducer(state, action: {type: string}) {
switch (action.type) {
case 'swap':
Expand Down Expand Up @@ -80,6 +81,7 @@ class StatefulClass extends Component<Props, State> {
state: 'California',
};

// $FlowFixMe[missing-local-annot]
handleChange = ({target}): any =>
this.setState({
state: target.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ErrorBoundary extends React.Component {
}
}

// $FlowFixMe[missing-local-annot]
function Component({label}) {
return <div>{label}</div>;
}
Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-shell/src/app/Iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function Iframe(): React.Node {

const iframeStyle = {border: '2px solid #eee', height: 80};

// $FlowFixMe[missing-local-annot]
function Frame(props) {
const [element, setElement] = React.useState(null);

Expand Down
Loading

0 comments on commit 9362bda

Please sign in to comment.