title: TypeScript: Union type of objects without defining the whole type on each side
body: <p>I am converting frontend Java to TypeScript and i am dealing with method overloading.</p>
  
  <p>I want to write the types like this</p>
  
  <pre><code>const person = (info: {name:string, age:number} | {man:boolean}): void =&gt; {
      if (typeof info.man === "boolean") {
          console.log("man is defined", info.man);
      } else {
          console.log(info.name, info.age);
      }
  }
  
  person({name:"Joe", age:25});
  person({ man: false});
  </code></pre>
  
  <p>But i have it like this to make TypeScript happy</p>
  
  <pre><code>const person = (info: {name:string, age:number, man?:undefined} 
    | {name?:string, age?:number, man:boolean}): void =&gt; {
      if (typeof info.man === "boolean") {
          console.log("man is defined", info.man);
      } else {
          console.log(info.name, info.age);
      }
  }
  
  person({name:"Joe", age:25});
  person({ man: false});
  </code></pre>
  
  <p>I am hoping that there is a prettier way to define the types to make it more readable</p>