Lab 02: Generics
Step 1: Setup
docker run -it --rm node:20-alpine sh
npm install -g typescript ts-node
mkdir /lab02 && cd /lab02
cat > tsconfig.json << 'EOF'
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true
}
}
EOFStep 2: Generic Functions
Step 3: Generic Classes
Step 4: Generic Interfaces and Constraints
Step 5: Default Type Parameters
Step 6: Built-in Utility Types
Step 7: Generic Constraints in Practice
Step 8: Capstone — Generic Repository
Summary
Concept
Syntax
Use Case
Last updated
