einarpersson
einarpersson
Explore posts from servers
Aarktype
Created by einarpersson on 9/16/2024 in #questions
Why does an optional property add a " | undefined" instead of just being an optional property?
Hi, this feels like such a basic question that it probably has an answer, but I don't understand why marking a arktype property as optional not just makes the corresponding inferred type property optional, without adding an additional | undefined? I encountered something similar with zod which had the result that my zod-type and database generated type did not match although they should. Dummy example:
const schema = type({
'name?': 'string',
email: 'string.email'
});


// typeof schema.infer
// {
// email: string;
// name?: string | undefined;
// }

type WhatIWanted = {
name?: string;
email: string;
}
const schema = type({
'name?': 'string',
email: 'string.email'
});


// typeof schema.infer
// {
// email: string;
// name?: string | undefined;
// }

type WhatIWanted = {
name?: string;
email: string;
}
https://github.com/colinhacks/zod/issues/3186
4 replies
KPCKevin Powell - Community
Created by einarpersson on 9/29/2023 in #front-end
Struggling with the new view transitions API
No description
4 replies