I am trying to create a TypeScript function that accepts an argument matching one of two conditions:
type A = {
x: string
}
type B = {
y: string
}
function testFunc(param: A | B) {
...
}
However, TypeScript allows me to call the function with both keys:
testFunc({x: "x", y: "y"})
Shouldn't the union type restrict the function to only accept either A or B?
Playground showcasing the issue here