codelilac
codelilac
DTDrizzle Team
Created by codelilac on 6/24/2024 in #help
Struggling to use Zod with Drizzle... Type errors around |undefined
By default, Zod includes | undefined on fields with Zod.Optional(), this causes an issue since there’s a difference between a type that is set to undefined and getting ‘undefined’ from a variable, which is what that flag enforces checks for. I’ve since switched to Drizzle Typebox which is quite a bit less headache and had this flag in mind from the get go :)
8 replies
DTDrizzle Team
Created by codelilac on 6/24/2024 in #help
Struggling to use Zod with Drizzle... Type errors around |undefined
In your TS config, do you have exactOptionalPropertyTypes enabled? This is the flag that causes the issue
8 replies
DTDrizzle Team
Created by codelilac on 6/24/2024 in #help
Struggling to use Zod with Drizzle... Type errors around |undefined
this appears to be an issue with Zod itself, what a bummer
8 replies
DTDrizzle Team
Created by codelilac on 6/24/2024 in #help
Struggling to use Zod with Drizzle... Type errors around |undefined
for added context:
[{
"resource": "/Users/brandonclark/Repositories/rbp_backend/src/routes/test.ts",
"owner": "typescript",
"code": "2769",
"severity": 8,
"message": "No overload matches this call.\n Overload 1 of 2, '(value: { name: string | SQL<unknown> | Placeholder<string, any>; email: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; role: \"admin\" | ... 2 more ... | Placeholder<...>; createdAt: Date | ... 1 more ... | Placeholder<...>; updatedAt: Date | ... 1 more ... | Placeholder<...>; id?: number | ... 1 more ... | Placeholder<...>; }): PgInsertBase<...>', gave the following error.\n Argument of type 'unknown' is not assignable to parameter of type '{ name: string | SQL<unknown> | Placeholder<string, any>; email: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<string, any>; role: \"admin\" | ... 2 more ... | Placeholder<...>; createdAt: Date | ... 1 more ... | Placeholder<...>; updatedAt: Date | ... 1 more ... | Pla...'.\n Overload 2 of 2, '(values: { name: string | SQL<unknown> | Placeholder<string, any>; email: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; role: \"admin\" | ... 2 more ... | Placeholder<...>; createdAt: Date | ... 1 more ... | Placeholder<...>; updatedAt: Date | ... 1 more ... | Placeholder<...>; id?: number | ... 1 more ... | Placeholder<...>; }[]): PgInsertBase<...>', gave the following error.\n Argument of type 'unknown' is not assignable to parameter of type '{ name: string | SQL<unknown> | Placeholder<string, any>; email: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<string, any>; role: \"admin\" | ... 2 more ... | Placeholder<...>; createdAt: Date | ... 1 more ... | Placeholder<...>; updatedAt: Date | ... 1 more ... | Pla...'.",
"source": "ts",
"startLineNumber": 31,
"startColumn": 37,
"endLineNumber": 31,
"endColumn": 49
}]
[{
"resource": "/Users/brandonclark/Repositories/rbp_backend/src/routes/test.ts",
"owner": "typescript",
"code": "2769",
"severity": 8,
"message": "No overload matches this call.\n Overload 1 of 2, '(value: { name: string | SQL<unknown> | Placeholder<string, any>; email: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; role: \"admin\" | ... 2 more ... | Placeholder<...>; createdAt: Date | ... 1 more ... | Placeholder<...>; updatedAt: Date | ... 1 more ... | Placeholder<...>; id?: number | ... 1 more ... | Placeholder<...>; }): PgInsertBase<...>', gave the following error.\n Argument of type 'unknown' is not assignable to parameter of type '{ name: string | SQL<unknown> | Placeholder<string, any>; email: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<string, any>; role: \"admin\" | ... 2 more ... | Placeholder<...>; createdAt: Date | ... 1 more ... | Placeholder<...>; updatedAt: Date | ... 1 more ... | Pla...'.\n Overload 2 of 2, '(values: { name: string | SQL<unknown> | Placeholder<string, any>; email: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; role: \"admin\" | ... 2 more ... | Placeholder<...>; createdAt: Date | ... 1 more ... | Placeholder<...>; updatedAt: Date | ... 1 more ... | Placeholder<...>; id?: number | ... 1 more ... | Placeholder<...>; }[]): PgInsertBase<...>', gave the following error.\n Argument of type 'unknown' is not assignable to parameter of type '{ name: string | SQL<unknown> | Placeholder<string, any>; email: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<string, any>; role: \"admin\" | ... 2 more ... | Placeholder<...>; createdAt: Date | ... 1 more ... | Placeholder<...>; updatedAt: Date | ... 1 more ... | Pla...'.",
"source": "ts",
"startLineNumber": 31,
"startColumn": 37,
"endLineNumber": 31,
"endColumn": 49
}]
8 replies