学习记录 - 获取元素长度 - 对于给定的元组,您需要创建一个通用的Length,选择元组的长度题目简介对于给定的元组,您需要创建一个通用的Length,选择元组的长度例如type tesla = ['tesla', 'model 3', 'model X', 'model Y']
type spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT']
type teslaLength = Length// expected 4
type spaceXLength = Length// expected 5测试用例import { Equal, Expect } from '@type-challenges/utils'
const tesla = ['tesla', 'model 3', 'model X', 'model Y'] as const
const spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT'] as const
type cases = [
Expect, 4>>,
Expect, 5>>,
]答案type Length= T extends
...
继续阅读
(103)