From daf55d3d25e18a0fb2a393dda8e64bcb20ebdcc0 Mon Sep 17 00:00:00 2001 From: Sebastian Sebbie Silbermann Date: Fri, 6 Feb 2026 15:49:31 +0100 Subject: [PATCH] Fix type issues --- .../views/Settings/CodeEditorOptions.js | 24 ++++++++++--- .../views/Settings/GeneralSettings.js | 34 ++++++++++++++++--- .../src/app/InspectableElements/Contexts.js | 10 ++++-- .../src/app/SuspenseTree/index.js | 2 +- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Settings/CodeEditorOptions.js b/packages/react-devtools-shared/src/devtools/views/Settings/CodeEditorOptions.js index d6e81ef355..6e2cb27a90 100644 --- a/packages/react-devtools-shared/src/devtools/views/Settings/CodeEditorOptions.js +++ b/packages/react-devtools-shared/src/devtools/views/Settings/CodeEditorOptions.js @@ -20,14 +20,18 @@ import { import styles from './SettingsShared.css'; +type OpenInEditorURLPreset = 'vscode' | 'custom'; + export default function CodeEditorOptions({ environmentNames, }: { environmentNames: Promise>, }): React.Node { - const [openInEditorURLPreset, setOpenInEditorURLPreset] = useLocalStorage< - 'vscode' | 'custom', - >(LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, getDefaultPreset()); + const [openInEditorURLPreset, setOpenInEditorURLPreset] = + useLocalStorage( + LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, + getDefaultPreset(), + ); const [openInEditorURL, setOpenInEditorURL] = useLocalStorage( LOCAL_STORAGE_OPEN_IN_EDITOR_URL, @@ -39,7 +43,17 @@ export default function CodeEditorOptions({ setTheme(currentTarget.value)}> + onChange={({currentTarget}) => { + // Casting here allows an exhaustive check so that devs changing + // themes will get a Flow error if they forget to update options. + // $FlowFixMe[incompatible-cast] We're checking the value below + const value = (currentTarget.value: Theme); + switch (value) { + case 'auto': + case 'light': + case 'dark': + break; + default: + (value: empty); + } + setTheme(value); + }}> @@ -78,9 +93,20 @@ export default function GeneralSettings(_: {}): React.Node {
Display density
diff --git a/packages/react-devtools-shell/src/app/InspectableElements/Contexts.js b/packages/react-devtools-shell/src/app/InspectableElements/Contexts.js index ebd2470ac6..5c58b7456a 100644 --- a/packages/react-devtools-shell/src/app/InspectableElements/Contexts.js +++ b/packages/react-devtools-shell/src/app/InspectableElements/Contexts.js @@ -226,7 +226,10 @@ function FunctionalContextConsumerWithContextUpdates() { {state}
test state:{' '} - setState(e.target.value)} /> + setState(e.currentTarget.value)} + />
@@ -265,7 +268,10 @@ class ModernClassContextConsumerWithUpdates extends Component { 'ModernClassContextConsumerWithUpdates', string, )} - setString(e.target.value)} /> + setString(e.currentTarget.value)} + /> )} diff --git a/packages/react-devtools-shell/src/app/SuspenseTree/index.js b/packages/react-devtools-shell/src/app/SuspenseTree/index.js index f9b687cbc8..c8861fbd94 100644 --- a/packages/react-devtools-shell/src/app/SuspenseTree/index.js +++ b/packages/react-devtools-shell/src/app/SuspenseTree/index.js @@ -195,7 +195,7 @@ function PrimaryFallbackTest({initialSuspend}) {