00533-easy-concat

Back

// 你的答案
type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]
// or
type Concat<T extends ReadonlyArray<any>, U extends ReadonlyArray<any>> = [...T, ...U]

Solution by HoseaGuo #35130

// 你的答案

type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [...T, ...U]

Solution by hexingdagmail #35050

type Tuple = readonly unknown[]
type Concat<T extends Tuple, P extends Tuple> = [...T, ...P]

Solution by ClarityOfMind #34992

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by huabingjenny #34981

type Concat<T extends any[], U extends any[]> = [...T, ...U];

Solution by raeyoung-kim #34941

type Concat<T extends ReadonlyArray<any>, U extends ReadonlyArray<any>> = [...T, ...U]

Solution by 56aiden90 #34881

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by floatDreamWithSong #34870

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by nguyste #34856

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by eunsukimme #34814

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by kang-kibong #34747

type Concat<T extends any[]|readonly any[], U extends any[]|readonly any[]> = [...T,...U];

Solution by lephuthuc2001 #34712

// your answers
type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [ ...T, ...U ];

Solution by zeyuanHong0 #34707

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]
image

Solution by Git-I985 #34704

type Concat<T, U> = T extends readonly any[] ? U extends readonly any[] ? [...T, ...U] : never : never

Solution by nathan2slime #34661

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by Hailey0930 #34637

type Concat<T extends readonly unknown[], U extends  readonly unknown[]> = [...T,...U]

Solution by devshinthant #34547

// your answers

Solution by devshinthant #34546

// 여기 풀이를 입력하세요
type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [...T, ...U];

Solution by LeeKangHyun #34462

type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [...T, ...U]

// Note that: readonly is only permitted on array and tuple literal types ⇒ it means that it doesn’t work with generic like Array<unknown>

Solution by binhdv155127 #34443

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U];

Solution by ktim816 #34425

// your answers
type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by gobielJonathan #34398

type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [...T, ...U]

Solution by rookie-luochao #34360

type Concat<P, Q> = [
  ...P extends any[] ? P : [P],
  ...Q extends any[] ? Q : [Q],
]

考虑到P,Q可能不一定是数组类型(元组是特殊的数组类型),因此将any[]的写法从泛型中提取出来,分别对应到P和Q中。

Solution by wxh-cyber #34346

We just use the spread Operator. But we should check T and U extends readonly unknown[] because of [...] as const inputs.

type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [...T, ...U]

Solution by dev-jaemin #34329

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]; 

注意,如果没有加入readonly,在处理元组类型时会报错。

Solution by wxh-cyber #34324

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by bkdragon0228 #34321

type Concat<
  A extends unknown[],
  B extends unknown[]
> = [...A, ...B]

Solution by souzaramon #34268

// 你的答案

type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [...T,...U]

Solution by W-fitTiger #34248

// 你的答案
type Concat<T extends readonly any[], U extends readonly any[]> = [...T,...U]

Solution by Hadias94 #34216

type Concat<T extends readonly any[], U extends readonly any[]> = [...T, ...U]

Solution by quitone #34194