title: TypeScript interface optional properties and return type
body: <p>I'm new to typescript and now going over the docs and there is this example in "Optional Properties" section :</p>
  
  <pre><code>interface SquareConfig {
    color?: string;
    width?: number;
  }
  
  function createSquare(config: SquareConfig): { color: string; area: number } {
    let newSquare = { color: "white", area: 100 };
    if (config.color) {
      newSquare.color = config.color;
    }
    if (config.width) {
      newSquare.area = config.width * config.width;
    }
    return newSquare;
  }
  
  let mySquare = createSquare({ color: "black" });
  </code></pre>
  
  <p>Now, i do understand what optional properties are, but what confused me is the <code>: { color: string; area: number }</code> in the function arguments.Is it because they want to do type checking against the variables <code>color</code> and <code>area</code>? and if that is the case why they write them in function arguments rather than place them within the function and do type checking like below </p>
  
  <pre><code>let color:string;
  let area: number;
  </code></pre>
  
  <p>can you please explain what does it do in this code snippet ? </p>