Skip to content

Latest commit

 

History

History
109 lines (70 loc) · 89.1 KB

README.zh-CN.md

File metadata and controls

109 lines (70 loc) · 89.1 KB

TypeScript 类型体操姿势合集


English | 简体中文 | 日本語 | 한국어


介绍

众所周知,TypeScript 拥有一个图灵完备的类型系统

高质量的类型可以提高项目的可维护性并避免一些潜在的漏洞。市面上也已经有许多优秀的类型工具库,像是 ts-toolbelt, utility-types, SimplyTyped 等等。我们也从这些项目中获取了许多灵感。

本项目意在于让你更好的了解 TS 的类型系统,编写你自己的类型工具,或者只是单纯的享受挑战的乐趣!我们同时希望可以建立一个社区,在这里你可以提出你在实际环境中遇到的问题,或者帮助他人解答疑惑 - 这些问题也可能被选中成为题库的一部分!

题库

点击下方徽章查看题目内容

1
13・Hello World

13
4・实现 Pick 7・实现 Readonly 11・元组转换为对象 14・第一个元素 18・获取元组长度 43・Exclude 189・Awaited 268・If 533・Concat 898・Includes 3057・Push 3060・Unshift 3312・Parameters

80
2・获取函数返回类型 3・实现 Omit 8・Readonly 2 9・深度 Readonly 10・元组转合集 12・可串联构造器 15・最后一个元素 16・出堆 20・Promise.all 62・Type Lookup 106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 191・追加参数 296・Permutation 298・Length of String 459・Flatten 527・Append to object 529・Absolute 531・String to Union 599・Merge 612・KebabCase 645・Diff 949・AnyOf 1042・IsNever 1097・IsUnion 1130・ReplaceKeys 1367・Remove Index Signature 1978・Percentage Parser 2070・Drop Char 2257・MinusOne 2595・PickByType 2688・StartsWith 2693・EndsWith 2757・PartialByKeys 2759・RequiredByKeys 2793・Mutable 2852・OmitByType 2946・ObjectEntries 3062・Shift 3188・Tuple to Nested Object 3192・Reverse 3196・Flip Arguments 3243・FlattenDepth 3326・BEM style string 3376・InorderTraversal 4179・Flip 4182・斐波那契序列 4260・AllCombinations 4425・Greater Than 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 4803・Trim Right 5117・去除数组指定元素 5140・Trunc 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 5821・MapTypes 7544・Construct Tuple 8640・Number Range 8767・Combination 8987・Subsequence 9142・CheckRepeatedChars 9286・FirstUniqueCharIndex 9896・获取数组的中间元素 9898・找出目标数组中只出现过一次的元素 10969・整数 16259・将类型为字面类型(标签类型)的属性,转换为基本类型。 17973・DeepMutable 18142・All 18220・Filter 21106・组合键类型 Combination key type 25170・Replace First 25270・Transpose

45
6・简单的 Vue 类型 17・柯里化 1 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 112・Capitalize Words 114・CamelCase 147・C-printf Parser 213・Vue Basic Props 223・IsAny 270・Typed Get 300・String to Number 399・Tuple Filter 472・Tuple to Enum Object 545・printf 553・Deep object to unique 651・Length of String 2 730・Union to Tuple 847・String Join 956・DeepPick 1290・Pinia 1383・Camelize 2059・Drop String 2822・Split 2828・ClassPublicKeys 2857・IsRequiredKey 2949・ObjectFromEntries 4037・IsPalindrome 5181・Mutable Keys 5423・Intersection 6141・Binary to Decimal 7258・Object Key Paths 8804・两数之和 9155・ValidDate 9160・Assign 9384・Maximum 9775・Capitalize Nest Object Keys 13580・Replace Union 14080・FizzBuzz 14188・Run-length encoding 15260・Tree path array 19458・SnakeCase 25747・IsNegativeNumber

14
5・获取只读字段 151・Query String Parser 216・Slice 274・Integers Comparator 462・柯里化 2 476・Sum 517・Multiply 697・Tag 734・Inclusive Range 741・Sort 869・DistributeUnions 925・Assert Array Index 6228・JSON Parser 7561・Subtract

