Introduction
A structured training plan is essential for any developer looking to progress efficiently. In 2026, combining theory and practice through code enables precise tracking of acquired skills. This tutorial shows you how to design a simple yet complete system to manage learning paths.
Prerequisites
- Node.js 20+
- Basic knowledge of TypeScript
- An editor like VS Code
Initialize the project
mkdir plan-formation
cd plan-formation
npm init -y
npm install typescript @types/node
npx tsc --initThis command creates the project folder and installs TypeScript to type our training plan. The generated tsconfig.json file enables strict compilation suitable for beginners.
Define the types
export interface Module {
id: number;
titre: string;
duree: number;
complete: boolean;
}
export interface PlanFormation {
id: number;
nom: string;
modules: Module[];
}These TypeScript interfaces define the structure of a training plan. They ensure data consistency and facilitate code maintenance.
Create initial data
import { PlanFormation } from './types';
export const planInitial: PlanFormation = {
id: 1,
nom: "Débutant TypeScript",
modules: [
{ id: 1, titre: "Bases du langage", duree: 4, complete: false },
{ id: 2, titre: "Types et interfaces", duree: 3, complete: false },
{ id: 3, titre: "Fonctions avancées", duree: 5, complete: false }
]
};This file contains a concrete example of a training plan. It is ready to use and can be imported into any application.
Progress function
import { PlanFormation } from './types';
export function calculerProgression(plan: PlanFormation): number {
const total = plan.modules.length;
const completes = plan.modules.filter(m => m.complete).length;
return total > 0 ? Math.round((completes / total) * 100) : 0;
}
export function marquerComplete(plan: PlanFormation, moduleId: number): PlanFormation {
return {
...plan,
modules: plan.modules.map(m =>
m.id === moduleId ? { ...m, complete: true } : m
)
};
}These functions calculate the progress percentage and mark a module as complete. They are pure and easily testable.
Main script
import { planInitial } from './data';
import { calculerProgression, marquerComplete } from './progression';
let monPlan = planInitial;
console.log("Progression initiale:", calculerProgression(monPlan), "%");
monPlan = marquerComplete(monPlan, 1);
console.log("Progression après module 1:", calculerProgression(monPlan), "%");This executable script demonstrates the full usage of the training plan. Run it with ts-node to see the results live.
Best practices
- Always type data with interfaces
- Separate responsibilities (types, data, logic)
- Add unit tests for calculation functions
- Version training plans
- Make the system extensible for new modules
Common mistakes
- Forgetting to update the object after modification
- Not handling empty list cases
- Using any instead of strict types
- Ignoring module ID validation
Going further
Explore additional resources on building training tracking applications.