summaryrefslogtreecommitdiff
path: root/src/components/Config.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/Config.tsx')
-rw-r--r--src/components/Config.tsx21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/components/Config.tsx b/src/components/Config.tsx
index 34bb20a..6107789 100644
--- a/src/components/Config.tsx
+++ b/src/components/Config.tsx
@@ -6,11 +6,7 @@ import Select from 'src/components/shared/Select';
import { ClashGeneralConfig, DispatchFn, State } from 'src/store/types';
import { ClashAPIConfig } from 'src/types';
-import {
- getClashAPIConfig,
- getLatencyTestUrl,
- getSelectedChartStyleIndex,
-} from '../store/app';
+import { getClashAPIConfig, getLatencyTestUrl, getSelectedChartStyleIndex } from '../store/app';
import { fetchConfigs, getConfigs, updateConfigs } from '../store/configs';
import { openModal } from '../store/modals';
import Button from './Button';
@@ -103,7 +99,7 @@ function ConfigImpl({
}, [dispatch]);
const setConfigState = useCallback(
- (name, val) => {
+ (name: keyof ClashGeneralConfig, val: ClashGeneralConfig[keyof ClashGeneralConfig]) => {
setConfigStateInternal({ ...configState, [name]: val });
},
[configState]
@@ -147,14 +143,14 @@ function ConfigImpl({
[apiConfig, dispatch, setConfigState]
);
- const handleInputOnChange = useCallback(
+ const handleInputOnChange = useCallback<React.ChangeEventHandler<HTMLInputElement>>(
(e) => handleChangeValue(e.target),
[handleChangeValue]
);
const { selectChartStyleIndex, updateAppConfig } = useStoreActions();
- const handleInputOnBlur = useCallback(
+ const handleInputOnBlur = useCallback<React.FocusEventHandler<HTMLInputElement>>(
(e) => {
const target = e.target;
const { name, value } = target;
@@ -198,7 +194,6 @@ function ConfigImpl({
name={f.key}
value={configState[f.key]}
onChange={handleInputOnChange}
- // @ts-expect-error ts-migrate(2322) FIXME: Type '{ name: string; value: any; onChange: (e: an... Remove this comment to see the full error message
onBlur={handleInputOnBlur}
/>
</div>
@@ -210,9 +205,7 @@ function ConfigImpl({
<Select
options={modeOptions}
selected={mode}
- onChange={(e) =>
- handleChangeValue({ name: 'mode', value: e.target.value })
- }
+ onChange={(e) => handleChangeValue({ name: 'mode', value: e.target.value })}
/>
</div>
@@ -221,9 +214,7 @@ function ConfigImpl({
<Select
options={logLeveOptions}
selected={configState['log-level']}
- onChange={(e) =>
- handleChangeValue({ name: 'log-level', value: e.target.value })
- }
+ onChange={(e) => handleChangeValue({ name: 'log-level', value: e.target.value })}
/>
</div>