I am getting a weird TypeScript error.
I have the following example:
interface Foo {
prop: 0 | 1 | 2;
}
class Bar implements Foo {
prop = 1;
}
And I am getting the error:
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;
~~~~
Why does this code give the error?