Skip to content

Typescript error selecting an optional field. #300

@thruflo

Description

@thruflo

I have a collection defined with a zod schema with inserted_at: z.date().optional().

If I try to select this field in a live query:

query
  .from({ thread: threadCollection })
  .select(({ thread }) => ({
    inserted_at: thread.inserted_at
  }))

I get a Typescript error:

Type 'RefProxy<Date | undefined> | undefined' is not assignable to type 'RefProxy<any> | RefProxyFor<any> | BasicExpression | Aggregate<any>'.
  Type 'undefined' is not assignable to type 'RefProxy<any> | RefProxyFor<any> | BasicExpression | Aggregate<any>'.

50           inserted_at: thread.inserted_at
             ~~~~~~~~~~~

This may relate to #299.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions