Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I improve type readability? #88

Closed
ctrlplusb opened this issue Jan 23, 2020 · 4 comments
Closed

How can I improve type readability? #88

ctrlplusb opened this issue Jan 23, 2020 · 4 comments
Assignees
Labels
question More info is requested wiki It's nice to learn stuff wontfix This will not be worked on
Projects

Comments

@ctrlplusb
Copy link

Hi @pirix-gh

Hope you are doing well. Good to see that ts-toolbelt is continuing to grow. 馃挏

A quick question for yourself...

Is there any mechanism by which I could improve the legibility of the types generated when using the ts-toolbelt types.

For example, when using combinations of Pick, Filter, Select on an object type the generated type becomes realllllly long.

Could I compact this out in some manner to improve the legibility?

@ctrlplusb ctrlplusb changed the title Improve readability of types [Question] Improve readability of types Jan 23, 2020
@millsp millsp self-assigned this Jan 23, 2020
@millsp millsp added the question More info is requested label Jan 23, 2020
@millsp millsp added this to To do in Board via automation Jan 23, 2020
@millsp
Copy link
Owner

millsp commented Jan 23, 2020

Hey Sean, glad to see you again, happy new year!

Are you having this issue when using generics?
If this is not the case, would you mind providing with an example, repo link?

In this case, we can mitigate it like this:

type _Example<O extends object> = 
    O.Filter<O.Select<O, string | number>, 1 | 2 | 3> extends infer X ? X : never

This will cause ts not to expand the types too far. Then on my side I can work on improving this, so that you can get even shorter types.

@millsp
Copy link
Owner

millsp commented Jan 24, 2020

@ctrlplusb did this help you? Can I close this issue?

@ctrlplusb
Copy link
Author

Sorry, been distracted. Will give this a thorough test soon. We can close it in the interim if you like. I'll report back if it doesn't work as expected. 馃憤

@millsp millsp changed the title [Question] Improve readability of types How can I improve type readability? Jan 27, 2020
@millsp millsp added the wiki It's nice to learn stuff label Jan 27, 2020
@stale
Copy link

stale bot commented Mar 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 27, 2020
Board automation moved this from To do to Done Apr 1, 2020
Repository owner locked and limited conversation to collaborators Feb 2, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question More info is requested wiki It's nice to learn stuff wontfix This will not be worked on
Projects
Board
  
Done
Development

No branches or pull requests

2 participants