title: Weird Behaviour of typescript when declaring variable using interface
body: <p>I am using the interface to define a type of variable and initializing that variable with a class that has some additional properties than the interface.
  please refer to the code below:</p>
  <pre><code>interface User {
    name: string;
    id: number;
  }
  
  class UserAccount {
    name: string;
    id: number;
    username: string
  
    constructor(name: string, id: number, username: string) {
      this.name = name;
      this.id = id;
      this.username = username;
    }
  }
  
  const user: User = new UserAccount(&quot;Suraj&quot;, 1, &quot;srs&quot;);
  // user.username
  // I will not be able to access username in above line but when I console it, it will show the value assigned by the class constructor
  console.log(user)
  // output will be **UserAccount { name: 'Murphy', id: 1, username: 'srs' }**
  </code></pre>
  <p>My question is:</p>
  <ol>
  <li>Why we are using Interface when we are initializing variables with the class?</li>
  <li>And if we are using this then why it is not an error in the typescript when compiling?</li>
  <li>And last if we are able to assign it (UserAccount { name: 'Murphy', id: 1, <em>username: 'srs'</em> }) then why can't we access <em>user.username</em>?</li>
  </ol>