Просмотр исходного кода

[doc]修复throttle函数中timer变量的类型定义,改为使用ReturnType<typeof setInterval>以提高类型安全性。

dufu1991 1 год назад
Родитель
Сommit
a911ecffa1
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      docs/site/src/utils/index.ts

+ 1 - 1
docs/site/src/utils/index.ts

@@ -16,7 +16,7 @@ hljs_svelte(hljs);
  * const throttleFunc = throttle(() => console.log(123), 1000)
  */
 export const throttle = <T extends (...args: unknown[]) => void>(func: T, wait: number = 100) => {
-	let timer: null | NodeJS.Timeout = null;
+	let timer: null | ReturnType<typeof setInterval> = null;
 	return function (...args: Parameters<T>) {
 		if (timer) {
 			return;