Exercices CM 1
This commit is contained in:
15
exercice2.ts
Normal file
15
exercice2.ts
Normal 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" });
|
||||
Reference in New Issue
Block a user