type Push<T extends unknown[], P> = [...T, P]
Solution by ClarityOfMind #35002
type Push<T extends any[], U> = [...T, U];
Solution by raeyoung-kim #34945
type Push<T extends any[], U> = T extends never[] ? [U] : [...T, U] // your answers
Solution by 56aiden90 #34882
type Push<T extends any[], U> = [...T, U]
Solution by eunsukimme #34816
type Push<T, U> = T extends Array<unknown> ? [...T, U] :never
Solution by Yuriy113 #34735
// your answers
type Push<T extends any[], U> = [...T, U];
Solution by zeyuanHong0 #34721
type Push<T extends any[], U> = [...T,U]
Solution by lephuthuc2001 #34709
type Push<T extends readonly any[], U> = [...T, U]
Solution by Git-I985 #34705
type Push<T, U> = T extends any[] ? [...T, U] : [U]
Solution by nathan2slime #34663
type Push<T extends readonly unknown[], U> = [...T,U]
Solution by devshinthant #34549
type Push<T extends unknown[], U> = [...T, U]
Solution by binhdv155127 #34473
// ์ฌ๊ธฐ ํ์ด๋ฅผ ์
๋ ฅํ์ธ์
type Push<T extends readonly unknown[], U> = [...T, U];
Solution by LeeKangHyun #34464
type Push<T extends readonly any[], U> = [...T, U];
Solution by ktim816 #34428
// your answers
type Push<T extends any[],U> = [...T, U]
Solution by gobielJonathan #34399
type Push<T extends any[], U> = [...T, U]
Solution by bkdragon0228 #34385
type Push<T extends any[], U> = [...T, U]
Solution by rookie-luochao #34364
Just use a spread operator.
// your answers
type Push<T extends any[], U> = [...T, U]
Solution by dev-jaemin #34330
type Push<T extends any[], U> = [...T, U];
Solution by wxh-cyber #34323
type Push<Xs extends unknown[], X extends unknown> = [...Xs, X];
Solution by souzaramon #34270
type Push<T extends any[], U> = [...T, U]
Solution by quitone #34197
Array.push
์ ์ ๋ค๋ฆญ ๋ฒ์ ์ ๊ตฌํํ์ธ์.
์์:
type Result = Push<[1, 2], "3">; // [1, 2, '3']
์ด ๋ํ ์ด๋ ค์ด ๋ฌธ์ ๋ ์๋์์ต๋๋ค. ๋ฌธ์ ์ค ํ๋์ธ, unshift ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ค๋ฉด, ๋์์ ํด๊ฒฐํ ์ ์๋ ๋ฌธ์ ์์ต๋๋ค.
/* _____________ ์ฌ๊ธฐ์ ์ฝ๋ ์
๋ ฅ _____________ */
type Push<T extends any[], U> = [...T, U];
/* _____________ ํ
์คํธ ์ผ์ด์ค _____________ */
import type { Equal, Expect } from "@type-challenges/utils";
type cases = [
Expect<Equal<Push<[], 1>, [1]>>,
Expect<Equal<Push<[1, 2], "3">, [1, 2, "3"]>>,
Expect<Equal<Push<["1", 2, "3"], boolean>, ["1", 2, "3", boolean]>>
];
Solution by adultlee #34116
type Push<T extends any[], U extends any> = [...T, U];
Solution by ProvorovOleksii #34083
type Push<T extends unknown[], U> = [...T, U];
Solution by ouzexi #33972
type Push<T extends unknown[], U> = [...T,U]
Solution by hyojinLee-git #33946
type Push<T extends unknown[], U> = [...T, U]
Solution by notsecret32 #33864
type Push<T extends any[], U> = [...T, U]
Solution by okasyun #33834
type Push<T extends any[], U> = [...T, U]
concatใฎๅ้กใฎๅฟ็จใง่งฃใใใ
Tๅใซๅฏพใใฆextends any[]
ใๅฎฃ่จใใชใใจ...T
ใใจใฉใผใซใชใใ
Solution by okabe-yuya #33826
type Push<T extends unknown[], U> = [...T, U]
Solution by veralex #33757
type Push<T extends Array<unknown>, K> = [...T, K]
Solution by Danny101201 #33739