-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optional handling in object #3
Comments
I second that. Infer<> does not generate the optional parameters so the following code results an error: const person = object({
name: string().or(optional()),
age: number().or(optional()),
});
type Person = Infer<typeof person>;
function updatePerson(personData: Person = {}) { ... } It would be great to get it fixed. |
Ouch, looks like superstruct typetest suite has failed me: banditypes/tests/typings/optional.ts Lines 6 to 12 in 0b992f7
The inferred type is assignable to the target one, but they're not equal. |
If you want a better test you can add this test<{
a?: number
b: string
}>(object({
a: number().or(optional()),
b: string(),
})) which typescript complain without a proper fix for the optional on object |
also add tsafe for testing that two types are equals closes thoughtspile#3
also add tsafe for testing that two types are equals closes thoughtspile#3
also add tsafe for testing that two types are equals closes thoughtspile#3
Fixed in I also updated the typetest suite for strict checks, and opened an issue in superstruct in case they'd like to avoid problems like these. |
given the following snippet
we have the resulting person type
where we could have
what do you think ?
The text was updated successfully, but these errors were encountered: