mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(schema): fix zod guard infer type for option fields (#148)
fix manual guard infer type breaks optional zod field type
This commit is contained in:
parent
a56d4ce026
commit
d54f77d78a
1 changed files with 4 additions and 2 deletions
|
@ -1,8 +1,10 @@
|
|||
import { ZodObject, ZodType } from 'zod';
|
||||
import { ZodObject, ZodType, ZodOptional } from 'zod';
|
||||
|
||||
export type Guard<T extends Record<string, unknown>> = ZodObject<
|
||||
{
|
||||
[key in keyof T]: ZodType<T[key]>;
|
||||
[key in keyof T]-?: undefined extends T[key]
|
||||
? ZodOptional<ZodType<Exclude<T[key], undefined>>>
|
||||
: ZodType<T[key]>;
|
||||
}
|
||||
>;
|
||||
|
||||
|
|
Loading…
Reference in a new issue