Generic Functions
in TypeScript
Generic Functions in TypeScript
Workshop repository:
https://github.com/moonhighway/generic-functions-in-typescript-workshop
Required: Node.js >= v18.0.0
Recommended: Visual Studio Code (with GitHub Copilot disabled)
Setup:
If you've already cloned the repository, bring it up-to-date:
git pull
Then install dependencies by running:
npm install
Types of activity
- 😲 Slides & Samples: I show you amazing things!
-
💪🏻 Exercise: We code together and practice what we’ve just learnt.
- Steps are in the README.md for the exercise if you need them at any point.
-
🧑🔬 Lab: Tackle a coding challenge by yourself. After we'll review a solution.
- Lab requirements are in the README.md for each lab.
Generics
Generics
"Generics" in TypeScript
Things which are generic.
Generics
Things which can be generic
Functions function someFunction(){...}
Classes class SomeClass(){...}
Types type SomeType = {...}
Generics
Type parameters
Functions function someFunction<Type>(){...}
Classes class SomeClass()<Type>{...}
Types type SomeType<Type> = {...}
Adding a type parameter makes the "thing" generic! ✨
Generic Functions in TypeScript
By Moon Highway
Generic Functions in TypeScript
- 48