-
Notifications
You must be signed in to change notification settings - Fork 89
fix(agents-core): improve type safety in triggers data-access #1557
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
base: main
Are you sure you want to change the base?
Conversation
Replace `as any` casts with proper type-safe conversion functions: - Add DrizzleTriggerInsert/Select types inferred from schema - Add toTriggerInsertValues() to convert Zod->Drizzle insert types - Add toTriggerUpdateValues() to convert Zod->Drizzle update types - Add toTriggerSelect() to convert Drizzle->Zod select types This properly handles the Zod vs Drizzle type mismatch where: - Zod types use `optional()` producing `Type | undefined` - Drizzle types use `| null` for nullable fields The conversion functions explicitly handle this with `?? null`.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @amikofalvy's task —— View job Code Review: Type Safety Improvements in Triggers Data-AccessI've analyzed this PR which replaces ✅ Positive Changes1. Eliminates Dangerous Type ErasureThe PR successfully removes 2. Clean Separation of ConcernsThe approach of creating dedicated conversion functions ( 3. Explicit
|
Summary
Replace
as anycasts in triggers data-access with proper type-safe conversion functions.Changes
DrizzleTriggerInsert/DrizzleTriggerSelecttypes inferred directly from the Drizzle schematoTriggerInsertValues()to convert ZodTriggerInsertto Drizzle-compatible insert valuestoTriggerUpdateValues()to convert ZodTriggerUpdateto Drizzle-compatible update valuestoTriggerSelect()to convert Drizzle select results to Zod-compatibleTriggerSelecttypeWhy
The Zod types (derived from extended schemas) use
.optional()which producesType | undefined, while Drizzle expectsType | nullfor nullable fields. The previous code usedas anycasts to work around this, which:The new conversion functions:
undefined->nullmapping with?? nullsignatureVerificationTesting