title: Why does the && operator produce the type of the second operand
body: <p>The TypeScript specification states in §4.15.6 about the <code>&amp;&amp;</code> operator:</p>
  
  <blockquote>
    <p>The &amp;&amp; operator permits the operands to be of any type and produces a <strong>result of the same type as the second operand</strong>.</p>
  </blockquote>
  
  <p>In Javascript, the <code>&amp;&amp;</code> operator returns the first operand if it is falsy, otherwise it returns the second operand (<a href="http://es5.github.com/#x11.11">see ECMA-262 §11.11</a>).</p>
  
  <p>That means that if the left operand is falsy, <code>&amp;&amp;</code> will return a value that matches the type of the left operand. For example,</p>
  
  <pre><code>typeof ( false &amp;&amp; {}      ) === "boolean" // true
  typeof ( ''    &amp;&amp; 1       ) === "string"  // true
  typeof ( null  &amp;&amp; "hello" ) === "object"  // true
  typeof ( NaN   &amp;&amp; true    ) === "number"  // true
  </code></pre>
  
  <p>Typescript, according to the rule quoted above, would <em>incorrectly</em> predict the types of the above expressions to be <code>Object</code>, <code>Number</code>, <code>String</code> and <code>Boolean</code>, respectively.</p>
  
  <p>Am I missing something? Is there a good reason to make the type of an <code>&amp;&amp;</code> expression match the type of the second operand? Shouldn't the result type behave like the <code>||</code> operator, and return the best common type of the two operands, and <code>Any</code> if there is no best common type?</p>