Lab 01: Type System Deep Dive
Step 1: Setup Environment
docker run -it --rm node:20-alpine sh
apk add --no-cache git
npm install -g typescript ts-node
mkdir /lab01 && cd /lab01
cat > tsconfig.json << 'EOF'
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true
}
}
EOFStep 2: Union and Intersection Types
Step 3: Type Narrowing — typeof / instanceof / in
Step 4: Discriminated Union Pattern
Step 5: Literal Types
Step 6: Template Literal Types
Step 7: Const Assertions
Step 8: Capstone — Full Type Safety Demo
Summary
Concept
Syntax
Use Case
Last updated
