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

Proposal: ValueOf -- gets the types of values in a hash. #36

Open
fbartho opened this issue Apr 30, 2019 · 5 comments
Open

Proposal: ValueOf -- gets the types of values in a hash. #36

fbartho opened this issue Apr 30, 2019 · 5 comments

Comments

@fbartho
Copy link
Contributor

fbartho commented Apr 30, 2019

Prior Art: https://stackoverflow.com/questions/49285864/is-there-a-valueof-similar-to-keyof-in-typescript

@pelotom
Copy link
Owner

pelotom commented Apr 30, 2019

Are you talking about this?

type ValueOf<T> = T[keyof T];

That seems too simple to be worth including.

@fbartho
Copy link
Contributor Author

fbartho commented Apr 30, 2019

It seems like it, but it's not that obvious a construct -- I went looking for it :P

@ssonne
Copy link
Contributor

ssonne commented Apr 30, 2019

There's value in naming constructs like this even if they're simple: the name captures the intent, which may not otherwise be obvious to future readers (especially if the semantics of the language change subtly).

@fbartho
Copy link
Contributor Author

fbartho commented Apr 30, 2019

Not to bike shed on the naming, but maybe we should call it ValuesOf since what it's making is a type that combines any value in the hash?

@pelotom
Copy link
Owner

pelotom commented May 2, 2019

Ok, well if it’s of value to you I’m happy to add it, PR welcome!

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

3 participants