diff --git a/src/devtools/store.js b/src/devtools/store.js index 9c129d7162..7b8590b54a 100644 --- a/src/devtools/store.js +++ b/src/devtools/store.js @@ -533,7 +533,7 @@ export default class Store extends EventEmitter { while (current != null) { if (current.parentID === 0) { const rendererID = this._rootIDToRendererID.get(current.id); - return rendererID == null ? null : ((rendererID: any): number); + return rendererID == null ? null : rendererID; } else { current = this._idToElement.get(current.parentID); } diff --git a/src/devtools/views/Profiler/ChartNode.js b/src/devtools/views/Profiler/ChartNode.js index 77fa24e1e8..b739434e63 100644 --- a/src/devtools/views/Profiler/ChartNode.js +++ b/src/devtools/views/Profiler/ChartNode.js @@ -10,8 +10,8 @@ type Props = {| height: number, isDimmed?: boolean, label: string, - onClick: Function, - onDoubleClick?: Function, + onClick: (event: SyntheticMouseEvent<*>) => mixed, + onDoubleClick?: (event: SyntheticMouseEvent<*>) => mixed, placeLabelAboveNode?: boolean, width: number, x: number, diff --git a/src/devtools/views/Profiler/CommitFlamegraphListItem.js b/src/devtools/views/Profiler/CommitFlamegraphListItem.js index 171ebebb45..b5829d11e3 100644 --- a/src/devtools/views/Profiler/CommitFlamegraphListItem.js +++ b/src/devtools/views/Profiler/CommitFlamegraphListItem.js @@ -26,7 +26,7 @@ function CommitFlamegraphListItem({ data, index, style }: Props) { const { maxSelfDuration, rows } = chartData; const handleClick = useCallback( - (event: MouseEvent, id: number, name: string) => { + (event: SyntheticMouseEvent<*>, id: number, name: string) => { event.stopPropagation(); selectFiber(id, name); }, diff --git a/src/devtools/views/Profiler/FilterModal.js b/src/devtools/views/Profiler/FilterModal.js index fc58bd5616..f1c1477e8d 100644 --- a/src/devtools/views/Profiler/FilterModal.js +++ b/src/devtools/views/Profiler/FilterModal.js @@ -7,7 +7,7 @@ import { useModalDismissSignal } from '../hooks'; import styles from './FilterModal.css'; type Props = {| - dismissModal: Function, + dismissModal: () => void, |}; export default function FilterModal({ dismissModal }: Props) { @@ -19,8 +19,8 @@ export default function FilterModal({ dismissModal }: Props) { } = useContext(ProfilerContext); const handleNumberChange = useCallback( - ({ currentTarget }) => { - const newValue = parseFloat(currentTarget.value); + (event: SyntheticEvent) => { + const newValue = parseFloat(event.currentTarget.value); setMinCommitDuration( Number.isNaN(newValue) || newValue <= 0 ? 0 : newValue ); @@ -29,9 +29,10 @@ export default function FilterModal({ dismissModal }: Props) { ); const handleEnabledChange = useCallback( - ({ currentTarget }) => { - setIsCommitFilterEnabled(currentTarget.checked); - if (currentTarget.checked) { + (event: SyntheticEvent) => { + const checked = event.currentTarget.checked; + setIsCommitFilterEnabled(checked); + if (checked) { if (inputRef.current !== null) { inputRef.current.focus(); } diff --git a/src/devtools/views/Profiler/ProfilerContext.js b/src/devtools/views/Profiler/ProfilerContext.js index 2a9aa6c8fb..c2fd4b5a5d 100644 --- a/src/devtools/views/Profiler/ProfilerContext.js +++ b/src/devtools/views/Profiler/ProfilerContext.js @@ -114,19 +114,16 @@ function ProfilerContextController({ children }: Props) { let rootHasProfilingData = false; if (importedProfilingData !== null) { rootHasProfilingData = true; - } else if (selectedElementID) { - rendererID = store.getRendererIDForElement( - ((selectedElementID: any): number) - ); - rootID = store.getRootIDForElement(((selectedElementID: any): number)); - rootHasProfilingData = store.profilingOperations.has( - ((rootID: any): number) - ); + } else if (selectedElementID !== null) { + rendererID = store.getRendererIDForElement(selectedElementID); + rootID = store.getRootIDForElement(selectedElementID); + rootHasProfilingData = + rootID === null ? false : store.profilingOperations.has(rootID); } else if (store.roots.length > 0) { // If no root is selected, assume the first root; many React apps are single root anyway. rootID = store.roots[0]; rootHasProfilingData = store.profilingOperations.has(rootID); - rendererID = store.getRendererIDForElement(((rootID: any): number)); + rendererID = store.getRendererIDForElement(rootID); } const startProfiling = useCallback(() => store.startProfiling(), [store]); diff --git a/src/devtools/views/Profiler/utils.js b/src/devtools/views/Profiler/utils.js index 33c9217f86..61d2725c76 100644 --- a/src/devtools/views/Profiler/utils.js +++ b/src/devtools/views/Profiler/utils.js @@ -27,15 +27,16 @@ export const calculateSelfDuration = ( return 0; } - let selfDuration = ((actualDurations.get(id): any): number); const node = nodes.get(id); if (node == null) { throw Error(`Could not find node with id "${id}" in commit tree`); } + let selfDuration = actualDurations.get(id) || 0; + node.children.forEach(childID => { if (actualDurations.has(childID)) { - selfDuration -= ((actualDurations.get(childID): any): number); + selfDuration -= actualDurations.get(childID) || 0; } }); diff --git a/src/devtools/views/hooks.js b/src/devtools/views/hooks.js index c6d8ce0984..d742ff9fdd 100644 --- a/src/devtools/views/hooks.js +++ b/src/devtools/views/hooks.js @@ -94,7 +94,7 @@ export function useLocalStorage( export function useModalDismissSignal( modalRef: { current: HTMLDivElement | null }, - dismissCallback: Function + dismissCallback: () => void ): void { useEffect(() => { if (modalRef.current === null) {