Skip to content

[FEATURE]: stronger conditional typing for and and or operators #4259

@extradosages

Description

@extradosages

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

A trivial change to the type overloading declarations of the and and or operators used for constructing filters can improve type inference.

See their definitions here.

Note that they return a union SQL | undefined to account for the fact that when the list of clauses being provided are empty the operators return undefined which plugs into drizzle's conditional filtering api (as a separate note, I believe that this is not consistent with conventional logical interpretations of empty disjunctions: undefined seems to indicate that no filter is being applied, whereas an empty disjunction is conventionally equivalent to falsehood, which might be interpreted as everything being filtered out...). There are circumstances when this type can be determined to be narrower, such as when it is known that the list of clauses is non-empty. I suggest that we overload these operators to account for that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions