fix: TS errors

This commit is contained in:
Slinetrac
2025-10-18 16:11:42 +08:00
Unverified
parent c465000178
commit 98725bbecf
8 changed files with 15 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
import eslintReact from "@eslint-react/eslint-plugin";
import eslintJS from "@eslint/js";
import eslintReact from "@eslint-react/eslint-plugin";
import { defineConfig } from "eslint/config";
import configPrettier from "eslint-config-prettier";
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
import pluginImportX from "eslint-plugin-import-x";
@@ -7,7 +8,6 @@ import pluginPrettier from "eslint-plugin-prettier";
import pluginReactHooks from "eslint-plugin-react-hooks";
import pluginReactRefresh from "eslint-plugin-react-refresh";
import pluginUnusedImports from "eslint-plugin-unused-imports";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";

View File

@@ -176,7 +176,7 @@ export const ProfileItem = (props: Props) => {
// 订阅定时器更新事件
useEffect(() => {
let refreshTimeout: ReturnType<typeof setTimeout> | undefined;
let refreshTimeout: number | undefined;
// 处理定时器更新事件 - 这个事件专门用于通知定时器变更
const handleTimerUpdate = (event: Event) => {
const source = event as CustomEvent<string> & { payload?: string };
@@ -185,7 +185,7 @@ export const ProfileItem = (props: Props) => {
// 只有当更新的是当前配置时才刷新显示
if (updatedUid === itemData.uid && showNextUpdate) {
console.log(`收到定时器更新事件: uid=${updatedUid}`);
if (refreshTimeout) {
if (refreshTimeout !== undefined) {
clearTimeout(refreshTimeout);
}
refreshTimeout = window.setTimeout(() => {
@@ -198,7 +198,7 @@ export const ProfileItem = (props: Props) => {
window.addEventListener("verge://timer-updated", handleTimerUpdate);
return () => {
if (refreshTimeout) {
if (refreshTimeout !== undefined) {
clearTimeout(refreshTimeout);
}
// 清理事件监听

View File

@@ -151,7 +151,7 @@ export const ProxiesEditorViewer = (props: Props) => {
const lines = uris.trim().split("\n");
let idx = 0;
const batchSize = 50;
let parseTimer: ReturnType<typeof setTimeout> | undefined;
let parseTimer: number | undefined;
const parseBatch = () => {
const end = Math.min(idx + batchSize, lines.length);
@@ -175,7 +175,7 @@ export const ProxiesEditorViewer = (props: Props) => {
if (idx < lines.length) {
parseTimer = window.setTimeout(parseBatch, 0);
} else {
if (parseTimer) {
if (parseTimer !== undefined) {
clearTimeout(parseTimer);
parseTimer = undefined;
}
@@ -238,7 +238,7 @@ export const ProxiesEditorViewer = (props: Props) => {
}
};
let idleId: number | undefined;
let timeoutId: ReturnType<typeof setTimeout> | undefined;
let timeoutId: number | undefined;
if (window.requestIdleCallback) {
idleId = window.requestIdleCallback(serialize);
} else {
@@ -248,7 +248,7 @@ export const ProxiesEditorViewer = (props: Props) => {
if (idleId !== undefined && window.cancelIdleCallback) {
window.cancelIdleCallback(idleId);
}
if (timeoutId) {
if (timeoutId !== undefined) {
clearTimeout(timeoutId);
}
};

View File

@@ -355,7 +355,7 @@ export const RulesEditorViewer = (props: Props) => {
}
};
let idleId: number | undefined;
let timeoutId: ReturnType<typeof setTimeout> | undefined;
let timeoutId: number | undefined;
if (window.requestIdleCallback) {
idleId = window.requestIdleCallback(serialize);
} else {
@@ -365,7 +365,7 @@ export const RulesEditorViewer = (props: Props) => {
if (idleId !== undefined && window.cancelIdleCallback) {
window.cancelIdleCallback(idleId);
}
if (timeoutId) {
if (timeoutId !== undefined) {
clearTimeout(timeoutId);
}
};

View File

@@ -90,7 +90,7 @@ export const AppDataProvider = ({
const refreshThrottle = 500;
let isUnmounted = false;
const scheduledTimeouts = new Set<ReturnType<typeof setTimeout>>();
const scheduledTimeouts = new Set<number>();
const cleanupFns: Array<() => void> = [];
const registerCleanup = (fn: () => void) => {

View File

@@ -63,7 +63,7 @@ export const fetchLogsViaIPCPeriodically = async () => {
};
// 初始化全局日志服务 (仅IPC模式)
let ipcPollingInterval: number | null = null;
let ipcPollingInterval: ReturnType<typeof setInterval> | null = null;
let isInitializing = false; // 添加初始化标志
export const initGlobalLogService = (

View File

@@ -11,7 +11,7 @@
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,

View File

@@ -2,11 +2,11 @@ import path from "node:path";
import legacy from "@vitejs/plugin-legacy";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
import monacoEditorPlugin, {
type IMonacoEditorOpts,
} from "vite-plugin-monaco-editor";
import svgr from "vite-plugin-svgr";
import { defineConfig } from "vitest/config";
const monacoEditorPluginDefault = (monacoEditorPlugin as any).default as (
options: IMonacoEditorOpts,
) => any;