参考网上的解决方法 可以设置
type interValueProps = NodeJS.Timer | null
let Timer:interValueProps = setInterval(....
但写上去报了 eslint 错误 ‘NodeJS’ 未定义 ‘NodeJS’ is not defined.eslint
查了一下 有两种方法
1. @typescript-eslint/parser@4导致这个问题。(相关提交:4d7265a)
将其降级到 v3@typescript-eslint/parser@3以解决问题。
参考 https://stackoverflow.com/q/64089216/1123955
2.第二种方法
将它添加为全局.eslintrc.js:
"globals": {
"NodeJS": true
},
参考链接
https://github.com/Chatie/eslint-config/issues/45