[英]fp-ts - pipe is deprecated
I'm using "fp-ts": "^2.10.5"
in my typescript/react project and I'm getting a warning that "pipe" has been deprecated.我在我的 typescript/react 项目中使用
"fp-ts": "^2.10.5"
并且收到警告说 "pipe" 已被弃用。 The code below comes from this tutorial on using fp-ts for error handling and validation:下面的代码来自本教程关于使用 fp-ts 进行错误处理和验证:
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)
)
The changelog documenting this deprecation states:记录此弃用的变更日志指出:
deprecate pipeable module, use the specific helpers instead
弃用可管道模块,改用特定的帮助器
What are the "specific helpers"?什么是“特定助手”? How can I address this warning?
我该如何解决这个警告?
To address this warning import pipe
from fp-ts/lib/function
instead of fp-ts/lib/pipeable
:要解决此警告,请从
fp-ts/lib/function
而不是fp-ts/lib/pipeable
pipe
import { pipe } from 'fp-ts/lib/function'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.