• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fxss5201 / fxss-leetcode / 14559966275

20 Apr 2025 01:30PM UTC coverage: 96.345% (-0.04%) from 96.385%
14559966275

push

github

fxss5201
feat: 增加 14. 第一个元素、18. 获取元组长度、43. 实现 Exclude

1014 of 1091 branches covered (92.94%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

3652 of 3752 relevant lines covered (97.33%)

6.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/type-challenges/tupleToObject/index.ts
1
// 11. 元组转换为对象:https://tsch.js.org/11/zh-CN
2
import type { Equal, Expect } from '@type-challenges/utils'
3

4
// 你的代码
5
type TupleToObject<T extends readonly PropertyKey[]> = {
6
  [K in T[number]]: K
7
}
8

9
// 测试用例
10
const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const
×
11
const tupleNumber = [1, 2, 3, 4] as const
×
12
const sym1 = Symbol(1)
×
13
const sym2 = Symbol(2)
×
14
const tupleSymbol = [sym1, sym2] as const
×
15
const tupleMix = [1, '2', 3, '4', sym1] as const
×
16

17
type cases = [
18
  Expect<Equal<TupleToObject<typeof tuple>, { 'tesla': 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y' }>>,
19
  Expect<Equal<TupleToObject<typeof tupleNumber>, { 1: 1, 2: 2, 3: 3, 4: 4 }>>,
20
  Expect<Equal<TupleToObject<typeof tupleSymbol>, { [sym1]: typeof sym1, [sym2]: typeof sym2 }>>,
21
  Expect<Equal<TupleToObject<typeof tupleMix>, { 1: 1, '2': '2', 3: 3, '4': '4', [sym1]: typeof sym1 }>>,
22
]
23

24
// @ts-expect-error
25
type error = TupleToObject<[[1, 2], {}]>
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc