Skip to content

How and where to add some utility types #55301

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

Closed
1 task done
Daggron opened this issue Aug 8, 2023 · 4 comments
Closed
1 task done

How and where to add some utility types #55301

Daggron opened this issue Aug 8, 2023 · 4 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@Daggron
Copy link

Daggron commented Aug 8, 2023

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

I just want to ask few questions w.r.t utility types in typescript

Right now whenever we have to get a union of object values we have to do something like this

const stages = {
   LOADING : 'LOADING'
   ERROR: 'ERROR'
   SUCCESS: 'SUCCESS'
} as const 

type Stages = typeof stages[keyof typeof stages]

this becomes redundant in code base and can be improved with utility types for e.g.

type ObjectValues<T extends Record<any, any>> =  T[keyof T];

Willing to add this as a utility type provided by TS, but stuck on where to add this es5.d.ts is one place where I can write it but not sure if thats the correct place and do I need to add it somewhere else or not.

@MartinJohns
Copy link
Contributor

Nowhere. See #39522 (comment):

We've opted to not include utility type aliases in the lib unless they're required for declaration emit purposes.

@Daggron
Copy link
Author

Daggron commented Aug 8, 2023

Nowhere. See #39522 (comment):

We've opted to not include utility type aliases in the lib unless they're required for declaration emit purposes.

Lol, time to create my own utility library then 😂

@MartinJohns
Copy link
Contributor

You're free to do so. Or use one of the many many out there.

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Aug 8, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants