title: Why boolean becomes true?
body: <p>Take a look at following <a href="https://www.typescriptlang.org/play/#src=export%20class%20Smth%20%7B%0D%0A%20%20private%20flag%3A%20boolean%3B%0D%0A%0D%0A%20%20public%20update()%20%7B%0D%0A%20%20%20%20this.flag%20%3D%20true%3B%0D%0A%0D%0A%20%20%20%20this.inner()%3B%0D%0A%0D%0A%20%20%20%20if%20(this.flag%20%3D%3D%3D%20false)%20%7B%20%2F%2F%20Operator%20&#39;%3D%3D%3D&#39;%20cannot%20be%20applied%20to%20types%20&#39;true&#39;%20and%20&#39;false&#39;.%0D%0A%20%20%20%20%20%20console.log(123)%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%7D%0D%0A%0D%0A%20%20private%20inner()%20%7B%0D%0A%20%20%20%20this.flag%20%3D%20false%3B%0D%0A%20%20%7D%0D%0A%7D" rel="noreferrer">code</a>:</p>
  
  <pre><code>export class Smth {
    private flag: boolean;
  
    public update() {
      this.flag = true;
  
      this.inner();
  
      if (this.flag === false) { // Operator '===' cannot be applied to types 'true' and 'false'.
        console.log(123);
      }
    }
  
    private inner() {
      this.flag = false;
    }
  }
  </code></pre>
  
  <p>I can't understand what's wrong with the line</p>
  
  <pre><code>if (this.flag === false)
  </code></pre>
  
  <p>Typescript says</p>
  
  <blockquote>
    <p>Operator '===' cannot be applied to types 'true' and 'false'.</p>
  </blockquote>
  
  <p>But actually there are <code>boolean</code> and <code>false</code>.</p>
  
  <p>I'm using typescript 2.6.2 but online playground shows the same result with 2.7.</p>
  
  <hr>
  
  <p>It's not a dublicate of <a href="https://stackoverflow.com/q/39243143/4928642">Operator &#39;==&#39; cannot be applied to types x and y in Typescript 2</a> as that question is about comparing constants. But in my code it's a chagable class field and there is a function that changes the value. Moreover, it is called.</p>
  
  <pre><code>this.flag = true;
  
  this.inner(); // exectues this.flag = false;
  
  if (this.flag === false) { // ... types 'true' and 'false'. - WHY?
  </code></pre>