By Tags
#application12・可串联构造器 8767・Combination 6・简单的 Vue 类型 213・Vue Basic Props
#arguments191・追加参数 3196・Flip Arguments
#array14・第一个元素 533・Concat 898・Includes 3057・Push 3060・Unshift 15・最后一个元素 16・出堆 20・Promise.all 459・Flatten 949・AnyOf 3062・Shift 3243・FlattenDepth 4425・Greater Than 5153・IndexOf 5310・Join 5317・LastIndexOf 5360・Unique 8767・Combination 18142・All 18220・Filter 25270・Transpose 17・柯里化 1 2822・Split 5423・Intersection 8804・两数之和 9160・Assign 9384・Maximum 9775・Capitalize Nest Object Keys 14080・FizzBuzz 216・Slice 734・Inclusive Range 741・Sort 925・Assert Array Index
#built-in4・实现 Pick 7・实现 Readonly 43・Exclude 189・Awaited 3312・Parameters 2・获取函数返回类型 3・实现 Omit
#deep9・深度 Readonly 17973・DeepMutable 553・Deep object to unique 956・DeepPick
#filter18220・Filter
#infer3312・Parameters 2・获取函数返回类型 10・元组转合集 2070・Drop Char 4260・AllCombinations 55・Union to Intersection 57・Get Required 59・Get Optional 399・Tuple Filter 730・Union to Tuple 2059・Drop String 14080・FizzBuzz 734・Inclusive Range 741・Sort
#json6228・JSON Parser
#map62・Type Lookup 5821・MapTypes
#math529・Absolute 2257・MinusOne 25270・Transpose 6141・Binary to Decimal 8804・两数之和 14080・FizzBuzz 274・Integers Comparator 476・Sum 517・Multiply
#number25747・IsNegativeNumber
#object599・Merge 645・Diff 2595・PickByType 2757・PartialByKeys 2759・RequiredByKeys 2852・OmitByType 2946・ObjectEntries 3188・Tuple to Nested Object 3376・InorderTraversal 4179・Flip 5821・MapTypes 2949・ObjectFromEntries 9160・Assign 9775・Capitalize Nest Object Keys
#object-keys7・实现 Readonly 11・元组转换为对象 8・Readonly 2 9・深度 Readonly 527・Append to object 1130・ReplaceKeys 1367・Remove Index Signature 2793・Mutable 7258・Object Key Paths 5・获取只读字段
#promise189・Awaited 20・Promise.all
#readonly7・实现 Readonly 8・Readonly 2 9・深度 Readonly 2793・Mutable 17973・DeepMutable
#recursion1383・Camelize
#split2822・Split
#string531・String to Union 8767・Combination 9142・CheckRepeatedChars 9286・FirstUniqueCharIndex 2822・Split 4037・IsPalindrome 19458・SnakeCase
#template literal25747・IsNegativeNumber
#template-literal106・Trim Left 108・Trim 110・Capitalize 116・Replace 119・ReplaceAll 298・Length of String 529・Absolute 612・KebabCase 1978・Percentage Parser 2070・Drop Char 2688・StartsWith 2693・EndsWith 3326・BEM style string 4260・AllCombinations 4803・Trim Right 5140・Trunc 10969・整数 112・Capitalize Words 114・CamelCase 147・C-printf Parser 270・Typed Get 300・String to Number 472・Tuple to Enum Object 545・printf 651・Length of String 2 2059・Drop String 19458・SnakeCase 151・Query String Parser 274・Integers Comparator 476・Sum 517・Multiply 6228・JSON Parser
#this6・简单的 Vue 类型 1290・Pinia
#tuple18・获取元组长度 3312・Parameters 10・元组转合集 3188・Tuple to Nested Object 3192・Reverse 3326・BEM style string 4471・Zip 4484・IsTuple 4499・Chunk 4518・Fill 7544・Construct Tuple 399・Tuple Filter 472・Tuple to Enum Object 730・Union to Tuple 2822・Split 7561・Subtract
#union4・实现 Pick 43・Exclude 3・实现 Omit 10・元组转合集 62・Type Lookup 296・Permutation 531・String to Union 1042・IsNever 1097・IsUnion 3326・BEM style string 4260・AllCombinations 8987・Subsequence 9142・CheckRepeatedChars 730・Union to Tuple 1383・Camelize 5423・Intersection
#utils268・If 1042・IsNever 5821・MapTypes 55・Union to Intersection 57・Get Required 59・Get Optional 89・Required Keys 90・Optional Keys 223・IsAny 270・Typed Get 2828・ClassPublicKeys 2857・IsRequiredKey 5181・Mutable Keys 5・获取只读字段
#vue6・简单的 Vue 类型 213・Vue Basic Props 1290・Pinia
#数组5117・去除数组指定元素
#联合类型5117・去除数组指定元素
          

By Plain Text

热身 (1)

简单 (13)

中等 (80)

困难 (45)

地狱 (14)


即将到来的新题目

🔥 开始挑战 TypeScript Playground

⚡️ 开始挑战 VS Code

推荐读物

官方资源 (英文)

知乎专栏

文章(英文)

视频

项目 / 题解

书籍

参与贡献

你可以通过如下几种方式参与贡献这个项目

  • 分享你的答案或解题思路
  • 提案加入新的题目
  • 完善已有题目的测试用例
  • 提供针对题目的学习资料或方法
  • 分享你在真实项目中遇到的类型问题(无论你找到答案与否)- 大家会一起帮你找到解决的思路
  • 通过在 Issue 下留言帮助他人

开一个新的 Issue 并选择相应的模板即可,感谢参与!

💡 尽管你可以使用中文进行讨论,我们还是鼓励你尝试使用英文发起 Issue 与评论,这样可以让你的问题被更多人看到也可以帮助更多人。

感谢

这个项目诞生于 @hardfist@MeCKodo 两位朋友做的类型体操。同时也非常感谢 @sinoon 在项目初期提供了宝贵的反馈意见与参与的贡献。

Contributors

License

MIT