• 2023-05-04TypeScript 学习笔记 — 模板字符串和类型体操(十五)
    目录基本介绍字符串类型体操实操环节1.字符串首字母大写CapitalizeString2.获取字符串第一个字符FirstChar3.获取字符串最后一个字符LastChar4.字符串转元组StringToTuple5.元组转字符串TupleToString6.重复字符串RepeatString7.字符串分割SplitString8.获取字符串
  • 2023-04-26类型体操-Tuple to Object
    刷类型体操时,问题的记录及收获TupletoObjectconsttuple=['tesla','model3','modelX','modelY']asconsttyperesult=TupleToObject<typeoftuple>//expected{'tesla':'tesla','model3�
  • 2023-04-16ts类型体操Concat
    /*533-Concat-------byAndreyKrasovsky(@bre30kra69cs)#easy#array###QuestionImplementtheJavaScript`Array.concat`functioninthetypesystem.Atypetakesthetwoarguments.Theoutputshouldbeanewarraythatincludesinputsin
  • 2023-04-16ts类型体操 Awaited
    /*189-Awaited-------byMaciejSikora(@maciejsikora)#easy#promise#built-in###QuestionIfwehaveatypewhichiswrappedtypelikePromise.Howwecangetatypewhichisinsidethewrappedtype?Forexample:ifwehave`Promise&l
  • 2022-12-18Typescript类型体操 - Combination
    题目中文给定一个字符串数组,实现它的全排列组合.EnglishGivenanarrayofstrings,doPermutation&Combination.It'salsousefulfortheproptypeslikevid
  • 2022-11-12Typescript类型体操 - Unique
    题目中文实现类型的Lodash.uniq,Unique接受数组T,返回没有重复值的数组TEnglishImplementthetypeversionofLodash.uniq,UniquetakesanArrayT,returns
  • 2022-11-12Typescript类型体操 - LastIndexOf
    题目中文实现类型的Array.lastIndexOf,LastIndexOf<T,U>接受泛型参数ArrayT和anyU并返回数组T中最后一个U的索引示例:typeRes1=LastIndexOf<[1,2,3
  • 2022-11-08Typescript类型体操 - Join
    题目中文实现类型版本的Array.join,Join<T,U>接受数组T和string或者number类型U作为泛型参数,并返回U连接数组T后的字符串.EnglishImplementthetyp
  • 2022-10-25Typescrip类型体操 - IndexOf
    题目中文实现类型版本的Array.indexOf,indexOf<T,U>接受一个数组T和any类型的U作为参数,返回T中第一个U的索引typeRes=IndexOf<[1,2,3],2>;//expectedto
  • 2022-10-24Typescript类型体操 - Trunc
    题目中文实现类型版本的Math.trunc,其接受一个字符串或数字作为泛型参数,并返回移除了全部小数位部分后的整数示例:typeA=Trunc<12.34>;//12EnglishImpleme
  • 2022-10-24Typescript类型体操 - TrimRight
    题目中文实现TrimRight<T>,它接收确定的字符串类型并返回一个新的字符串,其中新返回的字符串删除了原字符串结尾的空白字符串。例如typeTrimed=TrimRight<'Hello
  • 2022-10-24Typescript类型体操 - Fill
    题目中文Fill是javascript中常用的方法,现在让我实现类型版本的FillFill<T,N,Start?,End?>,正如你看到的那样,Fill接受四个泛型参数,其中T和N是必填参数,
  • 2022-10-23Typescript类型体操 - Chunk
    题目中文你知道lodash吗?lodash中有一个非常实用的方法Chunk,让我们实现它吧.Chunk<T,N>接受两个泛型参数,其中T是tuple类型,N是大于1的数字typeexp1=
  • 2022-10-23Typescript类型体操 - GreaterThan
    题目中文在本挑战中,你需要实现GreaterThan<T,U>,它的作用像T>U你不需要考虑负数示例:GreaterThan<2,1>//shouldbetrueGreaterThan<
  • 2022-10-02Typescript类型体操 - Flip
    题目中文实现一个just-flip-object类型示例:Flip<{a:'x';b:'y';c:'z'}>;//{x:'a',y:'b',z:'c'}Flip<{a:1;b:2;c:3}>;//{1:'a',2:'b',3:
  • 2022-10-02Typescript类型体操 - FibonacciSequence
    题目中文实现一个输入参数为数字T的泛型类型Fibonacci<T>,返回T对应的斐波那契数斐波那契数列:1,1,2,3,5,8,13,21,34,55,89,144,...示例:typeRes
  • 2022-09-24Typescript类型体操 - FlattenDepth
    题目中文递归将数组展开到指定的深度示例:typea=FlattenDepth<[1,2,[3,4],[[[5]]]],2>;//[1,2,3,4,[5]].flattern2timestypeb=FlattenDepth<[1,
  • 2022-09-24Typescripe类型体操 - FlipArguments
    题目中文实现lodash中_.flip方法的类型版本FlipArguments<T>类型接收泛型参数T并返回一个函数类型,且此函数类型有和T相同的返回类型但其参数的顺序是倒过来的E
  • 2022-09-23Typescript类型体操 - Reverse
    题目中文实现类型版本的数组反转Array.reverse例如:typea=Reverse<['a','b']>;//['b','a']typeb=Reverse<['a','b','c']>;//['c','b','a']English
  • 2022-09-22Typescript类型体操 - TupleToNestedObject
    题目中文给定一个只包含字符串类型的元组类型T和一个类型U,递归地构建一个对象.EnglishGivenatupletypeTthatonlycontainsstringtype,andatypeU,build
  • 2022-09-22Typescript类型体操 - ObjectEntries
    题目中文实现Object.entries的类型版本示例:interfaceModel{name:string;age:number;locations:string[]|null;}typemodelEntries=Objec
  • 2022-09-22Typescript类型体操 - Mutable
    题目中文实现一个通用的类型Mutable<T>,使类型T的全部属性可变(非只读)。例如:interfaceTodo{readonlytitle:string;readonlydescription:string;
  • 2022-09-21Typescript类型体操 - PartialRequired
    题目中文实现一个通用的RequiredByKeys<T,K>,它接收两个类型参数T和K。K指定应设为必选的T的属性集。当没有提供K时,它就和普通的Required<T>一样使所有的属性成为必选的
  • 2022-09-21Typescript类型体操 - EndsWith
    题目中文实现EndsWith<T,U>,接收两个string类型参数,然后判断T是否以U结尾,根据结果返回true或false例如:typea=EndsWith<'abc','bc'>;//expectedtobefals
  • 2022-09-21Typescript类型体操 - StartsWith
    题目中文实现StartsWith<T,U>,接收两个string类型参数,然后判断T是否以U开头,根据结果返回true或false例如:typea=StartsWith<'abc','ac'>;//expectedtobe