Running in TypeScript 3.9.7, this does not concern the compiler:
const someFn: () => void = () => 123;
I discovered this answer, which
A return type of void
means typescript won't let you use the return value, whatever it is. But as you note, that doesn't prevent from returning something. You won't be changing that behaviour.
() => void
means you don't care what the return value is, because you don't plan to use it. But, in this case you do care.
So you can declare a function type that enforces that it does not return any value by using a return type of undefined
.
const someFn: () => undefined = () =>
// Type 'Promise<unknown>' is not assignable to type 'undefined'.
new Promise((resolve, reject) => reject(Error('onoez')));