Parameter types
Every parameter in a TypeScript function should carry an explicit type — the compiler will not infer one for you from thin air, so an unannotated parameter is flagged as an implicit any under standard settings. The same rule applies to arrow functions assigned to a const, whether they are declared with a block body or as a single expression.
You should see
20
5c: number to multiply and use it in the return expression.TS2554: calling with the wrong number of arguments
function multiply(a: number, b: number): number {
return a * b
}
multiply(4)app.ts:4:1 - error TS2554: Expected 2 arguments, but got 1.
4 multiply(4)
~~~~~~~~~~~Both parameters are required — neither has a ? or a default value — so the function's type demands exactly two arguments at every call site.
Pass both arguments, or make the second one optional if calling with only one genuinely makes sense.
function multiply(a: number, b: number): number {
return a * b
}
multiply(4, 5): number after multiply(a: number, b: number) and TypeScript infers it from return a * b — but the parameter types themselves cannot be dropped the same way, because there is no call yet for the compiler to infer them from.