【发布时间】:2020-11-18 19:55:08
【问题描述】:
我正在尝试将 Segment.io 分析 sn-p 集成到 Typescript 项目中。
遇到 ESLint 错误,我无法解决。代码如下:
analytics.factory = function (method: any) {
return function () {
const args = Array.prototype.slice.call(arguments)
args.unshift(method)
analytics.push(args)
return analytics
}
}
错误是:
error Use the rest parameters instead of 'arguments' prefer-rest-params
我的 Typescript 有点生锈,我尝试了以下方法无济于事:
- Array.prototype.slice.call(this, ...arguments)
- Array.prototype.slice.call(null, ...arguments)
非常感谢任何帮助!
【问题讨论】:
-
As the rule suggests 使用 rest 参数,而不是
arguments关键字:function (...args) {
标签: typescript eslint typescript-eslint