GithubHelp home page GithubHelp logo

pablorosales / typescript-generics-workshop-solutions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from total-typescript/typescript-generics-workshop

1.0 2.0 0.0 201 KB

Interactive tutorial on using generics in TypeScript - Solutions

Home Page: https://totaltypescript.com

JavaScript 6.24% TypeScript 93.76%

typescript-generics-workshop-solutions's Introduction

Generics in TypeScript: a deep dive

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.

Prerequisites

This module is not recommended for beginners. You'll need to have completed:

  1. TypeScript for Beginners
  2. Intermediate TypeScript - not yet complete
  3. Type Transformations - not yet complete

Still, if you want to continue - go ahead!

Work in progress!

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!

Quickstart

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

How to take the course

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:

  1. Go into *.problem.ts
  2. Run 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:

  1. Check out TypeScript's docs
  2. Try to find something that looks relevant.
  3. Give it a go to see if it solves the problem.

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.

Acknowledgements

Say thanks to Matt on Twitter or by joining his Discord. Consider signing up to his Total TypeScript course.

Reference

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.

typescript-generics-workshop-solutions's People

Contributors

mattpocock avatar romain-trotard avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.