Why the first code is working but not the second one?
// Why this is not working function runAfter1s(fn: () => number){ setTimeout(fn, 1000) } const doSomething: () => void = () => { console.log(‘Hello’) return 5; } runAfter1s(doSomething) Why this is working function runAfter1s(fn: () => void){ setTimeout(fn, 1000) > } const doSomething: () => void = () […]
Typescript types: Is there a better way to write function type signature in typescript which can restrict the following runtime error?
The following code snippet passes typescript checks