title: TypeScript error: "Type 'number' is not assignable to type '0 | 1 | 2' ". Why am I getting this error?
body: <p>I am getting a weird TypeScript error.</p>
  
  <p>I have the following example:</p>
  
  <pre><code>interface Foo {
    prop: 0 | 1 | 2;
  }
  
  class Bar implements Foo {
    prop = 1;
  }
  
  </code></pre>
  
  <p>And I am getting the error:</p>
  
  <pre><code>src/example.ts:6:3 - error TS2416: Property 'prop' in type 'Bar' is not assignable to the same property in base type 'Foo'.
    Type 'number' is not assignable to type '0 | 1 | 2'.
  
  6   prop = 1;
      ~~~~
  </code></pre>
  
  <p>Why does this code give the error?</p>