跳至主要內容

3057. Push

鸭梨小于 1 分钟

3057. Push

<题目描述>

::: playground#ts 3057. Push

@file index.ts

// ============= Test Cases =============
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]>>,
]

// ============= Your Code Here =============
type Push<T, U> = any

:::

点击查看答案
type Push<T extends any[], U> = [...T, U]