Describe the bug
types seems to be broken

To Reproduce
import * as Yup from "yup";
export const validationSchema = Yup.object().shape({
email: Yup.string(),
});
Expected behavior
No types error
Additional context
i was using 0.31.1 with @types/yup but 0.32.0 does not need them
Same here, forced to rollback to 0.31.1 for now.
Also had to roll back
Same here, had to rollback
The changelog indicates some kind of breaking change but the README is not updated on how to use the new imports.
馃憥
TypeScript usage is linked in the README. Basically, remove @types/yup, add strictFunctionTypes:false to tsconfig.json, and maybe a couple small adjustments listed in the TypeScript guide.
@types/yup is removed
but why should I set strictFunctionTypes:false for the rest of my app because of one lib
for now it seems like a breaking change which should come in major update
@msheakoski I don't think forcing the consuming application to reduce the strictness of their type checking is an ideal solution here. If yup is unable to accurately represent it's behavior with Typescript's types, then I think the solution is to fall back to less strict typing of yup as a library (i.e. using anys where necessary), which lets consuming apps retain the higher degree of strictness in the rest of their code.
@davewasmer I'm just an early adopter sharing the changes that I read in the TypeScript usage docs. Let's see what the author says.
i'm having issues too, falling back to 0.31.1 for now
rolling back to 0.31.1 and installing @types/yup also solved it for me for now
Same here
Not a bug folks. The typing needed to actually implement the library in TS requires a lot more shenanigans than writing .d.ts files, and at the moment require strictFunctionTypes: false. I appreciate that folks don't want to reduce the strict-ness of their TS project. In practice this is not as bad as it might seem. TS already ignores this setting for class methods and constructors and checks them bivariantly. Turning this off (in my experience at least) doesn't cause more bugs (tho it can) but does reduce the need for explicit down-casting is lots of places it's otherwise silly to need.
To be clear though I would be happy to remove this restriction, I don't have endless time to tweak TS types, so can't promise that it will happen soon. If someone wants to help out more than happy to take improvements. In the meantime if the check is a deal breaker options are:
strictFunctionTypes on and manually cast problem schema to AnySchema or any for edge cases (see note below)for now it seems like a breaking change which should come in major update
There is a ton of breaking type changes so yes it did come with a major update. 0.31.0 -> 0.32.0, that is the versioning convention used by npm and yarn for <1.0.0 projects the, left most version bumps.
As an addendum, 0.32.1 fixes (inadvertently) the most limiting case that needed strictFunctionTypes, object shapes:
object({
name: string()
})
should now work fine with strict on, there are a few other cases that still don't, namely some concat() usages, but I suspect those are easier to work around with casts in the meantime.
thanks for the explanation 馃憤
It also have issue with Lazy schema.
```(property) childNodes: Yup.ArraySchema
meta: Yup.ObjectSchema
...;
}>, Record<...>, TypeOfShape<...>, AssertsShape<...>>;
}>, Record<...>, TypeOfShape<...>, AssertsShape<...>>, Record<...>, TypeOfShape<...>[] | undefined, AssertsShape<...>[] | undefined>
Argument of type 'Lazy
Type 'Lazy
And yes, I've added those options in my tsconfig.json
"strictFunctionTypes": false,
"strictNullChecks": true,
```
@IvanKalinin update to 0.32.1




open up another issue with this specific one please!
There can be issue for those who are not using TypeScript in strict mode
For me I was able to temporary supress this and be on latest package by disabling typecheck only for src folder
https://stackoverflow.com/questions/40164034/typescript-strictnullchecks-with-limited-scope
is there any other way possible?, because having flexible strictnullchecks might be nice instead of enforcing it on everyone
@harshzalavadiya yup will likely never support strictNullChecks being off. Yup as a validation library (and runtime type checker) makes the distinction between undefined and null and needs TS to do the same in order to be accurate
@jquense okay, then enabling strict null checks is the way to go then, It's a hassle for one time but might be worth
Anyway thanks for all of your hard work in yup you are doing amazing job :+1:
Switching to any or AnySchema doesn't work with Formik:


Formik needs to update the types it's using
Most helpful comment
@types/yup is removed
but why should I set strictFunctionTypes:false for the rest of my app because of one lib
for now it seems like a breaking change which should come in major update