Type safe discriminated union query
I am looking for a way to make this query more type safe.
The generated SQL gives me the result I want, which adheres to the specified union type, but typescript needs some convincing and the
$castTo
assertions I have added are hurting type safety.
If I remove .$castTo<unknown>()
in the task query I get this error in the event query Property 'description' is missing in type '{ event_name: string; }' but required in type '{ description: string; }'
, and similar in the note query.
If I remove the .$castTo
to the discriminated union type in the end this type is inferred
I would be happy to hear any tips and tricks 🙇0 Replies