Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify ts #2781

Merged
merged 14 commits into from
Nov 21, 2024
1 change: 1 addition & 0 deletions src/packages/animatingnumbers/countup.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@
})
.exec()
}
}, [numberArr])

Check warning on line 88 in src/packages/animatingnumbers/countup.taro.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useCallback has a missing dependency: 'duration'. Either include it or remove the dependency array

useEffect(() => {
if (numberArr.length) {
if (!isLoaded.current) {
isLoaded.current = true
// @ts-ignore
timerRef.current = setTimeout(() => {
setNumberTransform()
}, delay)
Comment on lines +94 to 97
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

建议避免使用 @ts-ignore 并添加正确的类型定义

使用 @ts-ignore 注释来抑制类型检查可能会掩盖潜在的问题。建议通过以下方式解决:

  1. timerRef 添加正确的类型定义
  2. 根据运行环境(Taro)正确处理 setTimeout 的返回类型

建议应用以下修改:

- const timerRef = useRef()
+ const timerRef = useRef<ReturnType<typeof setTimeout>>()

- // @ts-ignore
  timerRef.current = setTimeout(() => {
    setNumberTransform()
  }, delay)

Committable suggestion skipped: line range outside the PR's diff.

Expand Down
Loading