Definitelytyped: [@types/yup] - Type 'Ref' is not assignable to type 'string'

Created on 1 Jul 2019  路  2Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/yup package and had problems.
  • [ ] I tried using the latest stable version of tsc. (I'm using v3.3) https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow.
  • [x] [Mention] the authors so they can respond.

    • Authors: @dhardtke, @vtserman, @MoretonBayRC, @sseppola, @YashdalfTheGray, @vincentjames501, @robertbullen, @sat0yu, @dancrumb, @deskoh, @mauricedb

The latest version (0.26.19) made my CD pipeline crash with the following error :
TS2322: Type 'Ref' is not assignable to type 'string'.

I'm guessing it comes from the latest version because the previous one was released 5 days ago and I did several pipelines since then that went fine

Here is the the line in my code that triggers this:

confirmPassword: yup.string().oneOf([yup.ref("password"), null], passwordMismatch[lang])

I think this error shouldn't be thrown, as the Yup docs mention that .ref is expecting a string parameter

Most helpful comment

@guillaumepn

Yes, agreed that should work.

With one little addition given that you are using null in oneOf() as well. So I changed the definition to include nullable() like this:

confirmPassword: yup.string().nullable().oneOf([yup.ref("password"), null]),

All 2 comments

@guillaumepn

Yes, agreed that should work.

With one little addition given that you are using null in oneOf() as well. So I changed the definition to include nullable() like this:

confirmPassword: yup.string().nullable().oneOf([yup.ref("password"), null]),

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JudeAlquiza picture JudeAlquiza  路  3Comments

csharpner picture csharpner  路  3Comments

Loghorn picture Loghorn  路  3Comments

demisx picture demisx  路  3Comments

jgoz picture jgoz  路  3Comments