title: Type narrowing breaks when accessing an object property with bracket notation
body: <p>Why do tests 1 and 2 work here, but test 3 shows a compiler error at <code>foo[barConst]++</code>: 'Object is possibly &quot;undefined&quot;.'? I often need to access properties via bracket notation and thus like to have constants for these properties, but TypeScript doesn't allow this. It also doesn't work with <code>const enum</code>s. Is it a bug or is there a good reason for the error?</p>
  <pre class="lang-js prettyprint-override"><code>const barConst = 'bar';
  
  interface Foo {
      [barConst]?: number;
  }
  
  function test1(foo?: Foo) {
      if (foo &amp;&amp; foo.bar) {
          foo.bar++;
      }
  }
  
  function test2(foo?: Foo) {
      if (foo &amp;&amp; foo['bar']) {
          foo['bar']++;
      }
  }
  
  function test3(foo?: Foo) {
      if (foo &amp;&amp; foo[barConst]) {
          foo[barConst]++; // compiler error: 'Object is possibly &quot;undefined&quot;.'
      }
  }
  </code></pre>
  <p><a href="https://tsplay.dev/mb0jow" rel="nofollow noreferrer">Playground</a></p>