Skip to content
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

Paths<T> should handle recursive types #879

Open
Xriuk opened this issue May 15, 2024 · 0 comments
Open

Paths<T> should handle recursive types #879

Xriuk opened this issue May 15, 2024 · 0 comments
Assignees

Comments

@Xriuk
Copy link

Xriuk commented May 15, 2024

Currently Paths<T> does not handle types like this (translation of some backend DB entities):

type MyEntity ={
   myOtherEntity: MyOtherEntity;
    ...
}

type MyOtherEntity ={
    myEntity: MyEntity;
    ...
}

type MyEntityPaths = Paths<MyEntity>;

TS gives an error like this:
The type of property ... circularly references itself in mapped type ...

The main issue here would be determining if any given type recurses, which would require comparing already entered types (which afaik is unfeasible).
A possible solution would be adding an optional "hard limit" of depth parameter, which won't go beyond N levels deep. In this case also types using Paths<T> like PickDeep should include this parameter and forward it to Paths<T>.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@Emiyaaaaa Emiyaaaaa self-assigned this May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants