00533-easy-concat

Back

// 你的答案

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

Solution by 180ParkerLi #36923

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

Solution by AlexBraunMagic #36914

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

Solution by shaishabcoding #36846

type Result = Concat<[1], [2]> // expected to be [1, 2]
// 你的答案
type Concat<T extends readonly any[], U extends readonly any[]> = [...T,...U]

Solution by mola-fish #36833

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

/* _____________ Test Cases _____________ */
import type { Equal, Expect } from '@type-challenges/utils'

const tuple = [1] as const

type cases = [
  Expect<Equal<Concat<[], []>, []>>,
  Expect<Equal<Concat<[], [1]>, [1]>>,
  Expect<Equal<Concat<typeof tuple, typeof tuple>, [1, 1]>>,
  Expect<Equal<Concat<[1, 2], [3, 4]>, [1, 2, 3, 4]>>,
  Expect<Equal<Concat<['1', 2, '3'], [false, boolean, '4']>, ['1', 2, '3', false, boolean, '4']>>,
]

// @ts-expect-error
type error = Concat<null, undefined>

Solution by AnastasiaSv #36766

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

Solution by Abdullah-Elsayed01 #36752

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

Solution by tungulin #36717

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

Solution by Mamdouhreda #36709

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

Solution by seungdeok #36667

type Tuple = typeof tuple | any[]
type Concat<T extends Tuple, U  extends Tuple> = [...T, ...U]

Solution by wiJeeXu #36650

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

Solution by MrSissel #36585

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

Solution by ChemieAi #36554

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

Solution by shumik323 #36500

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

Solution by uuimorty #36464

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

Solution by alirezaprime #36415

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

Solution by EvgeniyKoch #36391

type Concat<T, U> = [...T, ...U]

Solution by Divcutu #36369

// your answers
type Concat<T extends readonly any[], U extends readonly any[]> = 
[...T, ...U] extends infer Y ? Y : never; 

Solution by justBadProgrammer #36365

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

Solution by HelloWook #36343

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

Solution by 1Alex4949031 #36313

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

Solution by EvgeniyKoch #36300

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

"unknown is safer than any"

Solution by asylbekduldiev #36282

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

Solution by Maxim-Do #36228

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

Solution by tungulin #36156


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

Solution by AleksandrShcherbackov #36146

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

Solution by buglavecz #36090

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

Solution by karazyabko #36030

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

Solution by reonce #36012

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

Solution by chen8840 #35950

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

Solution by codingaring #35940