00018-easy-tuple-length

Back

type Length<T extends readonly any[]> = T extends readonly [...infer U] ? U['length'] : never

Solution by notsecret32 #33610

type Length<T extends readonly any[]> = T['length']
// T가 튜플이라고 명시했으므로, length 속성에 직접 접근해서 갯수 찾기.

Solution by kukjun #33587

type Length<T extends readonly any[]> = T["length"]

Solution by Kolufs #33520

type Length<T extends readonly any[]> = T['length']

Solution by brown2243 #33465

// 你的答案

// ============= Your Code Here =============
type Length<T extends readonly any[]> = T['length']

Solution by EurYellow #33427

// 你的答案
type Length<T extends readonly any[]> = T['length']

Solution by chenjieya #33397

type Length<T extends readonly any[]> = T extends { length: infer L }  ?  L : never;

Solution by adultlee #33338

// 여기 풀이를 입력하세요
type Length<T extends readonly unknown[]> = T['length'];

Solution by awesomelon #33323

type Length<T extends readonly any[]> = T['length']

Solution by Skytim #33291

type Length<T> = T extends { length : infer R } ? R : never;

Solution by daishi-motoyama #33281

type Length<T extends readonly any[]> = T extends {length:infer L} ?L:never

Solution by mrchenxiao #33217

type Length<T extends readonly any[]> = T extends {length:infer L} ?L:never

Solution by mrchenxiao #33215

type Length<T extends readonly any[]> = T["length"];

Below is a solution document related to the problem in Korean. 아래는 한국어로 된 해당 문제 관련 풀이 문서입니다.

https://github.com/hanseulhee/studying/blob/master/TypeScript/Challenges/README.md#18%EB%B2%88

Solution by hanseulhee #33211

type Length<T extends readonly (string | number)[]> = T['length'];

Solution by seoksanghwan #33161

type Length<T extends {length:number}> = T['length']

Solution by loevray #33145

// your answers

Solution by lehach85 #33071

type Length<T extends readonly string[]> = T['length']

Solution by RanungPark #33036

// 你的答案

type Length<T extends readonly any[]> = T['length']

Solution by DwayneDuanJY #33007

// your answers
type Length<T extends readonly any[]> = T["length"]

Solution by sciencefunq #32912

type Length<T extends readonly any[]> = T['length']

Solution by high-g #32895

type Length<T extends readonly any[]> = T['length'];

Solution by ZhipengYang0605 #32786

type Length<T extends readonly any[]> = T["length"];

Solution by Yasunori-aloha #32664

type Length<T extends string[]> = T['length']

Solution by jitendra-huma #32655

type Length<T> = T extends {length: infer L} ? L : never;

Solution by mistkafka #32601

type Length<T extends readonly any[]> = T['length'];

Solution by pouqwyggad #32581

 type tesla = ['tesla', 'model 3', 'model X', 'model Y']
type spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT']

type teslaLength = Length<tesla> // expected 4
type spaceXLength = Length<spaceX> // expected 5

type Length<T extends readonly any[]> = T['length']

Solution by sugar258596 #32542

type Length<T extends readonly any[]> = T['length']

Solution by jcyicai #32431

// 你的答案
type Length<T> = T extends readonly any[] ? T['length'] : never

Solution by DOIT008 #32390

// your answers

type tesla = ['tesla', 'model 3', 'model X', 'model Y']
type spaceX = ['FALCON 9', 'FALCON HEAVY', 'DRAGON', 'STARSHIP', 'HUMAN SPACEFLIGHT']

type LengthOfTuple<T extends readonly any[]> = T["length"]

type teslaLength = LengthOfTuple<tesla> // expected 4
type spaceXLength = LengthOfTuple<spaceX> // expected 5

Solution by laqudee #32349

type Length<T extends readonly any[]> = T['length'];

Solution by koh1260 #32185