00533-easy-concat

Back

type Concat<T extends Array<unknown> | ReadonlyArray<unknown>, U extends Array<unknown> | ReadonlyArray<unknown>> = [...T, ...U]

Solution by gangnamssal #35486

type Concat<T extends readonly (PropertyKey| boolean)[], U extends readonly (PropertyKey| boolean)[]> =  [...T, ...U]

Solution by RanungPark #35438

// your answers

type Result<T extends unknown[], K extends unknown[]> = [...T, ...K];

const slicedData: Result<[1], [2]> = [1, 2];

Solution by Sathiyapramod #35416

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

Solution by sesolaga #35393

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

Solution by gyeounjeong #35359

// 你的答案
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