TypeScript claims no error even if parameter has the wrong type
There is no issue because (x: number) => void
is assignable to (x: number) => number
. And here is a prove of that:
type F = (x: number) => voidtype Z = (x: number) => numbertype ZextendsF = Z extends F ? true : false // evaluate to true
And this fact is totally fine for the program flow. If your interface says - I require a function which does not return, then If I pass a function which return something, its fully ok, as I will never use this return data. It is type safe and nothing to worry about.
More details about functions assignability - Comparing two functions. Also more details about TypeScript types behavior and relation - types assignability.