lodash 的 flow() 打破了 TypeScript 中的 add()
lodash's flow() breaks add() in TypeScript
import _ from 'lodash'
const x = _.add(3, 2) // no linting error
const foo = _.flow(
_.add, // @typescript-eslint/unbound-method
square,
)
为什么使用 lodash 的 flow() 会破坏它自己的 add() 并且有解决方案吗?
原来这个错误来自 recommended-requiring-type-checking eslint 配置。
这个配置比基本的 typescript eslint 更自以为是。因此,我很乐意重写这条规则:
.eslintrc.js
...
rules: {
'@typescript-eslint/unbound-method': 'off', // conflicts with lodash's add()
}
import _ from 'lodash'
const x = _.add(3, 2) // no linting error
const foo = _.flow(
_.add, // @typescript-eslint/unbound-method
square,
)
为什么使用 lodash 的 flow() 会破坏它自己的 add() 并且有解决方案吗?
原来这个错误来自 recommended-requiring-type-checking eslint 配置。
这个配置比基本的 typescript eslint 更自以为是。因此,我很乐意重写这条规则:
.eslintrc.js
...
rules: {
'@typescript-eslint/unbound-method': 'off', // conflicts with lodash's add()
}