Yup: InferType ignores required()

Created on 30 Jul 2019  Â·  6Comments  Â·  Source: jquense/yup

Go to https://codesandbox.io/s/serene-wu-5xf1j, hover over the SomeString type and you'll see that required from the yup scheme definition is being ignored:

image

InferType is the actual killer feature of this lib. Without, TS-devs need to create redundant work and inferring types from yup is the way to go. Hence I am wondering why the type definition file is not in this repo here? Actually this issue should have been filed to DefTypes' repo. But there are 2,827 issues and the probs that this is getting resolved there is zero.

CCing the creator of that file @mauricedb (great work) to suggest a fix and @jquense (great work too) to include that type definition file in this repo in the future.

Most helpful comment

@po35 @scottmas Turns out you need to enable "strictNullChecks": true in your tsconfig.json for this to work correctly.

All 6 comments

Thanks 🙂

I am currently on holiday but will take a look when I am back home.

Maurice

Op di 30 jul. 2019 14:39 schreef po35 notifications@github.com:

Go to https://codesandbox.io/s/serene-wu-5xf1j, hover over the SomeString
type and you'll see that required from the yup scheme definition is being
ignored:

[image: image]
https://user-images.githubusercontent.com/52068414/62133282-ce970b80-b2de-11e9-88f8-4fe7dcd22cc2.png

Besides, InferType is the actual killer feature of this lib. Without,
TS-devs need to create redundant work. Hence I am wondering why the type
definition file is not in this repo here? Actually this issue should have
been filed to DefTypes' repo. But there are 2,827 issues and the probs that
this is getting resolved there is zero

CCing the creator of that file @mauricedb https://github.com/mauricedb
(great work) and @jquense https://github.com/jquense (great work too)
to include that type definition file in this repo.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/jquense/yup/issues/582?email_source=notifications&email_token=AAYMWIUEFLDE662RF3F5KDLQCBACRA5CNFSM4IH4LR72YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HCJTXUQ,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAYMWIT5VN534DPJXRIE33LQCBACRANCNFSM4IH4LR7Q
.

I can confirm I'm getting this as well. I took a look at trying to fix it myself but couldn't figure it out. Mauricedb, your Typescript skills are next level.

@po35 @scottmas Turns out you need to enable "strictNullChecks": true in your tsconfig.json for this to work correctly.

Awesome Maurice, that works. Word to the wise though: you may need to restart your typescript server in your editor to get the changes to pick up. I'll go and submit a PR to tweak the Readme to make this requirement more obvious.

@scottmas I am using VS Code as my editor and an update to the tsconfig.json is picked up automatically. Depends on your environment though as you mentioned.

@po35 @scottmas Turns out you need to enable "strictNullChecks": true in your tsconfig.json for this to work correctly.

Shouldn't it be added here https://github.com/jquense/yup#typescript-support?

Was this page helpful?
0 / 5 - 0 ratings