How to fix Yup cannot read property object of undefined
![](https://daqxzxzy8xq3u.cloudfront.net/wp-content/uploads/2020/05/23210644/yup-undefined-object-error.jpg)
If you’re using TypeScript with Yup, you might be running into this error:
TypeError: Cannot read property 'object' of undefined
And this is what your code may look like
import yup from 'yup';
const schema = yup.object().shape({});
To fix the error message above, make sure you have types for Yup installed.
npm i -D @types/yup
The next thing to update is how you import Yup into your TypeScript file
import * as yup from 'yup';
That’s it!
I like to tweet about JavaScript and post helpful code snippets. Follow me there if you would like some too!