payload icon indicating copy to clipboard operation
payload copied to clipboard

feat: better select type

Open kristian240 opened this issue 8 months ago • 0 comments

What?

Add type support for return value when select is used. Instead of returning the string | Relation in to-one relations and (string | Relation)[] not proper type is returned - Relation or Relation[] for cases when the relation is explicitly selected.

NOTE1: string can be replaced with number, depends on the IDs you use in your app NOTE2: Relation is a collection type

Why?

Because it is frustrating working with union types when you know that in runtime you will have this typing

How?

I have expanded TransformDataWithSelect type.

Type checking is done using a type utils Equal that resolves to true if types are same and false otherwise. We type a variable with this and assign true to a variable. If type resolves to false you get an error.

Should I add type checks in every test case?

Future works?

  1. We should add same support for depth.
  2. Add support for nested selects?

kristian240 avatar May 28 '25 21:05 kristian240