Skip to content

Latest commit

 

History

History
15 lines (9 loc) · 2.91 KB

File metadata and controls

15 lines (9 loc) · 2.91 KB

元组转换为对象 简单

by sinoon @sinoon

接受挑战    English 日本語 한국어

欢迎 PR 改进翻译质量。

传入一个元组类型,将这个元组类型转换为对象类型,这个对象类型的键/值都是从元组中遍历出来。

例如:

const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const

type result = TupleToObject<typeof tuple> // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'}

返回首页 分享你的解答 查看解答

相关挑战

10・元组转合集 472・Tuple to Enum Object 730・Union to Tuple 3188・Tuple to Nested Object