Files
m1-sor-exercises/exercice1.ts
2026-01-16 20:25:02 +01:00

19 lines
576 B
TypeScript

function addition(a, b) {
return a + b;
}
console.log(addition(2, 3)); // attendu : 5
console.log(addition("2", 3)); // attendu : ?
console.log(addition(true, 3)); // attendu : ?
namespace Typed {
function addition(a: number, b: number): number {
return a + b;
}
console.log(addition(2, 3));
// L'argument de type 'string' n'est pas attribuable au paramètre de type 'number'.ts(2345)
console.log(addition("2", 3));
// L'argument de type 'boolean' n'est pas attribuable au paramètre de type 'number'.ts(2345)
console.log(addition(true, 3));
}