Is there a way to create a type guard helper function that Internally does type validation?
type GreenBanana = { name: 'banana', color: 'green'}
type RedBanana = { name: 'banana', color: 'red'}
type Apple = { name: 'apple', color: 'green'}
type Fruit = GreenBanana | RedBanana | Apple
function isBanana(f: Fruit): f is RedBanana {
return f.name === 'banana' // ok, should error saying that f.name could be RedBanana | GreenBanana
}