This solution is generated by ChatGPT, correctness is not guaranteed. You might also be able to find a solution fromcommunity posts.
AI solution for TypeScript puzzle on BFE.dev
31. implement Push<T, I>
type Push<T extends any[], I> = [...T, I];type A = Push<[1, 2, 3], 4>; // [1, 2, 3, 4]type B = Push<[1], 2>; // [1, 2]type C = Push<[], string>; // [string]
Note: In the examples given in the question, the expected output seems to be incorrect. The expected output for type A
should be [1, 2, 3, 4]
. Similarly, the expected output for type C
should be [string]
.