我在我的类型记录/反应项目中使用了"fp-ts": "^2.10.5",并且我收到了“管道”已经被废弃的警告。下面的代码来自于关于如何使用fp进行错误处理和验证的这教程:
import { Either, left, right } from 'fp-ts/lib/Either'
import { chain } from 'fp-ts/lib/Either'
import { pipe } from 'fp-ts/lib/pipeable'
//
const minLength = (s: string): Either<string, string> =>
s.length >= 6 ? right(s) : left('at least 6 characters')
const oneCapital = (s: string): Either<string, string> =>
/[A-Z]/g.test(s) ? right(s) : left('at least one capital letter')
const oneNumber = (s: string): Either<string, string> =>
/[0-9]/g.test(s) ? right(s) : left('at least one number')
const validatePassword = (s: string): Either<string, string> =>
pipe(
minLength(s),
chain(oneCapital),
chain(oneNumber)
)记录这种弃用的变化量g声明:
不推荐使用管道模块,而使用特定的帮助程序。
什么是“特定的帮手”?我该如何处理这个警告?
发布于 2021-05-11 03:10:45
要解决此警告,请从fp-ts/lib/function而不是fp-ts/lib/pipeable导入fp-ts/lib/pipeable
import { pipe } from 'fp-ts/lib/function'https://stackoverflow.com/questions/67480062
复制相似问题