title: TypeScript strict null check on field of object in array
body: <p>In TypeScript, despite checking for null on a nullable field in an object array  (with <code>strictNullCheck</code> set to <code>true</code>), the compiler still complains that the 'Object is possibly undefined'. Consider the following:</p>
  
  <pre><code>interface IA {
      d?: Date
  }
  const arr : IA[] = [{d: new Date()}];
  
  console.error(arr[0].d == null ? "" : arr[0].d.toString());  
                                             // ^ complains that "Object is possibly 'undefined'
  </code></pre>
  
  <p><a href="http://www.typescriptlang.org/play/#src=interface%20IA%20%7B%0D%0A%20%20%20%20d%3F%3A%20Date%0D%0A%7D%0D%0Aconst%20arr%20%3A%20IA%5B%5D%20%3D%20%5B%7Bd%3A%20new%20Date()%7D%5D%3B%0D%0A%0D%0Aconsole.error(arr%5B0%5D.d%20%3D%3D%20null%20%3F%20%22%22%20%3A%20arr%5B0%5D.d.toString())%3B" rel="nofollow noreferrer">Link</a> to TS PlayGround (set <code>strictNullCheck</code> on)</p>
  
  <p>However, if we have:</p>
  
  <pre><code>const a : IA = {d: new Date()};
  console.error(a.d == null ? "" : a.d.toString());
  </code></pre>
  
  <p>then the compiler is happy.</p>
  
  <p>Why is this the desired behavior? And what would be the correct practice here if I don't want to turn <code>strictNullCheck</code> off?</p>