Skip to content
1 change: 1 addition & 0 deletions src/packages/animatingnumbers/countup.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const CountUp: FunctionComponent<Partial<CountUpProps>> = (props) => {
if (numberArr.length) {
if (!isLoaded.current) {
isLoaded.current = true
// @ts-ignore
timerRef.current = setTimeout(() => {
setNumberTransform()
}, delay)
Comment on lines 94 to 97
Copy link
Copy Markdown

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