一息にいいますと、絞り込めるようになるってことです。
interface Interface01 {
type: "Interface01";
Interface01: number;
}
interface Interface02 {
type: "Interface02";
Interface02: number;
}
type InterfaceUnion = Interface01 | Interface02;
function interfaceSearch(arg: InterfaceUnion) {
let typeNumber: number;
switch (arg.type) {
case "Interface01":
typeNumber = arg.Interface01;
break;
case "Interface02":
typeNumber = arg.Interface02;
}
console.log("Interface01: " + typeNumber);
}
interfaceSearch({ type: "Interface01", Interface01: 10 });