Closed Edelf closed 1 year ago
Given the following interface: interface ChildInterface { myProperty: string | null | undefined; }
interface ChildInterface { myProperty: string | null | undefined; }
And the following Schema definition: const schemaChild: yup.ObjectSchema<ChildInterface> = yup.object({ myProperty: yup.string().notRequired() });
const schemaChild: yup.ObjectSchema<ChildInterface> = yup.object({ myProperty: yup.string().notRequired() });
The result of schemaChild is (note the questionmark '?' on the property): type ChildType { myProperty?: string | null | undefined; }
type ChildType { myProperty?: string | null | undefined; }
This is causing me issues when reusing the ObjectSchema in other Schemas.
Example: https://codesandbox.io/s/romantic-ganguly-muvkpz?file=/src/index.ts
The type yup produces is accurate, the properties may be missing, not just undefined. It's pretty difficult to make the schema produce one or the other dynamically
Given the following interface:
interface ChildInterface { myProperty: string | null | undefined; }
And the following Schema definition:
const schemaChild: yup.ObjectSchema<ChildInterface> = yup.object({ myProperty: yup.string().notRequired() });
The result of schemaChild is (note the questionmark '?' on the property):
type ChildType { myProperty?: string | null | undefined; }
This is causing me issues when reusing the ObjectSchema in other Schemas.
Example: https://codesandbox.io/s/romantic-ganguly-muvkpz?file=/src/index.ts