From e45deb5471ac8ec836635d9949fb6557dcec6a93 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 1 May 2019 13:59:54 -0700 Subject: [PATCH] Removed $FlowFixMe comments --- .../views/Components/ComponentFiltersModal.js | 99 +++++++++++-------- src/utils.js | 3 - 2 files changed, 58 insertions(+), 44 deletions(-) diff --git a/src/devtools/views/Components/ComponentFiltersModal.js b/src/devtools/views/Components/ComponentFiltersModal.js index 6ff939292d..a23e1af8f5 100644 --- a/src/devtools/views/Components/ComponentFiltersModal.js +++ b/src/devtools/views/Components/ComponentFiltersModal.js @@ -159,8 +159,7 @@ function ComponentFiltersModal({ store, setIsModalShowing }: Props) { onChange={({ currentTarget }) => changeFilterType( componentFilter, - // $FlowFixMe TODO (filters) - parseInt(currentTarget.value, 10) + ((parseInt(currentTarget.value, 10): any): FilterType) ) } > @@ -182,8 +181,10 @@ function ComponentFiltersModal({ store, setIsModalShowing }: Props) { onChange={({ currentTarget }) => updateFilterValueElementType( componentFilter, - // $FlowFixMe TODO (filters) - parseInt(currentTarget.value, 10) + ((parseInt( + currentTarget.value, + 10 + ): any): ElementType) ) } > @@ -287,23 +288,25 @@ function useComponentFilters() { const index = componentFilters.indexOf(componentFilter); if (index >= 0) { if (type === ComponentFilterElementType) { - // $FlowFixMe TODO (filters) - cloned[index] = ({ - type, + cloned[index] = { + type: ComponentFilterElementType, isEnabled: componentFilter.isEnabled, value: ElementTypeHostComponent, - }: ElementTypeComponentFilter); - } else if ( - type === ComponentFilterDisplayName || - type === ComponentFilterLocation - ) { - // $FlowFixMe TODO (filters) - cloned[index] = ({ - type, + }; + } else if (type === ComponentFilterDisplayName) { + cloned[index] = { + type: ComponentFilterDisplayName, isEnabled: componentFilter.isEnabled, isValid: true, value: '', - }: RegExpComponentFilter); + }; + } else if (type === ComponentFilterLocation) { + cloned[index] = { + type: ComponentFilterLocation, + isEnabled: componentFilter.isEnabled, + isValid: true, + value: '', + }; } } return cloned; @@ -320,13 +323,14 @@ function useComponentFilters() { setComponentFilters(componentFilters => { const cloned: Array = [...componentFilters]; - const index = componentFilters.indexOf(componentFilter); - if (index >= 0) { - // $FlowFixMe TODO (filters) - cloned[index] = { - ...componentFilter, - value, - }; + if (componentFilter.type === ComponentFilterElementType) { + const index = componentFilters.indexOf(componentFilter); + if (index >= 0) { + cloned[index] = { + ...componentFilter, + value, + }; + } } return cloned; }); @@ -342,20 +346,24 @@ function useComponentFilters() { setComponentFilters(componentFilters => { const cloned: Array = [...componentFilters]; - const index = componentFilters.indexOf(componentFilter); - if (index >= 0) { - let isValid = true; - try { - new RegExp(value); - } catch (error) { - isValid = false; + if ( + componentFilter.type === ComponentFilterDisplayName || + componentFilter.type === ComponentFilterLocation + ) { + const index = componentFilters.indexOf(componentFilter); + if (index >= 0) { + let isValid = true; + try { + new RegExp(value); + } catch (error) { + isValid = false; + } + cloned[index] = { + ...componentFilter, + isValid, + value, + }; } - // $FlowFixMe TODO (filters) - cloned[index] = { - ...componentFilter, - isValid, - value, - }; } return cloned; }); @@ -381,11 +389,20 @@ function useComponentFilters() { const cloned: Array = [...componentFilters]; const index = componentFilters.indexOf(componentFilter); if (index >= 0) { - // $FlowFixMe TODO (filters) - cloned[index] = { - ...cloned[index], - isEnabled, - }; + if (componentFilter.type === ComponentFilterElementType) { + cloned[index] = { + ...((cloned[index]: any): ElementTypeComponentFilter), + isEnabled, + }; + } else if ( + componentFilter.type === ComponentFilterDisplayName || + componentFilter.type === ComponentFilterLocation + ) { + cloned[index] = { + ...((cloned[index]: any): RegExpComponentFilter), + isEnabled, + }; + } } return cloned; }); diff --git a/src/utils.js b/src/utils.js index 1200687434..499a72bb1d 100644 --- a/src/utils.js +++ b/src/utils.js @@ -81,9 +81,6 @@ function toCodePoint(string: string) { return string.codePointAt(0); } -// TODO (filters) Save the filters as the frontend needs them (an array, with type and "enabled" status) -// Convert the fitlers to Sets for the renderer to consume. - export function getDefaultComponentFilters(): Array { return [ {