Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lvjiaxuan/type-challenges
Org: https://github.com/type-challenges/type-challenges
https://github.com/lvjiaxuan/type-challenges
type typescript
Last synced: about 1 month ago
JSON representation
Org: https://github.com/type-challenges/type-challenges
- Host: GitHub
- URL: https://github.com/lvjiaxuan/type-challenges
- Owner: lvjiaxuan
- Created: 2022-08-05T09:17:30.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-11-09T00:56:13.000Z (about 2 months ago)
- Last Synced: 2024-11-12T15:04:00.554Z (about 2 months ago)
- Topics: type, typescript
- Language: TypeScript
- Homepage:
- Size: 624 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Collection of TypeScript type challenges
English | 简体中文 | 日本語 | 한국어 | Português## Intro
by the power of TypeScript's well-known Turing Completed type systemHigh-quality types can help improve projects' maintainability while avoiding potential bugs.
There are a bunch of awesome type utility libraries that may boost your works on types, like [ts-toolbelt](https://github.com/millsp/ts-toolbelt), [utility-types](https://github.com/piotrwitek/utility-types), [SimplyTyped](https://github.com/andnp/SimplyTyped), etc., which you can already use.
This project is aimed at helping you better understand how the type system works, writing your own utilities, or just having fun with the challenges. We are also trying to form a community where you can ask questions and get answers you have faced in the real world - they may become part of the challenges!
## Challenges
> Click the following badges to see details of the challenges.
> **Note**: Challenges work in the [strict mode](https://www.typescriptlang.org/tsconfig#strict).
warm-up (1)
easy (13)
-
4・Pick -
7・Readonly -
11・Tuple to Object -
14・First of Array -
18・Length of Tuple -
43・Exclude -
189・Awaited -
268・If -
533・Concat -
898・Includes -
3057・Push -
3060・Unshift -
3312・Parameters
medium (98)
-
2・Get Return Type -
3・Omit -
8・Readonly 2 -
9・Deep Readonly -
10・Tuple to Union -
12・Chainable Options -
15・Last of Array -
16・Pop -
20・Promise.all -
62・Type Lookup -
106・Trim Left -
108・Trim -
110・Capitalize -
116・Replace -
119・ReplaceAll -
191・Append Argument -
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・Fibonacci Sequence -
4260・AllCombinations -
4425・Greater Than -
4471・Zip -
4484・IsTuple -
4499・Chunk -
4518・Fill -
4803・Trim Right -
5117・Without -
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 -
9616・Parse URL Params -
9896・GetMiddleElement -
9898・Appear only once -
9989・Count Element Number To Object -
10969・Integer -
16259・ToPrimitive -
17973・DeepMutable -
18142・All -
18220・Filter -
21104・FindAll -
21106・Combination key type -
21220・Permutations of Tuple -
25170・Replace First -
25270・Transpose -
26401・JSON Schema to TypeScript -
27133・Square -
27152・Triangular number -
27862・CartesianProduct -
27932・MergeAll -
27958・CheckRepeatedTuple -
28333・Public Type -
29650・ExtractToObject -
29785・Deep Omit -
30301・IsOdd -
30430・Tower of hanoi -
30958・Pascal's triangle -
30970・IsFixedStringLiteralType -
34007・Compare Array Length
hard (54)
-
6・Simple Vue -
17・Currying 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・Two Sum -
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 -
28143・OptionalUndefined -
30178・Unique Items -
30575・BitwiseXOR -
31797・Sudoku -
31824・Length of String 3 -
32427・Unbox -
32532・Binary Addition -
33763・Union to Object from key -
34286・Take Elements
extreme (17)
-
5・Get Readonly Keys -
151・Query String Parser -
216・Slice -
274・Integers Comparator -
462・Currying 2 -
476・Sum -
517・Multiply -
697・Tag -
734・Inclusive Range -
741・Sort -
869・DistributeUnions -
925・Assert Array Index -
6228・JSON Parser -
7561・Subtract -
31447・CountReversePairs -
31997・Parameter Intersection -
33345・Dynamic Route
> ✨ [Upcoming challenges](https://github.com/type-challenges/type-challenges/issues?q=is%3Aissue+is%3Aopen+label%3Anew-challenge)
> 🔥 Start the challenge in [TypeScript Playground](https://www.typescriptlang.org/play?install-plugin=%40type-challenges%2Fplayground-plugin)
> 🚀 Start the challenge locally in [your IDE or text editor with TypeScript language support](#play-locally)
> ⚡️ Start the challenge in [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=YRM.type-challenges)
## Recommended Readings
### Official
- [The TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html)
- [Unions and Intersection Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types)
- [Literal Types](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types)
- [Utility Types](https://www.typescriptlang.org/docs/handbook/utility-types.html)
- [Advanced Types](https://www.typescriptlang.org/docs/handbook/2/types-from-types.html)
- [The New Handbook](https://github.com/microsoft/TypeScript-Website/tree/v2/packages/documentation/copy/en/handbook-v2)
### Articles
- [Learn Advanced TypeScript Types](https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab)
- [The Art of Type Programming](https://mistlog.medium.com/the-art-of-type-programming-cfd933bdfff7)
- [Type Query: jQuery Style Type Manipulation](https://mistlog.medium.com/type-query-jquery-style-type-manipulation-497ce26d93f)
- [TypeScript Deep Dive](https://basarat.gitbook.io/typescript/)
### Talks
- [Type Level Programming in Typescript](https://www.youtube.com/watch?reload=9&v=vGVvJuazs84)
### Projects / Solutions
- [🎥 Video Explanations and Solutions for every challenge!](https://www.youtube.com/playlist?list=PLOlZuxYbPik180vcJfsAM6xHYLVxrEgHC)
- [Type Challenges Solutions](https://github.com/ghaiklor/type-challenges-solutions)
- [Type Gymnastics](https://github.com/g-plane/type-gymnastics)
- [TypeType Examples](https://github.com/mistlog/typetype-examples)
### Books
- [Effective TypeScript](https://effectivetypescript.com/)
- [Learning TypeScript](https://www.learningtypescript.com/)
- [TypeScript in 50 Lessons](https://typescript-book.com/)
- [TypeScript Cookbook](https://typescript-cookbook.com/)
## How to Contribute
There are several ways you can contribute to this project
- Share your answers / solutions
- Propose new challenges
- Add more test cases to the existing challenges
- Provide learning resources or ideas of how to solve challenges
- Share the problems you have faced in real-world projects, regardless you having the solution or not - the community would help you as well
- Help with others by discussion in issues
- Contribute the infra of this project [TODOs.md](./TODOs.md)
Just [open an issue](https://github.com/type-challenges/type-challenges/issues/new/choose) and choose the corresponding template. Thanks!
## Play Locally
You can build the challenges and play locally using your preferred IDE or text editor with TypeScript language support.
To do that, you will need the latest version of [Node.js](https://nodejs.org/) and [pnpm](https://pnpm.io/) installed.
After cloning the repo, installed the dependencies by:
```bash
pnpm install
```
Then and run the `generate` script:
```bash
pnpm generate
```
It will prompt you to select the desired language, then you can find the generated challenges in the `./playground` folder.
Later if you want to update playground while keeping your changes:
```bash
pnpm generate --keep-changes
```
OR
```bash
pnpm generate -K
```
## Thanks
This project was born from solving real-world types problem with [@hardfist](https://github.com/hardfist) and [@MeCKodo](https://github.com/MeCKodo). And great thanks to [@sinoon](https://github.com/sinoon) who contributed a lot while giving early feedback on this project.
### Inspired by
- [piotrwitek/utility-types](https://github.com/piotrwitek/utility-types)
- [psmyrdek/typescript-challenges](https://github.com/psmyrdek/typescript-challenges)
- [andnp/SimplyTyped](https://github.com/andnp/SimplyTyped)
### [Contributors](https://github.com/type-challenges/type-challenges/graphs/contributors)
![Contributors](https://contrib.rocks/image?repo=type-challenges/type-challenges)
## License
MIT