Tuple to Object #8443
Unanswered
michaeljsalo
asked this question in
Q&A
Tuple to Object
#8443
Replies: 2 comments
-
I hope document will help you. |
Beta Was this translation helpful? Give feedback.
0 replies
-
If T is an object type containing only string keys and string values, you can make use of T[string], which is a form of indexed access type! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The solutions for 'Tuple to Object' problem apply a type map that looks like this:
[key in T[number]]: key
I understand how the mapping works, but what I didn't know about is T[number]. Is there TypeScript documentation that explains the T[number] expression for arrays.
Also, would object types have an equivalent expression? If T was an object type with string keys and string values, does this mean I could use T[string] to get a union of all the strings?
Beta Was this translation helpful? Give feedback.
All reactions