We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
type TupleToObject<T extends readonly any[]> = {[P in T[number]]: P} /* _____________ Test Cases _____________ */ import type { Equal, Expect } from '@type-challenges/utils' const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const const tupleNumber = [1, 2, 3, 4] as const const sym1 = Symbol(1) const sym2 = Symbol(2) const tupleSymbol = [sym1, sym2] as const const tupleMix = [1, '2', 3, '4', sym1] as const type cases = [ Expect<Equal<TupleToObject<typeof tuple>, { 'tesla': 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y' }>>, Expect<Equal<TupleToObject<typeof tupleNumber>, { 1: 1, 2: 2, 3: 3, 4: 4 }>>, Expect<Equal<TupleToObject<typeof tupleSymbol>, { [sym1]: typeof sym1, [sym2]: typeof sym2 }>>, Expect<Equal<TupleToObject<typeof tupleMix>, { 1: 1, '2': '2', 3: 3, '4': '4', [sym1]: typeof sym1 }>>, ]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: