Skip to content

feat: better select type #12598

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kristian240
Copy link
Contributor

@kristian240 kristian240 commented May 28, 2025

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 kristian240 changed the title Better select type feat: better select type May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant