I am studying typescript with gpteachus and I got this code that i can’t wrap my head around it:
type MyFuncType = (a:number) => void
function MyFunc(a:MyFuncType) {
return a(2)
}
MyFunc((a) => { return 'a'})
I expect typescript to prevent my from returning a string in the function! but it allows me to return a string. the expectation is to return void/empty/noting. not a string
Why typescript won’t warn me for a wrong type return?
Thanks!
I read typescript docs, I look up code examples online and via other people codebase but couldn’t find an answer