Is it possible to configure the TypeScript compiler to generate an error when a function is called with an argument that can belong to both cases in a union type? For example:
interface Name {
name: string
}
interface Email {
email: string
}
type NameOrEmail = Name | Email
function print(p: NameOrEmail) {
console.log(p)
}
print({name: 'alice'}) // This works fine
print({email: 'alice'}) // This also works
print({email: 'alice', name: 'alice'}) // Currently this works, but I want it to trigger an error
print({email: 'alice', age: 33}) // This should not work