total-typescript / typescript-generics-tutorial
- пятница, 2 сентября 2022 г. в 00:33:15
Interactive tutorial on using generics in TypeScript
Generics in TypeScript are one of the most powerful, least well-documented features of an extraordinary language. They allow for some of the wizardry you'll have seen in your favourite open-source libraries.
In this module, we'll build our generics knowledge with practical examples taken from real open-source libraries. After completing it, you'll feel confident enough to start experimenting with your own ideas.
This module is not recommended for beginners. You'll need to have completed:
Still, if you want to continue - go ahead!
This module is a work-in-progress. Exercises may appear out of order, and there will likely be a lot of content inside the FUTURE
notes.
You'll still be able to run through the exercises, but expect some bumps along the way!
Clone this repo or open in Gitpod.
# Installs all dependencies
yarn install
# Starts the first exercise
yarn exercise 01
# Runs linting and tests on the solution
yarn solution 01
You'll notice that the course is split into exercises. Each exercise is split into a *.problem.ts
and a *.solution.ts
.
To take an exercise:
*.problem.ts
yarn exercise 01
, where 01
is the number of the exercise you're on.The exercise
script will run TypeScript typechecks and a test suite on the exercise.
This course encourages active, exploratory learning. In the video, I'll explain a problem, and you'll be asked to try to find a solution. To attempt a solution, you'll need to:
You'll know if you've succeeded because the tests will pass.
If you succeed, or if you get stuck, unpause the video and check out the *.solution.ts
. You can see if your solution is better or worse than mine!
You can run yarn solution 01
to run the tests and typechecking on the solution.
Say thanks to Matt on Twitter or by joining his Discord. Consider signing up to his Total TypeScript course.
yarn exercise 01
Alias: yarn e 01
Run the corresponding *.problem.ts
file.
yarn solution 01
Alias: yarn s 01
Run the corresponding *.solution.ts
file. If there are multiple, it runs only the first one.