function f(x:boolean|string) { return x }
f(true) // boolean | string
Why can't typescript understand that the return value is a boolean?
function f(x:boolean|string) {
return typeof x === 'boolean' ? true : 'str'
}
f(true) // boolean | string
It can't understand this either.
Do I need to manually setup a function overload definition?