Skip to content

InferType inconsistent with module implementation #42360

@colinhacks

Description

@colinhacks

If you know how to fix the issue, make a pull request instead.

If you do not mention the authors the issue will be ignored.


I have a suggestion for an improvement to the typings. Happy to submit a PR but I wanted to make sure this change makes sense first.

Currently, the yup package treats all object properties as optional by default:

const schema =  yup.object({
  asdf: yup.string()
})
schema.validate({})  // passes

Yet yup.InferType infers the type as: { asdf: string } when really it should be { asdf?: string }.

The idea behind this change is to make all calls to yup.string, yup.number, and yup.boolean optional by default, which aligns with the behavior of the actual package implementation. I have this working on my local machine, but I wanted to run this by you guys in case there's a reason it's currently done this way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions