首页 > 其他分享 >[Typescript] 75. Easy - Push

[Typescript] 75. Easy - Push

时间:2022-10-29 03:22:50浏览次数:53  
标签:Typescript _____________ 75 Expect Easy Push type

Implement the generic version of Array.push

For example:

type Result = Push<[1, 2], '3'> // [1, 2, '3']

 

/* _____________ Your Code Here _____________ */

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


/* _____________ 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]>>,
]

 

标签:Typescript,_____________,75,Expect,Easy,Push,type
From: https://www.cnblogs.com/Answer1215/p/16837963.html

相关文章

  • [Typescript] 77. Easy - Unshift
    Implementthetypeversionof Array.unshiftForexample:typeResult=Unshift<[1,2],0>//[0,1,2,] /*_____________YourCodeHere_____________*/t......
  • [Typescript] 76. Easy - Parameters
    Implementthebuilt-inParametersgenericwithoutusingit.Forexample:constfoo=(arg1:string,arg2:number):void=>{}typeFunctionParamsType=MyPara......
  • 洛谷P5759题解
    本文摘自本人洛谷博客,原文章地址:https://www.luogu.com.cn/blog/cjtb666anran/solution-p5759\[这道题重在理解题意\]选手编号依次为:\(1,2...N\)(\(N\)为参赛总人数)。......
  • CF1675G
    首先,可以感性地发现移动小球时出现负值不会影响最终答案,只要最终方案是非负的就行了。所以,我们不妨规定,一个箱子只能从右边一个箱子拿小球,或者向右边一个箱子放小球。设......
  • [Typescript] 74. Medium - LastIndexOf
    Implementthetypeversionof Array.lastIndexOf, LastIndexOf<T,U> takesanArray T,any U andreturnstheindexofthelast U inArray TForexample:......
  • plus.push.getClientInfo()
    https://blog.csdn.net/qq_39410252/article/details/116053737https://blog.csdn.net/u011200562/article/details/118091156......
  • JavaScript数组的push()等方法的使用
        数组是值得有序集合。每个值在数组中有一个位置,用数字表示,叫做索引。JavaScript数组是无类型的:数组元素可以是任何类型,而且同一个数组中可以存在不同类型元素,甚......
  • git push 出现 OpenSSL SSL_read: Connection was aborted, errno 10053报错
    gitpush出现OpenSSLSSL_read:Connectionwasaborted,errno10053报错    原因:git默认的缓存区太小了,增加缓冲器。gitconfig--globalhttp.postBuff......
  • LeetCode_Array_75. Sort Colors 颜色分类 (C++)
    目录​​1,题目描述​​​​2,思路​​​​3,代码【C++】​​1,题目描述Givenanarraywithnobjectscoloredred,whiteorblue,sortthemin-placesothatobjectsoft......
  • CF1754 题解
    比赛链接:https://codeforces.com/contest/1754题解:AB水题//bySkyRainWind#include<cstdio>#include<vector>#include<cstring>#include<iostream>#include......