I can’t understand this code:
type MyFuncType = (a:number) => void
function MyFunc(a:MyFuncType) {
return a(2)
}
MyFunc((a) => { return 'a'})
I expect TypeScript to prevent me from returning a string in the function, but it allows me to return a string. The expectation is to return void/empty/nothing, not a string
Why won’t TypeScript warn me for a wrong type return?
New contributor
oliviarizona is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3