Exercices CM 1

This commit is contained in:
khannurien
2026-01-16 20:21:02 +01:00
parent ed3100a3e7
commit 1eb0ffc866
7 changed files with 230 additions and 0 deletions

15
exercice2.ts Normal file
View File

@@ -0,0 +1,15 @@
interface Utilisateur {
nom: string;
age: number;
}
function afficherUtilisateur(u: Utilisateur): void {
console.log(`${u.nom} a ${u.age} ans`);
}
afficherUtilisateur({ nom: "Alice", age: 25 });
// L'argument de type '{ nom: string; }' n'est pas attribuable
// au paramètre de type 'Utilisateur'.
// La propriété 'age' est absente du type '{ nom: string; }'
// mais obligatoire dans le type 'Utilisateur'.ts(2345)
afficherUtilisateur({ nom: "Bob" });